Skip to content

Commit 58dbf31

Browse files
committed
updated change log and docs
1 parent b8f5653 commit 58dbf31

3 files changed

Lines changed: 130 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,18 @@
8282
- S3 write credentials are resolved from `S3_USER_STORAGE_KEY`/`S3_USER_STORAGE_SECRET`,
8383
`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`, or the boto3 default chain
8484
(IAM role, `~/.aws/credentials`) — no secrets in config files.
85+
86+
- Made `osc_project` a configurable parameter on `OscDatasetStacGenerator` (default:
87+
`"deep-earth-system-data-lab"`), replacing the previously hardcoded value.
88+
- The project identifier is now used dynamically when setting `osc:project` on the
89+
OSC extension, generating the `related` link to the project collection, and
90+
resolving the project collection file path during publishing.
91+
92+
- Publisher now creates the OSC project collection automatically when it does not yet
93+
exist in the catalog repository, instead of failing or silently skipping.
94+
- A minimal but valid STAC Collection is generated for the project with `self`,
95+
`root`, and `parent` links.
96+
- A `child` link for the new project is appended to `projects/catalog.json` so the
97+
project is reachable from the catalog root.
98+
- If the project collection already exists, the existing update path (appending
99+
product `child` and theme `related` links) is used unchanged.

docs/configuration.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,55 @@ collection_id: your-collection
77
osc_themes: [cryosphere]
88
osc_region: global
99
dataset_status: completed # or ongoing/planned
10+
license_type: CC-BY-4.0
1011
documentation_link: https://example.com/docs
1112
access_link: s3://bucket/your-dataset.zarr
13+
14+
# Optional: publish a STAC Catalog + Item next to the data on S3.
15+
# When set, a lightweight STAC hierarchy (catalog.json → item.json) is written
16+
# directly to S3 and a "via" link is added to the OSC collection pointing to it.
17+
stac_catalog_s3_root: s3://bucket/stac/your-collection/
18+
```
19+
20+
### Field reference
21+
22+
| Field | Required | Description |
23+
|---|---|---|
24+
| `dataset_id` | Yes | Zarr store identifier (used to open the dataset). |
25+
| `collection_id` | Yes | Unique ID for the STAC collection in the OSC catalog. |
26+
| `license_type` | Yes | SPDX license identifier (e.g. `CC-BY-4.0`). |
27+
| `osc_themes` | No | List of OSC theme slugs (e.g. `[cryosphere, oceans]`). |
28+
| `osc_region` | No | Geographical region label (default: `Global`). |
29+
| `dataset_status` | No | One of `ongoing`, `completed`, or `planned` (default: `ongoing`). |
30+
| `access_link` | No | Public S3 URL of the Zarr store. Defaults to `s3://deep-esdl-public/{dataset_id}`. |
31+
| `documentation_link` | No | URL to dataset documentation. |
32+
| `stac_catalog_s3_root` | No | S3 root for the dataset-level STAC Catalog/Item. See [STAC Catalog on S3](#stac-catalog-on-s3). |
33+
34+
### STAC Catalog on S3
35+
36+
Setting `stac_catalog_s3_root` generates a two-file STAC hierarchy on S3 alongside
37+
the data:
38+
39+
```
40+
s3://bucket/stac/your-collection/
41+
├── catalog.json # STAC Catalog (root)
42+
└── your-collection/
43+
└── item.json # STAC Item covering the full Zarr store
1244
```
1345

46+
The item has two assets:
47+
48+
- `zarr-data` — points to the Zarr store (`application/vnd+zarr`).
49+
- `zarr-consolidated-metadata` — points to `.zmetadata` (`application/json`).
50+
51+
The OSC collection gains a `via` link to `catalog.json` so STAC-aware clients
52+
can discover the data path. `rel="child"` is intentionally avoided because the
53+
OSC validator requires every `child` link to resolve inside the metadata repository.
54+
55+
S3 credentials are resolved in this order: `S3_USER_STORAGE_KEY` /
56+
`S3_USER_STORAGE_SECRET` env vars, then `AWS_ACCESS_KEY_ID` /
57+
`AWS_SECRET_ACCESS_KEY`, then the boto3 default chain (IAM role, `~/.aws/credentials`).
58+
1459
## Workflow config (YAML)
1560
```yaml
1661
workflow_id: your-workflow

docs/python-api.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from deep_code.tools.publish import Publisher
88
publisher = Publisher(
99
dataset_config_path="dataset.yaml",
1010
workflow_config_path="workflow.yaml",
11-
environment="staging",
11+
environment="staging", # "production" | "staging" | "testing"
1212
)
1313

1414
# Generate files locally (no PR)
@@ -18,3 +18,72 @@ publisher.publish(write_to_file=True, mode="all")
1818
publisher.publish(write_to_file=False, mode="dataset")
1919
```
2020

21+
`mode` controls what is published:
22+
23+
| `mode` | What is published |
24+
|---|---|
25+
| `"dataset"` | OSC STAC collection, variable catalogs, product/variable base catalogs, project collection. |
26+
| `"workflow"` | OGC API workflow and experiment records, workflow/experiment base catalogs. |
27+
| `"all"` | Both of the above (default). |
28+
29+
---
30+
31+
## OscDatasetStacGenerator
32+
33+
`OscDatasetStacGenerator` can also be used directly when you need more control
34+
over individual artifacts.
35+
36+
```python
37+
from deep_code.utils.dataset_stac_generator import OscDatasetStacGenerator
38+
39+
generator = OscDatasetStacGenerator(
40+
dataset_id="my-dataset.zarr",
41+
collection_id="my-collection",
42+
workflow_id="my-workflow",
43+
workflow_title="My Workflow",
44+
license_type="CC-BY-4.0",
45+
osc_themes=["cryosphere"],
46+
osc_region="Global",
47+
osc_status="completed",
48+
# Optional: override the default project identifier.
49+
# Controls osc:project on the collection and the link to the project collection.
50+
osc_project="deep-earth-system-data-lab",
51+
)
52+
```
53+
54+
### `osc_project` parameter
55+
56+
`osc_project` defaults to `"deep-earth-system-data-lab"` and is used in three places:
57+
58+
1. Sets `osc:project` on the OSC extension of the generated STAC collection.
59+
2. Generates the `related` link from the product collection to the project collection
60+
(`../../projects/{osc_project}/collection.json`).
61+
3. Determines the file path of the project collection when publishing
62+
(`projects/{osc_project}/collection.json`).
63+
64+
### Automatic project collection creation
65+
66+
When `Publisher.publish_dataset()` runs, it checks whether
67+
`projects/{osc_project}/collection.json` already exists in the catalog repository:
68+
69+
- **Missing** — a minimal STAC Collection is created for the project and a `child`
70+
link is appended to `projects/catalog.json` so it is reachable from the catalog root.
71+
- **Exists** — the existing collection is updated with a `child` link to the new
72+
product and `related` links for its themes (same behaviour as before).
73+
74+
This means publishing to a new project does not require manual catalog setup.
75+
76+
### STAC Catalog and Item generation
77+
78+
```python
79+
# Build the S3 STAC hierarchy (dict keyed by S3 path)
80+
file_dict = generator.build_zarr_stac_catalog_file_dict(
81+
stac_catalog_s3_root="s3://bucket/stac/my-collection/"
82+
)
83+
# file_dict contains:
84+
# "s3://bucket/stac/my-collection/catalog.json"
85+
# "s3://bucket/stac/my-collection/my-collection/item.json"
86+
```
87+
88+
See [STAC Catalog on S3](configuration.md#stac-catalog-on-s3) for details on the
89+
generated structure.

0 commit comments

Comments
 (0)