-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split cli.py into indvidual files for each subcommand
- Loading branch information
1 parent
d70797d
commit 0656797
Showing
8 changed files
with
329 additions
and
280 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from __future__ import annotations | ||
|
||
import cyclopts | ||
|
||
from bfabric.experimental.app_interface.cli.app import app_app | ||
from bfabric.experimental.app_interface.cli.chunk import app_chunk | ||
from bfabric.experimental.app_interface.cli.inputs import app_inputs | ||
from bfabric.experimental.app_interface.cli.outputs import app_outputs | ||
from bfabric.experimental.app_interface.cli.validate import app_validate | ||
|
||
app = cyclopts.App() | ||
app.command(app_inputs) | ||
app.command(app_outputs) | ||
app.command(app_app) | ||
app.command(app_chunk) | ||
app.command(app_validate) | ||
|
||
if __name__ == "__main__": | ||
app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
import cyclopts | ||
import yaml | ||
|
||
from bfabric import Bfabric | ||
from bfabric.cli_formatting import setup_script_logging | ||
from bfabric.experimental.app_interface.app_runner._spec import AppSpec | ||
from bfabric.experimental.app_interface.app_runner.runner import run_app, Runner | ||
|
||
app_app = cyclopts.App("app", help="Run an app.") | ||
|
||
|
||
@app_app.command() | ||
def run( | ||
app_spec: Path, | ||
target_folder: Path, | ||
workunit_ref: int | Path, | ||
*, | ||
ssh_user: str | None = None, | ||
read_only: bool = False, | ||
) -> None: | ||
"""Runs all stages of an app.""" | ||
# TODO doc | ||
setup_script_logging() | ||
client = Bfabric.from_config() | ||
app_spec_parsed = AppSpec.model_validate(yaml.safe_load(app_spec.read_text())) | ||
run_app( | ||
app_spec=app_spec_parsed, | ||
workunit_ref=workunit_ref, | ||
work_dir=target_folder, | ||
client=client, | ||
ssh_user=ssh_user, | ||
read_only=read_only, | ||
) | ||
|
||
|
||
@app_app.command() | ||
def dispatch( | ||
app_spec: Path, | ||
work_dir: Path, | ||
workunit_ref: int | Path, | ||
) -> None: | ||
"""Create chunks, which can be processed individually. | ||
:param app_spec: Path to the app spec file. | ||
:param work_dir: Path to the work directory. | ||
:param workunit_ref: Reference to the workunit (ID or YAML file path). | ||
""" | ||
setup_script_logging() | ||
# TODO set workunit to processing? (i.e. add read-only option here) | ||
client = Bfabric.from_config() | ||
runner = Runner(spec=AppSpec.model_validate(yaml.safe_load(app_spec.read_text())), client=client, ssh_user=None) | ||
runner.run_dispatch(workunit_ref=workunit_ref, work_dir=work_dir) |
Oops, something went wrong.