diff --git a/src/ogdc_runner/__main__.py b/src/ogdc_runner/__main__.py index 1c1e05c..a65e63b 100644 --- a/src/ogdc_runner/__main__.py +++ b/src/ogdc_runner/__main__.py @@ -1,10 +1,8 @@ from __future__ import annotations -import os -import tempfile import subprocess +import tempfile import time -from pathlib import Path from urllib.parse import urlparse import click @@ -16,18 +14,18 @@ # handling github by # checking if path is a URL def is_url(recipe_path): - """ Check if the path is a valid URL.""" + """Check if the path is a valid URL.""" parsed = urlparse(recipe_path) - return parsed.scheme in ('http', 'https') and parsed.netloc != '' + return parsed.scheme in ("http", "https") and parsed.netloc != "" def convert_url_to_ssh(recipe_path): - """ Convert https github url to ssh format.""" + """Convert https github url to ssh format.""" parsed = urlparse(recipe_path) if parsed.scheme != "https" or "github.com" not in parsed.netloc: raise ValueError("Invalid GitHub HTTPS URL") # extract just the repo path - repo_path = parsed.path.lstrip("/") + repo_path = parsed.path.lstrip("/") return f"git@github.com:{repo_path}.git" @@ -35,11 +33,12 @@ def clone_repo(ssh_url): """Clone the repository into a temporary directory.""" temp_dir = tempfile.mkdtemp() try: - subprocess.run(['git', 'clone', ssh_url, temp_dir], check=True) + subprocess.run(["git", "clone", ssh_url, temp_dir], check=True) return temp_dir except subprocess.CalledProcessError as e: print(f"Error cloning repository: {e}") + # use that as a local path for submission # need to figure out how to best do this for if its a url - this is a temporary solution recipe_path = click.argument( @@ -55,11 +54,7 @@ def clone_repo(ssh_url): # path_type=Path, # ), ) -recipe_name = click.argument( - "recipe_name", - required=False, - type = str -) +recipe_name = click.argument("recipe_name", required=False, type=str) @click.group @@ -72,7 +67,7 @@ def _submit_workflow(recipe_path) -> str: print(f"Detected URL: {recipe_path}. Cloning repository...") ssh_url = convert_url_to_ssh(recipe_path) clone_repo(ssh_url) - else: + else: workflow = make_simple_workflow( recipe_dir=recipe_path, )