Skip to content

Commit

Permalink
Merge pull request #110 from odtp-org/release0.2.5
Browse files Browse the repository at this point in the history
Release0.2.5
  • Loading branch information
sabinem authored May 6, 2024
2 parents 2934cc7 + 0460c3a commit c792a8a
Show file tree
Hide file tree
Showing 21 changed files with 2,497 additions and 1,076 deletions.
3 changes: 3 additions & 0 deletions .env.dist.local
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ GITHUB_TOKEN=
# Dashboard parameters
ODTP_DASHBOARD_PORT=
ODTP_DASHBOARD_RELOAD=

# Working directory for user projects
ODTP_PATH=
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Changelog

- v0.2.5: Bugs corrections and new features
- Components tags parsing
- CLI compatibility with digital twins and executions names
- GUI user's working directory implementation
- GUI executions improvements

- v0.2.4: Feature
- Network added to compose so odtp components can use it
- Introducing `secrets` compatibility
Expand All @@ -16,7 +22,6 @@
- remove data mockup
- environment variables now loaded from the environment


- v.0.2.0: Improvements in database and files management.
- New MongoDB Schema supporting users, digital twins, executions, and steps.
- Setup uses pyproject.toml and set up method changed to poetry
Expand All @@ -26,7 +31,6 @@
- S3 uploading of outputs from each component.
- Switch UI from Streamlit to Nicegui


- v.0.1.0: Basic UI
- Streamlit APP with different
- User tagging
Expand Down
26 changes: 22 additions & 4 deletions odtp/cli/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@


@app.command()
def prepare(
def prepare(
execution_name: str = typer.Option(
None, "--execution-name", help="Specify the name of the execution"
),
execution_id: str = typer.Option(
..., "--execution-id", help="Specify the ID of the execution"
None, "--execution-id", help="Specify the ID of the execution"
),
project_path: str = typer.Option(
..., "--project-path", help="Specify the path for the execution"
),
):
try:
if execution_id is None and execution_name is None:
raise typer.Exit("Please provide either --execution-name or --execution-id")

if execution_name:
execution_id = db.get_document_id_by_field_value("title", execution_name, "executions")

execution = db.get_document_by_id(
document_id=execution_id,
collection=db.collection_executions
Expand All @@ -46,8 +55,11 @@ def prepare(

@app.command()
def run(
execution_name: str = typer.Option(
None, "--execution-name", help="Specify the name of the execution"
),
execution_id: str = typer.Option(
..., "--execution-id", help="Specify the ID of the execution"
None, "--execution-id", help="Specify the ID of the execution"
),
project_path: str = typer.Option(
..., "--project-path", help="Specify the path for the execution"
Expand All @@ -57,12 +69,18 @@ def run(
)] = None,
):
try:
if execution_id is None and execution_name is None:
raise typer.Exit("Please provide either --execution-name or --execution-id")

if execution_name:
execution_id = db.get_document_id_by_field_value("title", execution_name, "executions")

execution = db.get_document_by_id(
document_id=execution_id,
collection=db.collection_executions
)
step_count = len(execution["workflowSchema"]["workflowExecutorSchema"])
secrets = odtp_parse.parse_paramters_for_multiple_files(
secrets = odtp_parse.parse_parameters_for_multiple_files(
parameter_files=secrets_files, step_count=step_count)
flowManager = WorkflowManager(execution, project_path, secrets)
flowManager.run_workflow()
Expand Down
54 changes: 35 additions & 19 deletions odtp/cli/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import odtp.helpers.parse as odtp_parse
import odtp.mongodb.utils as db_utils
import odtp.helpers.utils as odtp_utils
import odtp.helpers.git as odtp_git


## Adding listing so we can have multiple flags
Expand Down Expand Up @@ -36,31 +37,23 @@ def odtp_component_entry(
help="Specify the repository"
)],
component_version: Annotated[str, typer.Option(
help="Specify the component version"
)],
odtp_version: Annotated[str, typer.Option(
help="Specify the version of odtp"
)] = None,
commit: Annotated[str, typer.Option(
help="""You may specify the commit of the repository. If not provided
the latest commit will be fetched"""
)] = None,
help="Specify the tagged component version. It needs to be available on the github repo"
)],
type: Annotated[str, typer.Option(
help="""You may specify the type of the component as either 'ephemeral or persistent'"""
)] = db_utils.COMPONENT_TYPE_EPHERMAL,
ports: Annotated[str, typer.Option(
help="Specify ports seperated by a comma i.e. 8501,8201"
)] = None,
):
):
try:
ports = odtp_parse.parse_component_ports(ports)
repo_info = odtp_git.get_github_repo_info(repository)
component_id, version_id = \
db.add_component_version(
component_name=name,
repository=repository,
odtp_version=odtp_version,
repo_info=repo_info,
component_version=component_version,
commit_hash=commit,
type=type,
ports=ports,
)
Expand All @@ -76,21 +69,32 @@ def odtp_component_entry(

@app.command()
def digital_twin_entry(
user_id: str = typer.Option(..., "--user-id", help="Specify the user ID"),
name: str = typer.Option(..., "--name", help="Specify the name"),
user_id: str = typer.Option(None, "--user-id", help="Specify the user ID"),
user_email: str = typer.Option(None, "--user-email", help="Specify the email"),
name: str = typer.Option(..., "--name", help="Specify the digital twin name"),
):
if user_id is None and user_email is None:
raise typer.Exit("Please provide either --user-id or --user-email")

if user_email:
user_id = db.get_document_id_by_field_value("user_email", user_email, "users")

dt_id = db.add_digital_twin(userRef=user_id, name=name)
print(f"Digital Twin added with ID {dt_id}")


@app.command()
def execution_entry(
execution_name: str = typer.Option(..., "--name", help="Specify the name of the execution"),
dt_name: str = typer.Option(None, "--digital-twin-name", help="Specify the digital twin name"),
dt_id: str = typer.Option(
..., "--digital-twin-id", help="Specify the digital twin ID"
None, "--digital-twin-id", help="Specify the digital twin ID"
),
component_tags: str = typer.Option(
None, "--component-tags", help="Specify the components-tags (component-name:version) separated by commas"
),
execution_name: str = typer.Option(..., "--name", help="Specify the name of the execution"),
component_versions: str = typer.Option(
..., "--component-versions", help="Specify the version_ids separated by commas"
None, "--component-versions", help="Specify the version_ids separated by commas"
),
parameter_files: Annotated[str, typer.Option(
help="List the files containing the parameters by step separated by commas"
Expand All @@ -101,11 +105,23 @@ def execution_entry(
)] = None,
):
try:
if dt_name is None and dt_id is None:
raise typer.Exit("Please provide either --digital-twin-name or --digital-twin-id")

if component_tags is None and component_versions is None:
raise typer.Exit("Please provide either --component-tags or --component-versions")

if dt_name:
dt_id = db.get_document_id_by_field_value("name", dt_name, "digitalTwins")

if component_tags:
component_versions = ",".join(odtp_parse.parse_component_tags(component_tags))

versions = odtp_parse.parse_versions(component_versions)
step_count = len(versions)
ports = odtp_parse.parse_port_mappings_for_multiple_components(
ports=ports, step_count=step_count)
parameters = odtp_parse.parse_paramters_for_multiple_files(
parameters = odtp_parse.parse_parameters_for_multiple_files(
parameter_files=parameter_files, step_count=step_count)
execution_id, step_ids = db.add_execution(
dt_id=dt_id,
Expand Down
2 changes: 1 addition & 1 deletion odtp/dashboard/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ def components():
title="ODTP",
storage_secret="private key to secure the browser session cookie",
port=ODTP_DASHBOARD_PORT,
reload=ODTP_DASHBOARD_RELOAD
reload=ODTP_DASHBOARD_RELOAD,
)
Loading

0 comments on commit c792a8a

Please sign in to comment.