Skip to content

Commit c533e2e

Browse files
authored
Fixed pipeline step to dict (#325)
2 parents 44e23d7 + 26096cd commit c533e2e

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

ads/pipeline/ads_pipeline_step.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,19 @@ def to_dict(self) -> dict:
519519
dict_details["spec"][self.CONST_JOB_ID] = self.job_id
520520
if self.description:
521521
dict_details["spec"][self.CONST_DESCRIPTION] = self.description
522+
if self.kind == "ML_JOB":
523+
if self.environment_variable:
524+
dict_details["spec"][self.CONST_ENVIRONMENT_VARIABLES] = (
525+
self.environment_variable
526+
)
527+
if self.argument:
528+
dict_details["spec"][self.CONST_COMMAND_LINE_ARGUMENTS] = (
529+
self.argument
530+
)
531+
if self.maximum_runtime_in_minutes:
532+
dict_details["spec"][self.CONST_MAXIMUM_RUNTIME_IN_MINUTES] = (
533+
self.maximum_runtime_in_minutes
534+
)
522535

523536
dict_details["spec"].pop(self.CONST_DEPENDS_ON, None)
524537

tests/unitary/default_setup/pipeline/test_pipeline.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@ def test_pipeline_define(self):
333333
"name": "TestPipelineStepOne",
334334
"jobId": "TestJobIdOne",
335335
"description": "Test description one",
336+
"commandLineArguments": "ARGUMENT --KEY VALUE",
337+
"environmentVariables": {
338+
"ENV": "VALUE"
339+
},
340+
"maximumRuntimeInMinutes": 20
336341
},
337342
},
338343
{
@@ -1060,6 +1065,11 @@ def test_pipeline_to_dict(self):
10601065
"name": "TestPipelineStepOne",
10611066
"jobId": "TestJobIdOne",
10621067
"description": "Test description one",
1068+
"commandLineArguments": "ARGUMENT --KEY VALUE",
1069+
"environmentVariables": {
1070+
"ENV": "VALUE"
1071+
},
1072+
"maximumRuntimeInMinutes": 20
10631073
},
10641074
},
10651075
{

tests/unitary/default_setup/pipeline/test_pipeline_step.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class DataSciencePipelineStepBaseTest(unittest.TestCase):
3838
PipelineStep("TestUpstreamPipelineStepOne")
3939
.with_description("Test upstream pipeline step description one")
4040
.with_job_id("TestJobIdOne")
41+
.with_environment_variable(**{"test_key": "test_value"})
42+
.with_maximum_runtime_in_minutes(20)
43+
.with_argument("--key val path/to/file")
4144
)
4245

4346
upstream_pipeline_step_two = (
@@ -85,6 +88,11 @@ def test_pipeline_step_to_dict(self):
8588
"name": "TestUpstreamPipelineStepOne",
8689
"jobId": "TestJobIdOne",
8790
"description": "Test upstream pipeline step description one",
91+
"environmentVariables": {
92+
"test_key": "test_value"
93+
},
94+
"commandLineArguments": "--key val path/to/file",
95+
"maximumRuntimeInMinutes": 20
8896
},
8997
}
9098

0 commit comments

Comments
 (0)