Skip to content

Commit

Permalink
Move the model inspection code (#1227)
Browse files Browse the repository at this point in the history
* added the inspect command,modelInspector class and registered the inspect command

* added inspect to the cli commands

* changed naming convention for function names and replaced print statements with debug logs

* formatted with black

* fixed computational performance tracking error uniting the subprocess

* changing function names

* restructuring the inspect code

---------

Co-authored-by: Dhanshree Arora <DhanshreeA@users.noreply.github.com>
  • Loading branch information
dzumii and DhanshreeA authored Aug 20, 2024
1 parent 2a0ba90 commit 2ec17c4
Show file tree
Hide file tree
Showing 4 changed files with 398 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ersilia/cli/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ def setup(self):
def test(self):
m = importlib.import_module("ersilia.cli.commands.test")
m.test_cmd()

def inspect(self):
m = importlib.import_module("ersilia.cli.commands.inspect")
m.inspect_cmd()
52 changes: 52 additions & 0 deletions ersilia/cli/commands/inspect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from ...publish.inspect import ModelInspector
import click
from . import ersilia_cli
import json
from ... import ErsiliaBase


class InspectCommand(ErsiliaBase):
def __init__(self, config_json=None, credentials_json=None):
super().__init__(config_json, credentials_json)

def inspect(self, model):
inspector = ModelInspector(model)

check_repo_exists_result = inspector.check_repo_exists()
check_complete_metadata_result = inspector.check_complete_metadata()
check_complete_folder_structure_result = (
inspector.check_complete_folder_structure()
)
check_dependencies_are_valid_result = inspector.check_dependencies_are_valid()
check_comptuational_performance_result = (
inspector.check_comptuational_performance()
)
check_no_extra_files_result = inspector.check_no_extra_files()

value = {
"is_github_url_available": check_repo_exists_result.success,
"is_github_url_available_details": check_repo_exists_result.details,
"complete_metadata": check_complete_metadata_result.success,
"complete_metadata_details": check_complete_metadata_result.details,
"complete_folder_structure": check_complete_folder_structure_result.success,
"complete_folder_structure_details": check_complete_folder_structure_result.details,
"docker_check": check_dependencies_are_valid_result.success,
"docker_check_details": check_dependencies_are_valid_result.details,
"computational_performance_tracking": check_comptuational_performance_result.success,
"computational_performance_tracking_details": check_comptuational_performance_result.details,
"extra_files_check": check_no_extra_files_result.success,
"extra_files_check_details": check_no_extra_files_result.details,
}

self.logger.debug(json.dumps(value, indent=2))
return json.dumps(value)


def inspect_cmd():
@ersilia_cli.command(
short_help="Inspect model", help="Inspect model structure and metadata"
)
@click.argument("model", type=click.STRING)
def inspect(model):
cmd = InspectCommand()
return cmd.inspect(model)
1 change: 1 addition & 0 deletions ersilia/cli/create_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def create_ersilia_cli():
cmd.fetch()
cmd.info()
cmd.test()
cmd.inspect()

# TODO: publishing functionalities
if is_contributor:
Expand Down
Loading

0 comments on commit 2ec17c4

Please sign in to comment.