Skip to content

Commit 2b843f4

Browse files
Misc bugfixes (#3234)
* Set stack before importing pipeline * Improve logic when fetching neptune run * Fix error message * Auto-update of NLP template * Missing return * Auto-update of LLM Finetuning template * Auto-update of Starter template * Auto-update of E2E template --------- Co-authored-by: GitHub Actions <[email protected]>
1 parent 634d034 commit 2b843f4

File tree

8 files changed

+130
-143
lines changed

8 files changed

+130
-143
lines changed

examples/e2e/.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 2024.11.20-2-g760142f
2+
_commit: 2024.11.28
33
_src_path: gh:zenml-io/template-e2e-batch
44
data_quality_checks: true
55

examples/e2e_nlp/.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 2024.10.30-2-g1ae14e3
2+
_commit: 2024.11.28
33
_src_path: gh:zenml-io/template-nlp
44
accelerator: cpu
55
cloud_of_choice: aws

examples/llm_finetuning/.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 2024.11.08-2-gece1d46
2+
_commit: 2024.11.28
33
_src_path: gh:zenml-io/template-llm-finetuning
44
bf16: true
55
cuda_version: cuda11.8

examples/mlops_starter/.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 2024.10.30-7-gb60e441
2+
_commit: 2024.11.28
33
_src_path: gh:zenml-io/template-starter
44
55
full_name: ZenML GmbH

src/zenml/cli/pipeline.py

Lines changed: 48 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,35 @@
4040
logger = get_logger(__name__)
4141

4242

43+
def _import_pipeline(source: str) -> Pipeline:
44+
"""Import a pipeline.
45+
46+
Args:
47+
source: The pipeline source.
48+
49+
Returns:
50+
The pipeline.
51+
"""
52+
try:
53+
pipeline_instance = source_utils.load(source)
54+
except ModuleNotFoundError as e:
55+
source_root = source_utils.get_source_root()
56+
cli_utils.error(
57+
f"Unable to import module `{e.name}`. Make sure the source path is "
58+
f"relative to your source root `{source_root}`."
59+
)
60+
except AttributeError as e:
61+
cli_utils.error("Unable to load attribute from module: " + str(e))
62+
63+
if not isinstance(pipeline_instance, Pipeline):
64+
cli_utils.error(
65+
f"The given source path `{source}` does not resolve to a pipeline "
66+
"object."
67+
)
68+
69+
return pipeline_instance
70+
71+
4372
@cli.group(cls=TagGroup, tag=CliCategories.MANAGEMENT_TOOLS)
4473
def pipeline() -> None:
4574
"""Interact with pipelines, runs and schedules."""
@@ -85,22 +114,7 @@ def register_pipeline(
85114
"source code root."
86115
)
87116

88-
try:
89-
pipeline_instance = source_utils.load(source)
90-
except ModuleNotFoundError as e:
91-
source_root = source_utils.get_source_root()
92-
cli_utils.error(
93-
f"Unable to import module `{e.name}`. Make sure the source path is "
94-
f"relative to your source root `{source_root}`."
95-
)
96-
except AttributeError as e:
97-
cli_utils.error("Unable to load attribute from module: " + str(e))
98-
99-
if not isinstance(pipeline_instance, Pipeline):
100-
cli_utils.error(
101-
f"The given source path `{source}` does not resolve to a pipeline "
102-
"object."
103-
)
117+
pipeline_instance = _import_pipeline(source=source)
104118

105119
parameters: Dict[str, Any] = {}
106120
if parameters_path:
@@ -176,24 +190,9 @@ def build_pipeline(
176190
"your source code root."
177191
)
178192

179-
try:
180-
pipeline_instance = source_utils.load(source)
181-
except ModuleNotFoundError as e:
182-
source_root = source_utils.get_source_root()
183-
cli_utils.error(
184-
f"Unable to import module `{e.name}`. Make sure the source path is "
185-
f"relative to your source root `{source_root}`."
186-
)
187-
except AttributeError as e:
188-
cli_utils.error("Unable to load attribute from module: " + str(e))
189-
190-
if not isinstance(pipeline_instance, Pipeline):
191-
cli_utils.error(
192-
f"The given source path `{source}` does not resolve to a pipeline "
193-
"object."
194-
)
195-
196193
with cli_utils.temporary_active_stack(stack_name_or_id=stack_name_or_id):
194+
pipeline_instance = _import_pipeline(source=source)
195+
197196
pipeline_instance = pipeline_instance.with_options(
198197
config_path=config_path
199198
)
@@ -277,36 +276,21 @@ def run_pipeline(
277276
"your source code root."
278277
)
279278

280-
try:
281-
pipeline_instance = source_utils.load(source)
282-
except ModuleNotFoundError as e:
283-
source_root = source_utils.get_source_root()
284-
cli_utils.error(
285-
f"Unable to import module `{e.name}`. Make sure the source path is "
286-
f"relative to your source root `{source_root}`."
287-
)
288-
except AttributeError as e:
289-
cli_utils.error("Unable to load attribute from module: " + str(e))
290-
291-
if not isinstance(pipeline_instance, Pipeline):
292-
cli_utils.error(
293-
f"The given source path `{source}` does not resolve to a pipeline "
294-
"object."
295-
)
296-
297-
build: Union[str, PipelineBuildBase, None] = None
298-
if build_path_or_id:
299-
if uuid_utils.is_valid_uuid(build_path_or_id):
300-
build = build_path_or_id
301-
elif os.path.exists(build_path_or_id):
302-
build = PipelineBuildBase.from_yaml(build_path_or_id)
303-
else:
304-
cli_utils.error(
305-
f"The specified build {build_path_or_id} is not a valid UUID "
306-
"or file path."
307-
)
308-
309279
with cli_utils.temporary_active_stack(stack_name_or_id=stack_name_or_id):
280+
pipeline_instance = _import_pipeline(source=source)
281+
282+
build: Union[str, PipelineBuildBase, None] = None
283+
if build_path_or_id:
284+
if uuid_utils.is_valid_uuid(build_path_or_id):
285+
build = build_path_or_id
286+
elif os.path.exists(build_path_or_id):
287+
build = PipelineBuildBase.from_yaml(build_path_or_id)
288+
else:
289+
cli_utils.error(
290+
f"The specified build {build_path_or_id} is not a valid UUID "
291+
"or file path."
292+
)
293+
310294
pipeline_instance = pipeline_instance.with_options(
311295
config_path=config_path,
312296
build=build,
@@ -369,24 +353,9 @@ def create_run_template(
369353
"init` at your source code root."
370354
)
371355

372-
try:
373-
pipeline_instance = source_utils.load(source)
374-
except ModuleNotFoundError as e:
375-
source_root = source_utils.get_source_root()
376-
cli_utils.error(
377-
f"Unable to import module `{e.name}`. Make sure the source path is "
378-
f"relative to your source root `{source_root}`."
379-
)
380-
except AttributeError as e:
381-
cli_utils.error("Unable to load attribute from module: " + str(e))
382-
383-
if not isinstance(pipeline_instance, Pipeline):
384-
cli_utils.error(
385-
f"The given source path `{source}` does not resolve to a pipeline "
386-
"object."
387-
)
388-
389356
with cli_utils.temporary_active_stack(stack_name_or_id=stack_name_or_id):
357+
pipeline_instance = _import_pipeline(source=source)
358+
390359
pipeline_instance = pipeline_instance.with_options(
391360
config_path=config_path
392361
)

src/zenml/integrations/neptune/experiment_trackers/neptune_experiment_tracker.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ def prepare_step_run(self, info: "StepRunInfo") -> None:
7777
NeptuneExperimentTrackerSettings, self.get_settings(info)
7878
)
7979

80-
self.run_state.token = self.config.api_token
81-
self.run_state.project = self.config.project
82-
self.run_state.run_name = info.run_name
83-
self.run_state.tags = list(settings.tags)
80+
self.run_state.initialize(
81+
project=self.config.project,
82+
token=self.config.api_token,
83+
run_name=info.run_name,
84+
tags=list(settings.tags),
85+
)
8486

8587
def get_step_run_metadata(
8688
self, info: "StepRunInfo"
@@ -107,4 +109,4 @@ def cleanup_step_run(self, info: "StepRunInfo", step_failed: bool) -> None:
107109
"""
108110
self.run_state.active_run.sync()
109111
self.run_state.active_run.stop()
110-
self.run_state.reset_active_run()
112+
self.run_state.reset()

0 commit comments

Comments
 (0)