Skip to content

Commit 4b1282a

Browse files
committed
support publish to testing and staging osc forks
1 parent 737dccb commit 4b1282a

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

deep_code/cli/publish.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@
1212
@click.command(name="publish")
1313
@click.argument("dataset_config", type=click.Path(exists=True))
1414
@click.argument("workflow_config", type=click.Path(exists=True))
15-
def publish(dataset_config, workflow_config):
15+
@click.option(
16+
"--environment",
17+
type=click.Choice(["production", "staging", "testing"],
18+
case_sensitive=False),
19+
default="production",
20+
help="Target environment for publishing (production, staging, testing)",
21+
)
22+
def publish(dataset_config, workflow_config, environment):
1623
"""Request publishing a dataset to the open science catalogue.
1724
"""
1825
publisher = Publisher(
19-
dataset_config_path=dataset_config, workflow_config_path=workflow_config
26+
dataset_config_path=dataset_config,
27+
workflow_config_path=workflow_config,
28+
environment=environment.lower(),
2029
)
2130
publisher.publish_all()

deep_code/tools/publish.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class GitHubPublisher:
4141
- Common GitHub automation steps (fork, clone, branch, file commit, pull request)
4242
"""
4343

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

5252
self.github_automation = GitHubAutomation(
53-
self.github_username, self.github_token, OSC_REPO_OWNER, OSC_REPO_NAME
53+
self.github_username,
54+
self.github_token,
55+
OSC_REPO_OWNER,
56+
repo_name
5457
)
5558
self.github_automation.fork_repository()
5659
self.github_automation.clone_sync_repository()
@@ -102,9 +105,23 @@ class Publisher:
102105
"""Publishes products (datasets) to the OSC GitHub repository.
103106
"""
104107

105-
def __init__(self, dataset_config_path: str, workflow_config_path: str):
108+
def __init__(
109+
self,
110+
dataset_config_path: str,
111+
workflow_config_path: str,
112+
environment: str = "production",
113+
):
114+
self.environment = environment
115+
# Determine repo name based on environment
116+
repo_name = "open-science-catalog-metadata"
117+
118+
if environment == "staging":
119+
repo_name = "open-science-catalog-metadata-staging"
120+
elif environment == "testing":
121+
repo_name = "open-science-catalog-metadata-testing"
122+
106123
# Composition
107-
self.gh_publisher = GitHubPublisher()
124+
self.gh_publisher = GitHubPublisher(repo_name=repo_name)
108125
self.collection_id = ""
109126
self.workflow_title = ""
110127

deep_code/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2020
# DEALINGS IN THE SOFTWARE.
2121

22-
version = "0.1.1"
22+
version = "0.1.2.dev0"

0 commit comments

Comments
 (0)