deep-code 0.1.5__tar.gz → 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {deep_code-0.1.5 → deep_code-0.1.6}/PKG-INFO +19 -2
- {deep_code-0.1.5 → deep_code-0.1.6}/README.md +18 -1
- deep_code-0.1.6/deep_code/cli/publish.py +264 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/tools/test_publish.py +63 -0
- deep_code-0.1.6/deep_code/tests/utils/test_github_automation.py +362 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/utils/test_ogc_api_record.py +4 -4
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tools/publish.py +217 -96
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/utils/dataset_stac_generator.py +9 -8
- deep_code-0.1.6/deep_code/utils/github_automation.py +272 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/utils/ogc_api_record.py +33 -15
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/version.py +1 -1
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code.egg-info/PKG-INFO +19 -2
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code.egg-info/top_level.txt +1 -0
- deep_code-0.1.5/deep_code/cli/publish.py +0 -31
- deep_code-0.1.5/deep_code/tests/utils/test_github_automation.py +0 -171
- deep_code-0.1.5/deep_code/utils/github_automation.py +0 -145
- {deep_code-0.1.5 → deep_code-0.1.6}/LICENSE +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/__init__.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/cli/__init__.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/cli/generate_config.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/cli/main.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/constants.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/tools/__init__.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/utils/__init__.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/utils/test_custom_xrlint_rules.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/utils/test_dataset_stac_generator.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/utils/test_helper.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/utils/test_ogc_record_generator.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tests/utils/test_osc_extension.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tools/__init__.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tools/lint.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tools/new.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tools/register.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tools/setup_ci.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/tools/test.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/utils/__init__.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/utils/custom_xrlint_rules.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/utils/helper.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/utils/ogc_record_generator.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code/utils/osc_extension.py +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code.egg-info/SOURCES.txt +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code.egg-info/dependency_links.txt +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code.egg-info/entry_points.txt +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/deep_code.egg-info/requires.txt +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/pyproject.toml +0 -0
- {deep_code-0.1.5 → deep_code-0.1.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deep_code
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: deepesdl earthcode integration utility tool
|
|
5
5
|
Author-email: Tejas Morbagal Harish <tejas.morbagalharish@brockmann-consult.de>
|
|
6
6
|
License: MIT
|
|
@@ -126,7 +126,8 @@ catalog
|
|
|
126
126
|
|
|
127
127
|
### Usage
|
|
128
128
|
```
|
|
129
|
-
deep-code publish DATASET_CONFIG WORKFLOW_CONFIG [--environment ENVIRONMENT]
|
|
129
|
+
deep-code publish DATASET_CONFIG WORKFLOW_CONFIG [--environment ENVIRONMENT] [--mode
|
|
130
|
+
all|dataset|workflow]
|
|
130
131
|
```
|
|
131
132
|
|
|
132
133
|
#### Arguments
|
|
@@ -137,8 +138,12 @@ deep-code publish DATASET_CONFIG WORKFLOW_CONFIG [--environment ENVIRONMENT]
|
|
|
137
138
|
(e.g., workflow-config.yaml)
|
|
138
139
|
|
|
139
140
|
#### Options
|
|
141
|
+
--dataset-config, - Explict path to dataset config
|
|
142
|
+
--workflow-config, - Explicit path to workflow config
|
|
140
143
|
--environment, -e - Target catalog environment:
|
|
141
144
|
production (default) | staging | testing
|
|
145
|
+
--mode, -m Publishing mode:
|
|
146
|
+
all (default) | dataset | workflow
|
|
142
147
|
|
|
143
148
|
#### Examples:
|
|
144
149
|
1. Publish to staging catalog
|
|
@@ -153,6 +158,18 @@ deep-code publish dataset-config.yaml workflow-config.yaml -e testing
|
|
|
153
158
|
```
|
|
154
159
|
deep-code publish dataset-config.yaml workflow-config.yaml
|
|
155
160
|
```
|
|
161
|
+
4. Publish Dataset only
|
|
162
|
+
```
|
|
163
|
+
deep-code publish dataset-config.yaml -m dataset
|
|
164
|
+
|
|
165
|
+
deep-code publish --dataset-config dataset.yaml -m dataset
|
|
166
|
+
```
|
|
167
|
+
5. Publish Workflow only
|
|
168
|
+
```
|
|
169
|
+
deep-code publish dataset-config.yaml -m workflow
|
|
170
|
+
|
|
171
|
+
deep-code publish --workflow-config workflow.yaml -m dataset
|
|
172
|
+
```
|
|
156
173
|
#### dataset-config.yaml example
|
|
157
174
|
|
|
158
175
|
```
|
|
@@ -93,7 +93,8 @@ catalog
|
|
|
93
93
|
|
|
94
94
|
### Usage
|
|
95
95
|
```
|
|
96
|
-
deep-code publish DATASET_CONFIG WORKFLOW_CONFIG [--environment ENVIRONMENT]
|
|
96
|
+
deep-code publish DATASET_CONFIG WORKFLOW_CONFIG [--environment ENVIRONMENT] [--mode
|
|
97
|
+
all|dataset|workflow]
|
|
97
98
|
```
|
|
98
99
|
|
|
99
100
|
#### Arguments
|
|
@@ -104,8 +105,12 @@ deep-code publish DATASET_CONFIG WORKFLOW_CONFIG [--environment ENVIRONMENT]
|
|
|
104
105
|
(e.g., workflow-config.yaml)
|
|
105
106
|
|
|
106
107
|
#### Options
|
|
108
|
+
--dataset-config, - Explict path to dataset config
|
|
109
|
+
--workflow-config, - Explicit path to workflow config
|
|
107
110
|
--environment, -e - Target catalog environment:
|
|
108
111
|
production (default) | staging | testing
|
|
112
|
+
--mode, -m Publishing mode:
|
|
113
|
+
all (default) | dataset | workflow
|
|
109
114
|
|
|
110
115
|
#### Examples:
|
|
111
116
|
1. Publish to staging catalog
|
|
@@ -120,6 +125,18 @@ deep-code publish dataset-config.yaml workflow-config.yaml -e testing
|
|
|
120
125
|
```
|
|
121
126
|
deep-code publish dataset-config.yaml workflow-config.yaml
|
|
122
127
|
```
|
|
128
|
+
4. Publish Dataset only
|
|
129
|
+
```
|
|
130
|
+
deep-code publish dataset-config.yaml -m dataset
|
|
131
|
+
|
|
132
|
+
deep-code publish --dataset-config dataset.yaml -m dataset
|
|
133
|
+
```
|
|
134
|
+
5. Publish Workflow only
|
|
135
|
+
```
|
|
136
|
+
deep-code publish dataset-config.yaml -m workflow
|
|
137
|
+
|
|
138
|
+
deep-code publish --workflow-config workflow.yaml -m dataset
|
|
139
|
+
```
|
|
123
140
|
#### dataset-config.yaml example
|
|
124
141
|
|
|
125
142
|
```
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2025 by Brockmann Consult GmbH
|
|
4
|
+
# Permissions are hereby granted under the terms of the MIT License:
|
|
5
|
+
# https://opensource.org/licenses/MIT.
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Literal
|
|
9
|
+
|
|
10
|
+
import click
|
|
11
|
+
import yaml
|
|
12
|
+
|
|
13
|
+
from deep_code.tools.publish import Publisher
|
|
14
|
+
|
|
15
|
+
Mode = Literal["all", "dataset", "workflow"]
|
|
16
|
+
|
|
17
|
+
DATASET_MARKERS = {
|
|
18
|
+
"stac_version",
|
|
19
|
+
"extent",
|
|
20
|
+
"license",
|
|
21
|
+
"summaries",
|
|
22
|
+
"assets",
|
|
23
|
+
"providers",
|
|
24
|
+
"collection",
|
|
25
|
+
"collection_id",
|
|
26
|
+
"id",
|
|
27
|
+
}
|
|
28
|
+
WORKFLOW_MARKERS = {
|
|
29
|
+
"workflow",
|
|
30
|
+
"workflow_id",
|
|
31
|
+
"workflow_title",
|
|
32
|
+
"experiment",
|
|
33
|
+
"jupyter_notebook_url",
|
|
34
|
+
"notebook",
|
|
35
|
+
"parameters",
|
|
36
|
+
"input_datasets",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _validate_inputs(
|
|
41
|
+
dataset_config: str | None, workflow_config: str | None, mode: str
|
|
42
|
+
):
|
|
43
|
+
mode = mode.lower()
|
|
44
|
+
|
|
45
|
+
def ensure_file(path: str | None, label: str):
|
|
46
|
+
if path is None:
|
|
47
|
+
raise click.UsageError(f"{label} is required but was not provided.")
|
|
48
|
+
if not Path(path).is_file():
|
|
49
|
+
raise click.UsageError(f"{label} not found: {path} is not a file")
|
|
50
|
+
|
|
51
|
+
if mode == "dataset":
|
|
52
|
+
ensure_file(dataset_config, "DATASET_CONFIG")
|
|
53
|
+
if workflow_config is not None:
|
|
54
|
+
click.echo("Ignoring WORKFLOW_CONFIG since mode=dataset.", err=True)
|
|
55
|
+
|
|
56
|
+
elif mode == "workflow":
|
|
57
|
+
ensure_file(workflow_config, "WORKFLOW_CONFIG")
|
|
58
|
+
|
|
59
|
+
elif mode == "all":
|
|
60
|
+
ensure_file(dataset_config, "DATASET_CONFIG")
|
|
61
|
+
ensure_file(workflow_config, "WORKFLOW_CONFIG")
|
|
62
|
+
|
|
63
|
+
else:
|
|
64
|
+
raise click.UsageError("Invalid mode. Choose one of: all, dataset, workflow.")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _detect_config_type(path: Path) -> Literal["dataset", "workflow"]:
|
|
68
|
+
"""Detect config type via filename hints and YAML top-level keys."""
|
|
69
|
+
name = path.name.lower()
|
|
70
|
+
if "workflow" in name or "experiment" in name:
|
|
71
|
+
return "workflow"
|
|
72
|
+
if "dataset" in name or "collection" in name:
|
|
73
|
+
return "dataset"
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
|
77
|
+
except Exception as e:
|
|
78
|
+
raise ValueError(f"Cannot read YAML from {path}: {e}")
|
|
79
|
+
|
|
80
|
+
if not isinstance(data, dict):
|
|
81
|
+
raise ValueError(f"YAML in {path} must be a mapping/object at the top level.")
|
|
82
|
+
|
|
83
|
+
keys = set(data.keys())
|
|
84
|
+
ds_score = len(keys & DATASET_MARKERS)
|
|
85
|
+
wf_score = len(keys & WORKFLOW_MARKERS)
|
|
86
|
+
|
|
87
|
+
if ds_score > wf_score:
|
|
88
|
+
return "dataset"
|
|
89
|
+
if wf_score > ds_score:
|
|
90
|
+
return "workflow"
|
|
91
|
+
|
|
92
|
+
raise ValueError(
|
|
93
|
+
f"Ambiguous config type for {path}. "
|
|
94
|
+
"Rename to include 'dataset' or 'workflow', or pass the missing file explicitly."
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _assign_configs(
|
|
99
|
+
pos_first: str | None,
|
|
100
|
+
pos_second: str | None,
|
|
101
|
+
mode: Mode,
|
|
102
|
+
explicit_dataset: str | None,
|
|
103
|
+
explicit_workflow: str | None,
|
|
104
|
+
) -> tuple[str | None, str | None]:
|
|
105
|
+
"""
|
|
106
|
+
Decide which file is dataset vs workflow.
|
|
107
|
+
Precedence: explicit flags > positional + detection.
|
|
108
|
+
Returns (dataset_config, workflow_config).
|
|
109
|
+
"""
|
|
110
|
+
ds = explicit_dataset
|
|
111
|
+
wf = explicit_workflow
|
|
112
|
+
|
|
113
|
+
# If both explicit provided, we're done; warn if extra positionals are passed.
|
|
114
|
+
pos_args = [p for p in (pos_first, pos_second) if p]
|
|
115
|
+
if ds and wf:
|
|
116
|
+
if pos_args:
|
|
117
|
+
click.echo(
|
|
118
|
+
"Positional config paths ignored because explicit flags were provided.",
|
|
119
|
+
err=True,
|
|
120
|
+
)
|
|
121
|
+
return ds, wf
|
|
122
|
+
|
|
123
|
+
# Helper to assign a single positional file to the missing slot
|
|
124
|
+
def _assign_single(p: str) -> tuple[str | None, str | None]:
|
|
125
|
+
nonlocal ds, wf
|
|
126
|
+
if ds and wf:
|
|
127
|
+
raise click.UsageError(
|
|
128
|
+
"Both dataset and workflow configs already provided; remove extra positional files."
|
|
129
|
+
)
|
|
130
|
+
# Use mode as a strong hint when only one is missing
|
|
131
|
+
if not ds and mode == "dataset":
|
|
132
|
+
ds = p
|
|
133
|
+
return
|
|
134
|
+
if not wf and mode == "workflow":
|
|
135
|
+
wf = p
|
|
136
|
+
return
|
|
137
|
+
# Otherwise detect
|
|
138
|
+
kind = _detect_config_type(Path(p))
|
|
139
|
+
if kind == "dataset":
|
|
140
|
+
if ds and Path(ds).resolve() != Path(p).resolve():
|
|
141
|
+
raise click.UsageError(
|
|
142
|
+
f"Multiple dataset configs supplied: {ds} and {p}"
|
|
143
|
+
)
|
|
144
|
+
ds = p
|
|
145
|
+
else:
|
|
146
|
+
if wf and Path(wf).resolve() != Path(p).resolve():
|
|
147
|
+
raise click.UsageError(
|
|
148
|
+
f"Multiple workflow configs supplied: {wf} and {p}"
|
|
149
|
+
)
|
|
150
|
+
wf = p
|
|
151
|
+
|
|
152
|
+
# If exactly one explicit provided, try to fill the other via positionals
|
|
153
|
+
if ds and not wf:
|
|
154
|
+
if len(pos_args) > 1:
|
|
155
|
+
raise click.UsageError(
|
|
156
|
+
"Provide at most one positional file when using --dataset-config."
|
|
157
|
+
)
|
|
158
|
+
if pos_args:
|
|
159
|
+
_assign_single(pos_args[0])
|
|
160
|
+
return ds, wf
|
|
161
|
+
|
|
162
|
+
if wf and not ds:
|
|
163
|
+
if len(pos_args) > 1:
|
|
164
|
+
raise click.UsageError(
|
|
165
|
+
"Provide at most one positional file when using --workflow-config."
|
|
166
|
+
)
|
|
167
|
+
if pos_args:
|
|
168
|
+
_assign_single(pos_args[0])
|
|
169
|
+
return ds, wf
|
|
170
|
+
|
|
171
|
+
# No explicit flags: rely on positionals + detection
|
|
172
|
+
if not pos_args:
|
|
173
|
+
return None, None
|
|
174
|
+
if len(pos_args) == 1:
|
|
175
|
+
p = pos_args[0]
|
|
176
|
+
if mode == "dataset":
|
|
177
|
+
return p, None
|
|
178
|
+
if mode == "workflow":
|
|
179
|
+
return None, p
|
|
180
|
+
# mode == "all": detect and require the other later in validation
|
|
181
|
+
kind = _detect_config_type(Path(p))
|
|
182
|
+
return (p, None) if kind == "dataset" else (None, p)
|
|
183
|
+
|
|
184
|
+
# Two positionals: detect both and assign
|
|
185
|
+
p1, p2 = pos_args[0], pos_args[1]
|
|
186
|
+
k1 = _detect_config_type(Path(p1))
|
|
187
|
+
k2 = _detect_config_type(Path(p2))
|
|
188
|
+
if k1 == k2:
|
|
189
|
+
raise click.UsageError(
|
|
190
|
+
f"Both files look like '{k1}' configs: {p1} and {p2}. "
|
|
191
|
+
"Please rename one or use --dataset-config/--workflow-config."
|
|
192
|
+
)
|
|
193
|
+
ds = p1 if k1 == "dataset" else p2
|
|
194
|
+
wf = p1 if k1 == "workflow" else p2
|
|
195
|
+
return ds, wf
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@click.command(name="publish")
|
|
199
|
+
@click.argument("dataset_config", type=click.Path(exists=True), required=False)
|
|
200
|
+
@click.argument("workflow_config", type=click.Path(exists=True), required=False)
|
|
201
|
+
@click.option(
|
|
202
|
+
"--dataset-config",
|
|
203
|
+
"dataset_config_opt",
|
|
204
|
+
type=click.Path(exists=True),
|
|
205
|
+
help="Explicit path to dataset config (overrides positional detection).",
|
|
206
|
+
)
|
|
207
|
+
@click.option(
|
|
208
|
+
"--workflow-config",
|
|
209
|
+
"workflow_config_opt",
|
|
210
|
+
type=click.Path(exists=True),
|
|
211
|
+
help="Explicit path to workflow config (overrides positional detection).",
|
|
212
|
+
)
|
|
213
|
+
@click.option(
|
|
214
|
+
"--environment",
|
|
215
|
+
"-e",
|
|
216
|
+
type=click.Choice(["production", "staging", "testing"], case_sensitive=False),
|
|
217
|
+
default="production",
|
|
218
|
+
help="Target environment for publishing (production, staging, testing)",
|
|
219
|
+
)
|
|
220
|
+
@click.option(
|
|
221
|
+
"--mode",
|
|
222
|
+
"-m",
|
|
223
|
+
type=click.Choice(["all", "dataset", "workflow"], case_sensitive=False),
|
|
224
|
+
default="all",
|
|
225
|
+
help="Publishing mode: dataset only, workflow only, or both",
|
|
226
|
+
)
|
|
227
|
+
def publish(
|
|
228
|
+
dataset_config,
|
|
229
|
+
workflow_config,
|
|
230
|
+
dataset_config_opt,
|
|
231
|
+
workflow_config_opt,
|
|
232
|
+
environment,
|
|
233
|
+
mode,
|
|
234
|
+
):
|
|
235
|
+
"""
|
|
236
|
+
Publish dataset and/or workflow/experiment metadata.
|
|
237
|
+
|
|
238
|
+
Examples:
|
|
239
|
+
deep-code publish workflow.yaml -e staging -m workflow
|
|
240
|
+
deep-code publish dataset.yaml -e staging -m dataset
|
|
241
|
+
deep-code publish dataset.yaml workflow.yaml -m all
|
|
242
|
+
deep-code publish --dataset-config dataset.yaml --workflow-config wf.yaml -m all
|
|
243
|
+
deep-code publish --dataset-config dataset.yaml -m dataset
|
|
244
|
+
deep-code publish --workflow-config wf.yaml -m workflow
|
|
245
|
+
"""
|
|
246
|
+
mode = mode.lower()
|
|
247
|
+
ds_path, wf_path = _assign_configs(
|
|
248
|
+
dataset_config,
|
|
249
|
+
workflow_config,
|
|
250
|
+
mode, # type: ignore[arg-type]
|
|
251
|
+
dataset_config_opt,
|
|
252
|
+
workflow_config_opt,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
_validate_inputs(ds_path, wf_path, mode)
|
|
256
|
+
|
|
257
|
+
publisher = Publisher(
|
|
258
|
+
dataset_config_path=ds_path,
|
|
259
|
+
workflow_config_path=wf_path,
|
|
260
|
+
environment=environment.lower(),
|
|
261
|
+
)
|
|
262
|
+
result = publisher.publish(mode=mode)
|
|
263
|
+
|
|
264
|
+
click.echo(result if isinstance(result, str) else "Wrote files locally.")
|
|
@@ -110,6 +110,69 @@ class TestPublisher(unittest.TestCase):
|
|
|
110
110
|
self.assertEqual(self.publisher.dataset_config, dataset_config)
|
|
111
111
|
self.assertEqual(self.publisher.workflow_config, workflow_config)
|
|
112
112
|
|
|
113
|
+
@patch("deep_code.tools.publish.GitHubPublisher")
|
|
114
|
+
def test_environment_repo_selection(self, mock_gp):
|
|
115
|
+
Publisher(environment="production")
|
|
116
|
+
assert mock_gp.call_args.kwargs["repo_name"] == "open-science-catalog-metadata"
|
|
117
|
+
Publisher(environment="staging")
|
|
118
|
+
assert (
|
|
119
|
+
mock_gp.call_args.kwargs["repo_name"]
|
|
120
|
+
== "open-science-catalog-metadata-staging"
|
|
121
|
+
)
|
|
122
|
+
Publisher(environment="testing")
|
|
123
|
+
assert (
|
|
124
|
+
mock_gp.call_args.kwargs["repo_name"]
|
|
125
|
+
== "open-science-catalog-metadata-testing"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
@patch.object(Publisher, "publish_dataset", return_value={"a": {}})
|
|
129
|
+
@patch.object(
|
|
130
|
+
Publisher, "generate_workflow_experiment_records", return_value={"b": {}}
|
|
131
|
+
)
|
|
132
|
+
def test_publish_mode_routing(self, mock_wf, mock_ds):
|
|
133
|
+
# dataset only
|
|
134
|
+
self.publisher.publish(write_to_file=True, mode="dataset")
|
|
135
|
+
mock_ds.assert_called()
|
|
136
|
+
mock_wf.assert_not_called()
|
|
137
|
+
|
|
138
|
+
mock_ds.reset_mock()
|
|
139
|
+
mock_wf.reset_mock()
|
|
140
|
+
self.publisher.publish(write_to_file=True, mode="workflow")
|
|
141
|
+
mock_ds.assert_not_called()
|
|
142
|
+
mock_wf.assert_called()
|
|
143
|
+
|
|
144
|
+
@patch.object(Publisher, "generate_workflow_experiment_records", return_value={})
|
|
145
|
+
@patch.object(Publisher, "publish_dataset", return_value={})
|
|
146
|
+
def test_publish_nothing_to_publish_raises(
|
|
147
|
+
self, mock_publish_dataset, mock_generate_workflow_experiment_records
|
|
148
|
+
):
|
|
149
|
+
with pytest.raises(ValueError):
|
|
150
|
+
self.publisher.publish(write_to_file=False, mode="dataset")
|
|
151
|
+
mock_publish_dataset.assert_called_once()
|
|
152
|
+
mock_generate_workflow_experiment_records.assert_not_called()
|
|
153
|
+
|
|
154
|
+
@patch.object(Publisher, "publish_dataset", return_value={"x": {}})
|
|
155
|
+
@patch.object(
|
|
156
|
+
Publisher, "generate_workflow_experiment_records", return_value={"y": {}}
|
|
157
|
+
)
|
|
158
|
+
def test_publish_builds_pr_params(self, mock_wf, mock_ds):
|
|
159
|
+
# Make PR creation return a fixed URL
|
|
160
|
+
self.publisher.gh_publisher.publish_files.return_value = "PR_URL"
|
|
161
|
+
|
|
162
|
+
# Provide IDs for commit/PR labels
|
|
163
|
+
self.publisher.collection_id = "col"
|
|
164
|
+
self.publisher.workflow_id = "wf"
|
|
165
|
+
|
|
166
|
+
url = self.publisher.publish(write_to_file=False, mode="all")
|
|
167
|
+
assert url == "PR_URL"
|
|
168
|
+
|
|
169
|
+
# Inspect the call arguments to publish_files
|
|
170
|
+
_, kwargs = self.publisher.gh_publisher.publish_files.call_args
|
|
171
|
+
assert "dataset: col" in kwargs["commit_message"]
|
|
172
|
+
assert "workflow/experiment: wf" in kwargs["commit_message"]
|
|
173
|
+
assert "dataset: col" in kwargs["pr_title"]
|
|
174
|
+
assert "workflow/experiment: wf" in kwargs["pr_title"]
|
|
175
|
+
|
|
113
176
|
|
|
114
177
|
class TestParseGithubNotebookUrl:
|
|
115
178
|
@pytest.mark.parametrize(
|