Skip to content

Commit 96692f6

Browse files
committed
build child link for experiment in workflow record according to modes
1 parent d4419c3 commit 96692f6

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

deep_code/tools/publish.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ def generate_workflow_experiment_records(
386386
jupyter_notebook_url=jupyter_notebook_url,
387387
themes=osc_themes,
388388
)
389+
if mode == "all":
390+
link_builder.build_child_link_to_related_experiment()
389391
# Convert to dictionary and cleanup
390392
workflow_dict = workflow_record.to_dict()
391393
if "jupyter_notebook_url" in workflow_dict:
@@ -400,6 +402,13 @@ def generate_workflow_experiment_records(
400402
exp_record_properties.type = "experiment"
401403
exp_record_properties.osc_workflow = workflow_id
402404

405+
# Update base catalogs of workflows with links
406+
file_dict["workflows/catalog.json"] = self._update_base_catalog(
407+
catalog_path="workflows/catalog.json",
408+
item_id=workflow_id,
409+
self_href=WORKFLOW_BASE_CATALOG_SELF_HREF,
410+
)
411+
403412
if mode in ["all"]:
404413
if not getattr(self, "collection_id", None):
405414
raise ValueError(
@@ -430,18 +439,13 @@ def generate_workflow_experiment_records(
430439
exp_file_path = f"experiments/{workflow_id}/record.json"
431440
file_dict[exp_file_path] = experiment_dict
432441

433-
# Update base catalogs of experiments and workflows with links
442+
# Update base catalogs of experiments with links
434443
file_dict["experiments/catalog.json"] = self._update_base_catalog(
435444
catalog_path="experiments/catalog.json",
436445
item_id=workflow_id,
437446
self_href=EXPERIMENT_BASE_CATALOG_SELF_HREF,
438447
)
439448

440-
file_dict["workflows/catalog.json"] = self._update_base_catalog(
441-
catalog_path="workflows/catalog.json",
442-
item_id=workflow_id,
443-
self_href=WORKFLOW_BASE_CATALOG_SELF_HREF,
444-
)
445449
# Write to files if testing
446450
if write_to_file:
447451
for file_path, data in file_dict.items():

deep_code/utils/ogc_api_record.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def build_theme_links_for_records(self):
128128
return self.theme_links
129129

130130
@staticmethod
131-
def build_link_to_dataset(collection_id):
131+
def build_link_to_dataset(collection_id) -> list[dict[str, str]]:
132132
return [
133133
{
134134
"rel": "child",
@@ -138,6 +138,17 @@ def build_link_to_dataset(collection_id):
138138
}
139139
]
140140

141+
def build_child_link_to_related_experiment(self) -> list[dict[str, str]]:
142+
"""Build a link to the related experiment record if publishing mode is 'all'."""
143+
return [
144+
{
145+
"rel": "child",
146+
"href": f"../../experiments/{self.id}/record.json",
147+
"type": "application/json",
148+
"title": self.title,
149+
}
150+
]
151+
141152
def build_link_to_jnb(self, workflow_title, jupyter_nb_url) -> List[Dict[str, Any]]:
142153
return [
143154
{
@@ -278,12 +289,6 @@ def _generate_static_links(self):
278289
"type": "application/json",
279290
"title": "Workflows",
280291
},
281-
{
282-
"rel": "child",
283-
"href": f"../../experiments/{self.id}/record.json",
284-
"type": "application/json",
285-
"title": f"{self.title}",
286-
},
287292
{
288293
"rel": "jupyter-notebook",
289294
"type": "application/json",

0 commit comments

Comments
 (0)