Skip to content

Commit

Permalink
Creating python API for Nox sessions (#1414)
Browse files Browse the repository at this point in the history
* Update config.yml - fix Circle CI pipeline

* Playground Implementation

* Playground Implementation

* Support CLI batching, and more

* Update CLI test

* Update CLI test

* Update CLI test

* CLI test Update

* A few fix on the playground test

* A few fix on the playground test

* A few fix on the playground test

* Playground with all command at #1368

* Playground with all command at #1368

* Playground with all command at #1368

* Playground with all command at #1368

* Playground with all command at #1368

* Playground with all command at #1368

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground

* Session Parallelization on CLI test playground with pytest dependency

* Rich lib integration pyproject config

* Make the serializer use the fields from the header (#1406)

* Generalize Standard Run  (#1411)

* Modify header calculation to choose from predefined example output file or standard example output file

* Remove the readiness function from SCRA because it is redundant, since those checks are also performed by the amenable function

* Remove unused method

* Make csv serialization work for any kind of model api response

* Remove the standard flag from the CLI since it is now the default run

* Update tests

* Creating python for Nox sessions

* Creating python for Nox sessions

* Generalize Standard Run  (#1411)

* Modify header calculation to choose from predefined example output file or standard example output file

* Remove the readiness function from SCRA because it is redundant, since those checks are also performed by the amenable function

* Remove unused method

* Make csv serialization work for any kind of model api response

* Remove the standard flag from the CLI since it is now the default run

* Update tests

* Generalize Standard Run  (#1411)

* Modify header calculation to choose from predefined example output file or standard example output file

* Remove the readiness function from SCRA because it is redundant, since those checks are also performed by the amenable function

* Remove unused method

* Make csv serialization work for any kind of model api response

* Remove the standard flag from the CLI since it is now the default run

* Update tests

* Make the serializer use the fields from the header (#1406)

* Merge sample command with the example command (#1422)

* Merge sample command with the example command

* Fix example command usage

* Generalize Standard Run  (#1411)

* Modify header calculation to choose from predefined example output file or standard example output file

* Remove the readiness function from SCRA because it is redundant, since those checks are also performed by the amenable function

* Remove unused method

* Make csv serialization work for any kind of model api response

* Remove the standard flag from the CLI since it is now the default run

* Update tests

* Conflict resolved with upstream

* Conflict resolved with upstream

* Generalize Standard Run  (#1411)

* Modify header calculation to choose from predefined example output file or standard example output file

* Remove the readiness function from SCRA because it is redundant, since those checks are also performed by the amenable function

* Remove unused method

* Make csv serialization work for any kind of model api response

* Remove the standard flag from the CLI since it is now the default run

* Update tests

* Make the serializer use the fields from the header (#1406)

* Generalize Standard Run  (#1411)

* Modify header calculation to choose from predefined example output file or standard example output file

* Remove the readiness function from SCRA because it is redundant, since those checks are also performed by the amenable function

* Remove unused method

* Make csv serialization work for any kind of model api response

* Remove the standard flag from the CLI since it is now the default run

* Update tests

* Conflict resolved with upstream

* Conflict resolved with upstream

* Unnecessary files removed

* Generalize Standard Run  (#1411)

* Modify header calculation to choose from predefined example output file or standard example output file

* Remove the readiness function from SCRA because it is redundant, since those checks are also performed by the amenable function

* Remove unused method

* Make csv serialization work for any kind of model api response

* Remove the standard flag from the CLI since it is now the default run

* Update tests

* Unnecessary files removed

* Generalize Standard Run  (#1411)

* Modify header calculation to choose from predefined example output file or standard example output file

* Remove the readiness function from SCRA because it is redundant, since those checks are also performed by the amenable function

* Remove unused method

* Make csv serialization work for any kind of model api response

* Remove the standard flag from the CLI since it is now the default run

* Update tests

* Make the serializer use the fields from the header (#1406)

* Unnecessary files removed

* Unnecessary files removed

* Unnecessary files removed

* Unnecessary files removed

* Fix: Unnecessary files removed

---------

Co-authored-by: Dhanshree Arora <[email protected]>
  • Loading branch information
Abellegese and DhanshreeA authored Dec 10, 2024
1 parent ff9e2b6 commit 175b677
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ersilia/serve/standard_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def _read_information_file(self):
with open(os.path.join(self.path, INFORMATION_FILE), "r") as f:
info = json.load(f)
return info

except FileNotFoundError:
self.logger.debug(
f"Error: File '{INFORMATION_FILE}' not found in the path '{self.path}'"
Expand Down Expand Up @@ -295,6 +294,7 @@ def serialize_to_csv(self, input_data, result, output_data):
result[idx] = item[list(item.keys())[0]]

assert len(input_data) == len(result)

with open(output_data, "w") as f:
writer = csv.writer(f)
writer.writerow(self.header)
Expand Down
71 changes: 71 additions & 0 deletions test/playground/runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import subprocess
import yaml
from pathlib import Path


class NoxSession:

def __init__(self, name):
self.name = name

def execute(self, noxfile):
try:
subprocess.run(
["nox","-f", noxfile, "-s", self.name],
check=True,
)
print(f"Session '{self.name}' executed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error executing session '{self.name}': {e}")


class NoxRunner:
def __init__(self, config_path="config.yml", noxfile="noxfile.py"):
self.original_dir = Path.cwd()
self.config_path = Path(config_path)
self.noxfile = noxfile
self.config = yaml.safe_load(self.config_path.read_text())
self.nox_command = "nox"
self.queue = []

def update_yaml_values(self, new_values: dict):
existing_config = yaml.safe_load(self.config_path.read_text())
existing_config.update(new_values)
self.config_path.write_text(yaml.dump(existing_config))

def get_python_version(self):
return self.config.get("python_version", "3.10.10")

def add_session(self, session_name):
self.queue.append(NoxSession(session_name))

def execute_all(self):

for session in self.queue:
session.execute(self.noxfile)
self.queue.clear()

def clear_queue(self):
self.queue.clear()

def setup(self):
self.add_session("setup")

def test_from_github(self):
self.add_session("test_from_github")

def test_from_dockerhub(self):
self.add_session("test_from_dockerhub")

def test_auto_fetcher_decider(self):
self.add_session("test_auto_fetcher_decider")

def test_fetch_multiple_models(self):
self.add_session("test_fetch_multiple_models")

def test_serve_multiple_models(self):
self.add_session("test_serve_multiple_models")

def test_conventional_run(self):
self.add_session("test_conventional_run")

0 comments on commit 175b677

Please sign in to comment.