Skip to content

Commit 70cd5fb

Browse files
committed
feat: add commands to CLI run, profile
1 parent 36d1797 commit 70cd5fb

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

src/millrun/cli.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,27 @@
2727

2828
@app.command(
2929
name="run",
30+
no_args_is_help=True,
3031
help="Executes a notebook or directory of notebooks using the provided bulk parameters JSON file",
3132
context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
3233
)
3334
def run(
35+
ctx: typer.Context,
3436
notebook_dir_or_file: Annotated[
35-
Optional[str],
37+
str,
3638
typer.Argument(
3739
help="Path to a notebook file or a directory containing notebooks.",
3840
),
39-
] = None,
41+
],
4042
notebook_params: Annotated[
41-
Optional[str],
43+
str,
4244
typer.Argument(
4345
help=(
4446
"JSON file that contains parameters for notebook execution. "
4547
"Can either be a 'list of dict' or 'dict of list'."
4648
),
4749
),
48-
] = None,
49-
profile: Annotated[
50-
Optional[str],
51-
typer.Argument(
52-
help=(
53-
"A millrun YAML profile file that specifies the notebook_dir_or_file and notebook_params (along with additional options) instead of providing them directly."
54-
),
55-
),
56-
] = None,
50+
],
5751
output_dir: Annotated[
5852
Optional[str],
5953
typer.Option(
@@ -89,18 +83,14 @@ def run(
8983
exclude_glob_pattern: Optional[str] = None,
9084
include_glob_pattern: Optional[str] = None,
9185
):
92-
if output_dir is not None:
93-
output_dir = pathlib.Path(output_dir)
94-
else:
95-
output_dir = pathlib.Path.cwd()
86+
if ctx.invoked_subcommand is None:
87+
if output_dir is not None:
88+
output_dir = pathlib.Path(output_dir)
89+
else:
90+
output_dir = pathlib.Path.cwd()
9691

97-
# Automated profile execution
98-
if profile is not None:
99-
profile_file = pathlib.Path.cwd() / pathlib.Path(profile)
100-
execute_profile(profile_file)
92+
# Typical execution
10193

102-
# Typical execution
103-
elif None not in [notebook_dir_or_file, notebook_params]:
10494
execute_run(
10595
notebook_dir_or_file,
10696
notebook_params,
@@ -112,8 +102,17 @@ def run(
112102
include_glob_pattern,
113103
use_multiprocessing=True,
114104
# **kwargs
115-
)
105+
)
106+
116107

108+
@app.command(
109+
name="profile",
110+
help="Run a bulk millrun execution running against a profile YAML file",
111+
context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
112+
)
113+
def profile_execution(profile_filepath: str):
114+
profile_file = pathlib.Path.cwd() / pathlib.Path(profile_filepath)
115+
execute_profile(profile_file)
117116

118117
if __name__ == "__main__":
119118
app()

src/millrun/millrun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ def execute_run(
114114
if "working_directory" in kwargs:
115115
notebook_dir_or_file = pathlib.Path(kwargs['working_directory']) / notebook_dir_or_file
116116
output_dir = pathlib.Path(kwargs['working_directory']) / output_dir
117+
117118
if isinstance(notebook_params, (list, dict)):
118119
notebook_params_list = validate_notebook_params(notebook_params)
119120
elif isinstance(notebook_params, (str, pathlib.Path)):
120121
if "working_directory" in kwargs:
121-
print("HERE")
122122
notebook_params = pathlib.Path(kwargs['working_directory']) / notebook_params
123123
params_data = _parse_json(notebook_params)
124124
notebook_params_list = validate_notebook_params(params_data)

0 commit comments

Comments
 (0)