Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ experiments/workflow as OGC API record and Datasets as an OSC stac collection.
## Setup

## Install
`deep-code` will be available in PyPI and conda-forge. Till the stable release,
`deep-code` will be available in PyPI for now and will be available in conda-forge
in the near future. Till the stable release,
developers/contributors can follow the below steps to install deep-code.

## Installing from the repository for Developers/Contributors
Expand Down Expand Up @@ -69,13 +70,38 @@ github-token: personal access token

### deep-code publish

Publish the experiment, workflow and dataset which is a result of an experiment to
the EarthCODE open-science catalog.
Publishes metadata of experiment, workflow and dataset to the EarthCODE open-science
catalog

```commandline
deep-code publish /path/to/dataset-config.yaml /path/to/workflow-config.yaml
### Usage
```
deep-code publish DATASET_CONFIG WORKFLOW_CONFIG [--environment ENVIRONMENT]
```

#### Arguments
DATASET_CONFIG - Path to the dataset configuration YAML file
(e.g., dataset-config.yaml)

WORKFLOW_CONFIG - Path to the workflow configuration YAML file
(e.g., workflow-config.yaml)

#### Options
--environment, -e - Target catalog environment:
production (default) | staging | testing

#### Examples:
1. Publish to staging catalog
```
deep-code publish dataset-config.yaml workflow-config.yaml --environment=staging
```
2. Publish to testing catalog
```
deep-code publish dataset-config.yaml workflow-config.yaml -e testing
```
3. Publish to production catalog
```
deep-code publish dataset-config.yaml workflow-config.yaml
```
#### dataset-config.yaml example

```
Expand Down
15 changes: 12 additions & 3 deletions deep_code/cli/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@
@click.command(name="publish")
@click.argument("dataset_config", type=click.Path(exists=True))
@click.argument("workflow_config", type=click.Path(exists=True))
def publish(dataset_config, workflow_config):
"""Request publishing a dataset to the open science catalogue.
@click.option(
"--environment", "-e",
type=click.Choice(["production", "staging", "testing"], case_sensitive=False),
default="production",
help="Target environment for publishing (production, staging, testing)",
)
def publish(dataset_config, workflow_config, environment):
"""Request publishing a dataset along with experiment and workflow metadata to the
open science catalogue.
"""
publisher = Publisher(
dataset_config_path=dataset_config, workflow_config_path=workflow_config
dataset_config_path=dataset_config,
workflow_config_path=workflow_config,
environment=environment.lower(),
)
publisher.publish_all()
9 changes: 5 additions & 4 deletions deep_code/tests/tools/test_publish.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import unittest
from unittest.mock import patch, mock_open, MagicMock
import json
import yaml
from pathlib import Path
import tempfile
import unittest
from pathlib import Path
from unittest.mock import MagicMock, mock_open, patch

import yaml
from pystac import Catalog

from deep_code.tools.publish import Publisher
Expand Down
2 changes: 0 additions & 2 deletions deep_code/tools/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@
workflow notebook template (e.g. workflow.ipynb), a template Python package (code and
pyproject.toml), and a template setup for documentation (e.g., using mkdocs),
setup of the build pipeline"""


22 changes: 18 additions & 4 deletions deep_code/tools/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GitHubPublisher:
- Common GitHub automation steps (fork, clone, branch, file commit, pull request)
"""

def __init__(self):
def __init__(self, repo_name: str = OSC_REPO_NAME):
with fsspec.open(".gitaccess", "r") as file:
git_config = yaml.safe_load(file) or {}
self.github_username = git_config.get("github-username")
Expand All @@ -50,7 +50,7 @@ def __init__(self):
raise ValueError("GitHub credentials are missing in the `.gitaccess` file.")

self.github_automation = GitHubAutomation(
self.github_username, self.github_token, OSC_REPO_OWNER, OSC_REPO_NAME
self.github_username, self.github_token, OSC_REPO_OWNER, repo_name
)
self.github_automation.fork_repository()
self.github_automation.clone_sync_repository()
Expand Down Expand Up @@ -102,9 +102,23 @@ class Publisher:
"""Publishes products (datasets) to the OSC GitHub repository.
"""

def __init__(self, dataset_config_path: str, workflow_config_path: str):
def __init__(
self,
dataset_config_path: str,
workflow_config_path: str,
environment: str = "production",
):
self.environment = environment
# Determine repo name based on environment
repo_name = "open-science-catalog-metadata"

if environment == "staging":
repo_name = "open-science-catalog-metadata-staging"
elif environment == "testing":
repo_name = "open-science-catalog-metadata-testing"

# Composition
self.gh_publisher = GitHubPublisher()
self.gh_publisher = GitHubPublisher(repo_name=repo_name)
self.collection_id = ""
self.workflow_title = ""

Expand Down
2 changes: 1 addition & 1 deletion deep_code/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

version = "0.1.1"
version = "0.1.2.dev0"