Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bench): Only validate the relevant site's config #176

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions agent/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import redis

from agent.exceptions import AgentException
from agent.job import connection
from agent.utils import get_execution_result

Expand Down Expand Up @@ -233,8 +234,3 @@ def retrieve_log(self, name):
log_file = os.path.join(self.logs_directory, name)
with open(log_file) as lf:
return lf.read()


class AgentException(Exception):
def __init__(self, data):
self.data = data
18 changes: 12 additions & 6 deletions agent/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from agent.app import App
from agent.base import AgentException, Base
from agent.exceptions import SiteNotExistsException
from agent.exceptions import InvalidSiteConfigException, SiteNotExistsException
from agent.job import job, step
from agent.site import Site
from agent.utils import download_file, end_execution, get_execution_result, get_size
Expand Down Expand Up @@ -790,18 +790,24 @@ def _sites(self, validate_configs=False) -> dict[str, Site]:
sites[directory] = Site(directory, self)
except json.decoder.JSONDecodeError as jde:
output = self.readable_jde_err(f"Error parsing JSON in {directory}", jde)
self.execute(
f"echo '{output}';exit {int(validate_configs)}",
) # exit 1 to make sure the job fails and shows output
try:
self.execute(
f"echo '{output}';exit {int(validate_configs)}",
) # exit 1 to make sure the job fails and shows output
except AgentException as e:
raise InvalidSiteConfigException(e.data, directory) from e
except Exception:
pass
return sites

def get_site(self, site):
try:
return self.valid_sites[site]
except KeyError as exc:
raise SiteNotExistsException(site, self.name) from exc
except KeyError as e:
raise SiteNotExistsException(site, self.name) from e
except InvalidSiteConfigException as e:
if e.site == site:
raise

@property
def step_record(self):
Expand Down
11 changes: 11 additions & 0 deletions agent/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from __future__ import annotations


class AgentException(Exception):
def __init__(self, data):
self.data = data


class BenchNotExistsException(Exception):
def __init__(self, bench):
self.bench = bench
Expand All @@ -16,3 +21,9 @@ def __init__(self, site, bench):
self.message = f"Site {site} does not exist on bench {bench}"

super().__init__(self.message)


class InvalidSiteConfigException(AgentException):
def __init__(self, data: dict, site=None):
self.site = site
super().__init__(data)