openjd-cli 0.6.0__tar.gz → 0.7.0__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.
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/PKG-INFO +1 -1
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_common/__init__.py +9 -2
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_common/_job_from_template.py +18 -8
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_run/_local_session/_session_manager.py +7 -12
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_run/_run_command.py +7 -1
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_summary/_summary_command.py +1 -1
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_version.py +2 -2
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/pyproject.toml +1 -1
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/.gitignore +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/LICENSE +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/NOTICE +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/README.md +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/hatch.toml +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/__main__.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/__init__.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_check/__init__.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_check/_check_command.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_common/_extensions.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_common/_validation_utils.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_create_argparser.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_run/__init__.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_run/_local_session/__init__.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_run/_local_session/_actions.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_run/_local_session/_logs.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_schema/__init__.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_schema/_schema_command.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_summary/__init__.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/_summary/_summary_output.py +0 -0
- {openjd_cli-0.6.0 → openjd_cli-0.7.0}/openjd/cli/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openjd-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Provides a command-line interface for working with Open Job Description templates.
|
|
5
5
|
Project-URL: Homepage, https://github.com/OpenJobDescription/openjd-cli
|
|
6
6
|
Project-URL: Source, https://github.com/OpenJobDescription/openjd-cli
|
|
@@ -21,7 +21,7 @@ from ._validation_utils import (
|
|
|
21
21
|
read_job_template,
|
|
22
22
|
read_environment_template,
|
|
23
23
|
)
|
|
24
|
-
from openjd.model import DecodeValidationError, Job
|
|
24
|
+
from openjd.model import DecodeValidationError, Job, JobParameterValues, EnvironmentTemplate
|
|
25
25
|
|
|
26
26
|
__all__ = [
|
|
27
27
|
"add_extensions_argument",
|
|
@@ -112,13 +112,20 @@ class SubparserGroup:
|
|
|
112
112
|
return self.group.add_parser(name, **kwargs)
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
def generate_job(
|
|
115
|
+
def generate_job(
|
|
116
|
+
args: Namespace,
|
|
117
|
+
environments: list[EnvironmentTemplate] = [],
|
|
118
|
+
*,
|
|
119
|
+
supported_extensions: list[str],
|
|
120
|
+
) -> tuple[Job, JobParameterValues]:
|
|
116
121
|
try:
|
|
117
122
|
# Raises: RuntimeError, DecodeValidationError
|
|
118
123
|
template = read_job_template(args.path, supported_extensions=supported_extensions)
|
|
124
|
+
|
|
119
125
|
# Raises: RuntimeError
|
|
120
126
|
return job_from_template(
|
|
121
127
|
template,
|
|
128
|
+
environments,
|
|
122
129
|
args.job_params if args.job_params else None,
|
|
123
130
|
Path(os.path.abspath(args.path.parent)),
|
|
124
131
|
Path(os.getcwd()),
|
|
@@ -4,14 +4,16 @@ from __future__ import annotations
|
|
|
4
4
|
import json
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
import re
|
|
7
|
-
from typing import Union
|
|
7
|
+
from typing import Optional, Union
|
|
8
8
|
import yaml
|
|
9
9
|
|
|
10
10
|
from ._validation_utils import get_doc_type
|
|
11
11
|
from openjd.model import (
|
|
12
12
|
DecodeValidationError,
|
|
13
13
|
DocumentType,
|
|
14
|
+
EnvironmentTemplate,
|
|
14
15
|
Job,
|
|
16
|
+
JobParameterValues,
|
|
15
17
|
JobTemplate,
|
|
16
18
|
create_job,
|
|
17
19
|
preprocess_job_parameters,
|
|
@@ -54,7 +56,7 @@ def get_params_from_file(parameter_string: str) -> Union[dict, list]:
|
|
|
54
56
|
return parameters
|
|
55
57
|
|
|
56
58
|
|
|
57
|
-
def get_job_params(parameter_args: list[str]) -> dict:
|
|
59
|
+
def get_job_params(parameter_args: Optional[list[str]]) -> dict:
|
|
58
60
|
"""
|
|
59
61
|
Resolves Job Parameters from a list of command-line arguments.
|
|
60
62
|
Arguments may be a filepath or a string with format 'Key=Value'.
|
|
@@ -62,7 +64,8 @@ def get_job_params(parameter_args: list[str]) -> dict:
|
|
|
62
64
|
Raises: RuntimeError if the provided Parameters are formatted incorrectly or can't be opened
|
|
63
65
|
"""
|
|
64
66
|
parameter_dict: dict = {}
|
|
65
|
-
|
|
67
|
+
|
|
68
|
+
for arg in parameter_args or []:
|
|
66
69
|
arg = arg.strip()
|
|
67
70
|
# Case 1: Provided argument is a filepath
|
|
68
71
|
if arg.startswith("file://"):
|
|
@@ -104,17 +107,18 @@ def get_job_params(parameter_args: list[str]) -> dict:
|
|
|
104
107
|
|
|
105
108
|
def job_from_template(
|
|
106
109
|
template: JobTemplate,
|
|
110
|
+
environments: list[EnvironmentTemplate],
|
|
107
111
|
parameter_args: list[str] | None,
|
|
108
112
|
job_template_dir: Path,
|
|
109
113
|
current_working_dir: Path,
|
|
110
|
-
) -> Job:
|
|
114
|
+
) -> tuple[Job, JobParameterValues]:
|
|
111
115
|
"""
|
|
112
|
-
Given a decoded Job Template and a user-
|
|
113
|
-
generates a Job object.
|
|
116
|
+
Given a decoded Job Template and a user-input parameter dictionary,
|
|
117
|
+
generates a Job object and the parameter values for running the job.
|
|
114
118
|
|
|
115
119
|
Raises: RuntimeError if parameters are an unsupported type or don't correspond to the template
|
|
116
120
|
"""
|
|
117
|
-
parameter_dict = get_job_params(parameter_args)
|
|
121
|
+
parameter_dict = get_job_params(parameter_args)
|
|
118
122
|
|
|
119
123
|
try:
|
|
120
124
|
parameter_values = preprocess_job_parameters(
|
|
@@ -122,11 +126,17 @@ def job_from_template(
|
|
|
122
126
|
job_parameter_values=parameter_dict,
|
|
123
127
|
job_template_dir=job_template_dir,
|
|
124
128
|
current_working_dir=current_working_dir,
|
|
129
|
+
environment_templates=environments,
|
|
125
130
|
)
|
|
126
131
|
except ValueError as ve:
|
|
127
132
|
raise RuntimeError(str(ve))
|
|
128
133
|
|
|
129
134
|
try:
|
|
130
|
-
|
|
135
|
+
job = create_job(
|
|
136
|
+
job_template=template,
|
|
137
|
+
job_parameter_values=parameter_values,
|
|
138
|
+
environment_templates=environments,
|
|
139
|
+
)
|
|
140
|
+
return (job, parameter_values)
|
|
131
141
|
except DecodeValidationError as dve:
|
|
132
142
|
raise RuntimeError(f"Could not generate Job from template and parameters: {str(dve)}")
|
|
@@ -21,8 +21,6 @@ from openjd.model import (
|
|
|
21
21
|
IntRangeExpr,
|
|
22
22
|
Job,
|
|
23
23
|
JobParameterValues,
|
|
24
|
-
ParameterValue,
|
|
25
|
-
ParameterValueType,
|
|
26
24
|
Step,
|
|
27
25
|
StepParameterSpaceIterator,
|
|
28
26
|
TaskParameterSet,
|
|
@@ -78,6 +76,7 @@ class LocalSession:
|
|
|
78
76
|
self,
|
|
79
77
|
*,
|
|
80
78
|
job: Job,
|
|
79
|
+
job_parameter_values: JobParameterValues,
|
|
81
80
|
session_id: str,
|
|
82
81
|
timestamp_format: LoggingTimestampFormat = LoggingTimestampFormat.RELATIVE,
|
|
83
82
|
path_mapping_rules: Optional[list[PathMappingRule]] = None,
|
|
@@ -93,18 +92,9 @@ class LocalSession:
|
|
|
93
92
|
self._environments = environments
|
|
94
93
|
|
|
95
94
|
# Create an OpenJD Session
|
|
96
|
-
job_parameters: JobParameterValues
|
|
97
|
-
if job.parameters:
|
|
98
|
-
job_parameters = {
|
|
99
|
-
name: ParameterValue(type=ParameterValueType(param.type.value), value=param.value)
|
|
100
|
-
for name, param in job.parameters.items()
|
|
101
|
-
}
|
|
102
|
-
else:
|
|
103
|
-
job_parameters = dict[str, ParameterValue]()
|
|
104
|
-
|
|
105
95
|
self._openjd_session = Session(
|
|
106
96
|
session_id=self.session_id,
|
|
107
|
-
job_parameter_values=
|
|
97
|
+
job_parameter_values=job_parameter_values,
|
|
108
98
|
path_mapping_rules=self._path_mapping_rules,
|
|
109
99
|
callback=self._action_callback,
|
|
110
100
|
retain_working_dir=retain_working_dir,
|
|
@@ -131,6 +121,11 @@ class LocalSession:
|
|
|
131
121
|
signal(SIGTERM, SIG_DFL)
|
|
132
122
|
self._started = False
|
|
133
123
|
|
|
124
|
+
# A blank line to separate the job log output from this status message
|
|
125
|
+
LOG.info(
|
|
126
|
+
msg="",
|
|
127
|
+
extra={"session_id": self.session_id},
|
|
128
|
+
)
|
|
134
129
|
if self.failed:
|
|
135
130
|
LOG.info(
|
|
136
131
|
msg=f"Open Job Description CLI: ERROR executing action: '{self.failed_action}' (see Task logs for details)",
|
|
@@ -28,6 +28,7 @@ from openjd.model import (
|
|
|
28
28
|
DecodeValidationError,
|
|
29
29
|
EnvironmentTemplate,
|
|
30
30
|
Job,
|
|
31
|
+
JobParameterValues,
|
|
31
32
|
Step,
|
|
32
33
|
StepDependencyGraph,
|
|
33
34
|
StepParameterSpaceIterator,
|
|
@@ -317,6 +318,7 @@ def _validate_task_params(step: Step, task_params: list[dict[str, str]]) -> None
|
|
|
317
318
|
def _run_local_session(
|
|
318
319
|
*,
|
|
319
320
|
job: Job,
|
|
321
|
+
job_parameter_values: JobParameterValues,
|
|
320
322
|
step_list: list[Step],
|
|
321
323
|
selected_step: Optional[Step],
|
|
322
324
|
timestamp_format: LoggingTimestampFormat,
|
|
@@ -337,6 +339,7 @@ def _run_local_session(
|
|
|
337
339
|
step_name = ""
|
|
338
340
|
with LocalSession(
|
|
339
341
|
job=job,
|
|
342
|
+
job_parameter_values=job_parameter_values,
|
|
340
343
|
timestamp_format=timestamp_format,
|
|
341
344
|
session_id="CLI-session",
|
|
342
345
|
path_mapping_rules=path_mapping_rules,
|
|
@@ -442,7 +445,9 @@ def do_run(args: Namespace) -> OpenJDCliResult:
|
|
|
442
445
|
|
|
443
446
|
try:
|
|
444
447
|
# Raises: RuntimeError
|
|
445
|
-
the_job = generate_job(
|
|
448
|
+
the_job, job_parameter_values = generate_job(
|
|
449
|
+
args, environments, supported_extensions=extensions
|
|
450
|
+
)
|
|
446
451
|
|
|
447
452
|
# Map Step names to Step objects so they can be easily accessed
|
|
448
453
|
step_map = {step.name: step for step in the_job.steps}
|
|
@@ -509,6 +514,7 @@ def do_run(args: Namespace) -> OpenJDCliResult:
|
|
|
509
514
|
|
|
510
515
|
return _run_local_session(
|
|
511
516
|
job=the_job,
|
|
517
|
+
job_parameter_values=job_parameter_values,
|
|
512
518
|
step_list=step_list,
|
|
513
519
|
selected_step=selected_step,
|
|
514
520
|
task_parameter_values=task_parameter_values,
|
|
@@ -35,7 +35,7 @@ def do_summary(args: Namespace) -> OpenJDCliResult:
|
|
|
35
35
|
|
|
36
36
|
try:
|
|
37
37
|
# Raises: RuntimeError
|
|
38
|
-
sample_job = generate_job(args, supported_extensions=extensions)
|
|
38
|
+
sample_job, _ = generate_job(args, supported_extensions=extensions)
|
|
39
39
|
except RuntimeError as rte:
|
|
40
40
|
return OpenJDCliResult(status="error", message=str(rte))
|
|
41
41
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|