Hi ! I was surprised to discover that the `pipelin...
# questions
m
Hi ! I was surprised to discover that the
pipeline
object does not have a
.name
attribute (as opposed to
node
) It would have come in handy to "restrict" certain hooks to certain pipelines. The only hack I can come up with is to identify pipelines by the name of their nodes ? Is there another / better way ? Thx M.
n
Hey Marc, you can use the before_pipeline_run hook
You are correct pipeline does not come with name because it is a collection of nodes, summing pipelines will result in ambigirous names.
d
Yeah it might not be clear the difference between a ‘registered pipeline name’ i.e. an entrypoint and an instance of a pipeline object, as Nok says you need the lifecycle of a run (exposed via a hook) to contextualise a running pipeline’s name
m
Thanks @Nok Lam Chan & @datajoely i've tried to hack my way around by monkey patching the pipeline objects in the pipeline dict defined in
pipeline_registry.py
with :
Copy code
for name, object_ in pipelines.items():
       setattr(object_, 'name', name)
What surprises me is that this works within the context of / will running the
pipeline_registry.py
but when I tried to access to the monkey-patched pipeline name in
hooks.py
in end up with an
AttributeError: 'Pipeline' object has no attribute 'name'
What am I missing / getting wrong regarding the lifecycle ?
n
Was on holiday. Patching attribute is not robust because filtering pipeline effectively create new pipeline object.