accli 1.0.0__tar.gz → 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {accli-1.0.0 → accli-1.0.1}/PKG-INFO +1 -1
- {accli-1.0.0 → accli-1.0.1}/accli/_version.py +1 -1
- {accli-1.0.0 → accli-1.0.1}/accli/cli.py +33 -19
- {accli-1.0.0 → accli-1.0.1}/accli.egg-info/PKG-INFO +1 -1
- {accli-1.0.0 → accli-1.0.1}/LICENSE +0 -0
- {accli-1.0.0 → accli-1.0.1}/README.md +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli/AcceleratorJobProjectService.py +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli/AcceleratorTaskDispatcher.py +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli/AcceleratorTerminalCliProjectService.py +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli/CsvRegionalTimeseriesValidator.py +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli/__init__.py +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli/__main__.py +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli/common.py +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli/token.py +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli.egg-info/SOURCES.txt +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli.egg-info/dependency_links.txt +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli.egg-info/entry_points.txt +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli.egg-info/requires.txt +0 -0
- {accli-1.0.0 → accli-1.0.1}/accli.egg-info/top_level.txt +0 -0
- {accli-1.0.0 → accli-1.0.1}/pyproject.toml +0 -0
- {accli-1.0.0 → accli-1.0.1}/setup.cfg +0 -0
|
@@ -9,6 +9,7 @@ import warnings
|
|
|
9
9
|
import importlib.util
|
|
10
10
|
from rich import print
|
|
11
11
|
from typing_extensions import Annotated
|
|
12
|
+
from contextlib import contextmanager
|
|
12
13
|
|
|
13
14
|
from accli.token import save_token_details, get_token, get_server_url, set_github_app_token, set_project_slug
|
|
14
15
|
|
|
@@ -40,6 +41,17 @@ def get_size(path):
|
|
|
40
41
|
return size
|
|
41
42
|
|
|
42
43
|
|
|
44
|
+
@contextmanager
|
|
45
|
+
def pushd(new_dir):
|
|
46
|
+
"""Temporarily change the working directory."""
|
|
47
|
+
prev_dir = os.getcwd()
|
|
48
|
+
os.chdir(new_dir)
|
|
49
|
+
try:
|
|
50
|
+
yield
|
|
51
|
+
finally:
|
|
52
|
+
os.chdir(prev_dir)
|
|
53
|
+
|
|
54
|
+
|
|
43
55
|
@app.command()
|
|
44
56
|
def about():
|
|
45
57
|
print("[bold cyan]This is a terminal client for Accelerator hosted on https://accelerator.iiasa.ac.at . [/bold cyan]\n")
|
|
@@ -181,7 +193,6 @@ def validate(
|
|
|
181
193
|
def dispatch(
|
|
182
194
|
project_slug: Annotated[str, typer.Argument(help="Unique Accelerator project slug.")],
|
|
183
195
|
root_task_variable: Annotated[str, typer.Argument(help="Root task variable in workflow_file.")],
|
|
184
|
-
server: Annotated[str, typer.Option(..., '-s', help="Accelerator server url.")] = "https://accelerator.iiasa.ac.at",
|
|
185
196
|
workflow_filename: Annotated[str, typer.Option(..., '-f', help="Python workflow filepath.")] = "wkube.py"
|
|
186
197
|
):
|
|
187
198
|
set_project_slug(project_slug)
|
|
@@ -194,32 +205,35 @@ def dispatch(
|
|
|
194
205
|
verify_cert=(not ACCLI_DEBUG)
|
|
195
206
|
)
|
|
196
207
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
workflow_filepath = f"{base_dir}{workflow_filename}"
|
|
208
|
+
# ✅ Resolve the workflow file path properly
|
|
209
|
+
if os.path.isabs(workflow_filename):
|
|
210
|
+
workflow_filepath = workflow_filename
|
|
201
211
|
else:
|
|
202
|
-
workflow_filepath =
|
|
212
|
+
workflow_filepath = os.path.abspath(os.path.join(os.getcwd(), workflow_filename))
|
|
203
213
|
|
|
204
|
-
|
|
214
|
+
if not os.path.isfile(workflow_filepath):
|
|
215
|
+
raise FileNotFoundError(f"Workflow file not found: {workflow_filepath}")
|
|
205
216
|
|
|
206
|
-
|
|
217
|
+
workflow_dir = os.path.dirname(workflow_filepath)
|
|
207
218
|
|
|
208
|
-
|
|
219
|
+
# ✅ Temporarily switch to the workflow file's directory
|
|
220
|
+
with pushd(workflow_dir):
|
|
221
|
+
# ✅ Import the module dynamically
|
|
222
|
+
spec = importlib.util.spec_from_file_location("workflow", workflow_filepath)
|
|
223
|
+
module = importlib.util.module_from_spec(spec)
|
|
224
|
+
spec.loader.exec_module(module)
|
|
209
225
|
|
|
210
|
-
|
|
226
|
+
job_to_dispatch = getattr(module, root_task_variable, None)
|
|
211
227
|
|
|
228
|
+
if not job_to_dispatch:
|
|
229
|
+
raise ValueError(f"No root task variable found with name '{root_task_variable}' in {workflow_filepath}")
|
|
212
230
|
|
|
213
|
-
|
|
214
|
-
raise ValueError(f"No root task variable found with name {root_task_variable}")
|
|
215
|
-
|
|
216
|
-
print(job_to_dispatch.description)
|
|
217
|
-
|
|
231
|
+
print(job_to_dispatch.description)
|
|
218
232
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
233
|
+
root_job_id = term_cli_project_service.dispatch(
|
|
234
|
+
project_slug,
|
|
235
|
+
job_to_dispatch.description
|
|
236
|
+
)
|
|
223
237
|
|
|
224
238
|
print(f"Dispatched root job #ID: {root_job_id}")
|
|
225
239
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|