Skip to content

Commit

Permalink
Playground with all command at ersilia-os#1368
Browse files Browse the repository at this point in the history
  • Loading branch information
Abellegese committed Nov 18, 2024
1 parent 71ea736 commit b189365
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 41 deletions.
15 changes: 0 additions & 15 deletions test/playground/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,6 @@ def apply_rules(
expected_status=True,
)
)
checkups.append(
get_rule(
"dockerhub_status",
dest_path=dest_path,
expected_status=False,
)
)
if from_dockerhub:
checkups.append(
get_rule(
Expand Down Expand Up @@ -195,14 +188,6 @@ def apply_rules(
)
)
elif description == "serve":
if from_github:
checkups.append(
get_rule(
"dockerhub_status",
dest_path=dest_path,
expected_status=False,
)
)
if from_dockerhub:
checkups.append(
get_rule(
Expand Down
2 changes: 1 addition & 1 deletion test/playground/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python_version: "3.10"
python_version: "3.10.10"
model_id: "eos3b5e"
model_ids: ["eos3b5e", "eos4e40", "eos7d58", "eos9gg2"]
input_file: "files/input.csv"
Expand Down
55 changes: 30 additions & 25 deletions test/playground/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
from ersilia.utils.logging import logger

ORIGINAL_DIR = Path.cwd()
ORIGINAL_DIR = Path.cwd()
config_path = Path("config.yml")
config = yaml.safe_load(config_path.read_text())
REPO_URL = "https://github.com/ersilia-os/ersilia.git"
Expand All @@ -14,65 +14,70 @@ def update_yaml_values(new_values: dict):
config = yaml.safe_load(config_path.read_text())
config.update(new_values)
config_path.write_text(yaml.dump(config))
logger.info(f"Updated config.yml with: {new_values}")

@nox.session(venv_backend="conda")
def get_python_version():
return config.get("python_version", "3.10.10")

@nox.session(venv_backend="conda", python=get_python_version())
def test_cli(session):
"""Test CLI with initial and updated configurations."""
session.install(
"pytest",
"pytest-asyncio",
"pytest-xdist",
"pytest",
"pytest-asyncio",
"pytest-xdist",
"psutil",
"PyYAML",
"rich"
"rich",
)

if config.get("use_existing_env", False):
logger.info("Using existing environment, skipping setup and installation.")

session.run("ersilia", "--help", external=True)
session.run(
"pytest",
"commands.py",
"-v",
"pytest",
"commands.py",
"-v",
silent=False,
external=True
external=True,
)
return

session.conda_install(f"python={config.get('python_version', '3.10')}")
session.conda_install(f"python={get_python_version()}")

if REPO_DIR.exists() and config.get("overwrite_ersilia_repo", False):
logger.info(f"Overwriting existing repository directory: {REPO_DIR}")
shutil.rmtree(REPO_DIR)

if not REPO_DIR.exists():
session.run(
"git",
"clone",
REPO_URL,
external=True
"git",
"clone",
REPO_URL,
external=True,
)
else:
logger.info(f"Using existing repository directory: {REPO_DIR}")

session.chdir(REPO_DIR)
session.install("-e", ".")
session.chdir(ORIGINAL_DIR)

session.run(
"ersilia",
"--help",
external=True
"ersilia",
"--help",
external=True,
)

# default run --from_github
logger.info(f'CLI test for model: {config.get("model_id")} and {config.get("fetch_flags")}')
session.run(
"pytest",
"commands.py",
"-v",
silent=False
"pytest",
"commands.py",
"-v",
silent=False,
)

# default run --from_dockerhub
update_yaml_values({
"fetch_flags": "--from_dockerhub"
Expand Down

0 comments on commit b189365

Please sign in to comment.