Skip to content

Commit

Permalink
Allow roundtrip of Layout to_spec and from_spec (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Oct 31, 2023
1 parent 592e75b commit 6d59bcf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lumen/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def from_spec(
view_spec['name'] = name
if 'pipeline' in view_spec:
pname = view_spec.pop('pipeline')
if pname in pipelines:
if isinstance(pname, str) and pname in pipelines:
pipeline = pipelines.get(pname)
else:
pipeline = Pipeline.from_spec(pname)
Expand Down Expand Up @@ -891,8 +891,12 @@ def from_spec(cls, spec: Dict[str, Any] | str, **kwargs) -> 'Layout':
view_spec = dict(view_spec)
processed_views.append(view_spec)
if 'pipeline' in view_spec:
pname = view_spec['pipeline']
pipelines[pname] = Pipeline.from_spec(pname)
pipeline = view_spec['pipeline']
if isinstance(pipeline, str):
pipelines[pipeline] = Pipeline.from_spec(pipeline)
else:
pname = pipeline.get('name', f'Pipeline{id(view_spec)}')
pipelines[pname] = pipeline
continue
elif 'pipeline' in spec:
continue
Expand Down

0 comments on commit 6d59bcf

Please sign in to comment.