diff --git a/README.md b/README.md index c1ab255..1661314 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` diff --git a/deep_code/cli/publish.py b/deep_code/cli/publish.py index 47e34fb..39db233 100644 --- a/deep_code/cli/publish.py +++ b/deep_code/cli/publish.py @@ -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() diff --git a/deep_code/tests/tools/test_publish.py b/deep_code/tests/tools/test_publish.py index f355cb5..f62db2c 100644 --- a/deep_code/tests/tools/test_publish.py +++ b/deep_code/tests/tools/test_publish.py @@ -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 diff --git a/deep_code/tools/new.py b/deep_code/tools/new.py index f54d0b2..89e62c5 100644 --- a/deep_code/tools/new.py +++ b/deep_code/tools/new.py @@ -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""" - - diff --git a/deep_code/tools/publish.py b/deep_code/tools/publish.py index c17264f..9918847 100644 --- a/deep_code/tools/publish.py +++ b/deep_code/tools/publish.py @@ -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") @@ -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() @@ -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 = "" diff --git a/deep_code/version.py b/deep_code/version.py index 3104c7c..f3eb35c 100644 --- a/deep_code/version.py +++ b/deep_code/version.py @@ -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"