diff --git a/src/cwl_ica/classes/icav2_bunch_classes.py b/src/cwl_ica/classes/icav2_bunch_classes.py index 643cc9a..deaf949 100644 --- a/src/cwl_ica/classes/icav2_bunch_classes.py +++ b/src/cwl_ica/classes/icav2_bunch_classes.py @@ -1057,7 +1057,7 @@ def create_bundle_from_bunch_version(self, icav2_access_token: str): :return: """ - bundle_obj = generate_empty_bundle( + self.bundle_id = generate_empty_bundle( bundle_name=self.bundle_name, bundle_version=self.bundle_version, bundle_description=self.bundle_description, @@ -1068,9 +1068,6 @@ def create_bundle_from_bunch_version(self, icav2_access_token: str): icav2_access_token=icav2_access_token, ) - # Get bundle id - self.bundle_id = bundle_obj.id - # Set bundle url self.bundle_url = f"https://ica.illumina.com/ica/bundles/{self.bundle_id}/bundleDetails" diff --git a/src/cwl_ica/utils/icav2_gh_helpers.py b/src/cwl_ica/utils/icav2_gh_helpers.py index ae66db4..3bebbc6 100644 --- a/src/cwl_ica/utils/icav2_gh_helpers.py +++ b/src/cwl_ica/utils/icav2_gh_helpers.py @@ -13,6 +13,7 @@ from urllib.parse import urlparse import json from ruamel.yaml import YAML, CommentedMap, CommentedSeq +from wrapica.bundle import get_bundle_obj_from_bundle_id # Wrapica from wrapica.data import Data @@ -514,7 +515,7 @@ def generate_empty_bundle( categories: List[str], pipeline_release_url: str, icav2_access_token: str -): +) -> str: """ Generate an empty bundle :param bundle_name: @@ -525,7 +526,7 @@ def generate_empty_bundle( :param categories: :param pipeline_release_url: :param icav2_access_token: - :return: + :return: The bundle id """ # Create pipeline from GitHub release proc_environ = os.environ.copy() @@ -537,7 +538,7 @@ def generate_empty_bundle( } ) - link_data_command = [ + generate_empty_bundle_command = [ f"{os.environ['ICAV2_CLI_PLUGINS_HOME']}/pyenv/bin/python", f"{os.environ['ICAV2_CLI_PLUGINS_HOME']}/pyenv/bin/icav2-cli-plugins.py", "bundles", @@ -546,23 +547,26 @@ def generate_empty_bundle( "--short-description", bundle_description, "--bundle-version", bundle_version, "--bundle-version-description", bundle_version_description, + "--json" ] # Extend with categories for category in categories: - link_data_command.extend(["--category", category]) + generate_empty_bundle_command.extend(["--category", category]) - link_data_returncode, link_data_stdout, link_data_stderr = run_subprocess_proc( - link_data_command, + generate_empty_bundle_returncode, generate_empty_bundle_stdout, generate_empty_bundle_stderr = run_subprocess_proc( + generate_empty_bundle_command, env=proc_environ, capture_output=True ) - if not link_data_returncode == 0: - logger.error(f"{link_data_stdout}") - logger.error(f"{link_data_stderr}") + if not generate_empty_bundle_returncode == 0: + logger.error(f"{generate_empty_bundle_stdout}") + logger.error(f"{generate_empty_bundle_stderr}") raise ChildProcessError + return json.loads(generate_empty_bundle_stdout).get("id") + def add_data_to_bundle(bundle_id, data_id, icav2_access_token: str): """