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 committed Dec 12, 2024
1 parent 82e8200 commit a16e320
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 10 additions & 3 deletions ersilia/cli/commands/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def example_cmd():
def example():
pass


@example.command()
@click.argument("model", required=False, default=None, type=click.STRING)
@click.option("--n_samples", "-n", default=5, type=click.INT)
Expand All @@ -50,6 +49,15 @@ def inputs(model, n_samples, file_name, simple, predefined):
else:
session = Session(config_json=None)
model_id = session.current_model_id()
if model_id is None:
click.echo(
click.style(
"Error: No model id given and no model found running in this shell.",
fg="red",
),
err=True,
)
return
eg = ExampleGenerator(model_id=model_id)
if file_name is None:
echo(
Expand All @@ -61,7 +69,6 @@ def inputs(model, n_samples, file_name, simple, predefined):
else:
eg.example(n_samples, file_name, simple, try_predefined=predefined)


@example.command()
@click.option("--n_samples", "-n", default=5, type=click.INT)
@click.option("--file_name", "-f", default=None, type=click.STRING)
Expand All @@ -71,4 +78,4 @@ def models(n_samples, file_name):
if file_name is None:
echo(json.dumps(sampler.sample(n_samples), indent=4))
else:
sampler.sample(n_samples, file_name)
sampler.sample(n_samples, file_name)
2 changes: 1 addition & 1 deletion ersilia/io/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def example(self, n_samples, file_name, simple, try_predefined):
if try_predefined is True and file_name is not None:
self.logger.debug("Trying with predefined input")
predefined_available = self.predefined_example(file_name)

if predefined_available:
with open(file_name, "r") as f:
return f.read()
Expand Down
4 changes: 3 additions & 1 deletion ersilia/utils/exceptions_utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def run_from_terminal(self):
output_file = os.path.join(framework_dir, "example_output.csv")
tmp_folder = make_temp_dir(prefix="ersilia-")
log_file = os.path.join(tmp_folder, "terminal.log")
run_command("ersilia example inputs {0} -n 3 -f {1}".format(self.model_id, input_file))
run_command(
"ersilia example inputs {0} -n 3 -f {1}".format(self.model_id, input_file)
)
cmd = "bash {0} {1} {2} {3} 2>&1 | tee -a {4}".format(
exec_file, framework_dir, input_file, output_file, log_file
)
Expand Down

0 comments on commit a16e320

Please sign in to comment.