diff --git a/requirements.txt b/requirements.txt index 302f524..c260c5e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -app_pack_generator>=0.4.3 -unity-sds-client==0.2.0 +app_pack_generator>=1.0.0 +unity-sds-client>=0.2.0 diff --git a/unity_app_generator/__main__.py b/unity_app_generator/__main__.py index b7ad7ca..62b3be3 100755 --- a/unity_app_generator/__main__.py +++ b/unity_app_generator/__main__.py @@ -79,7 +79,7 @@ def build_cwl(args): app_gen = UnityApplicationGenerator(state_dir) - app_gen.create_cwl(cwl_output_path=args.cwl_output_path, docker_url=args.image_url) + app_gen.create_cwl(cwl_output_path=args.cwl_output_path, docker_url=args.image_url, monolithic=args.monolithic) def push_app_registry(args): state_dir = check_state_directory(state_directory_path(args)) @@ -152,6 +152,9 @@ def main(): parser_build_cwl.add_argument("-u", "--image_url", help="Docker image tag or remote registry URL to be included in the generated CWL files if not using the build_docker and/or push_docker subcommands") + parser_build_cwl.add_argument("--monolithic", action="store_true", + help="Use the deprecated 'monolithic' approach to generating CWL where stage in and out are bundled inside the application") + parser_build_cwl.set_defaults(func=build_cwl) # push_app_registry diff --git a/unity_app_generator/generator.py b/unity_app_generator/generator.py index 132f2fe..d767ce5 100644 --- a/unity_app_generator/generator.py +++ b/unity_app_generator/generator.py @@ -6,7 +6,8 @@ from .state import ApplicationState -from app_pack_generator import GitManager, DockerUtil, ApplicationNotebook, CWL, Descriptor +from app_pack_generator import GitManager, DockerUtil, ApplicationNotebook +from app_pack_generator import ProcessCWL, DataStagingCWL, Descriptor from unity_sds_client.services.application_service import DockstoreAppCatalog @@ -55,9 +56,9 @@ def push_to_docker_registry(self, docker_registry, image_tag=None): # Push to remote repository self.app_state.docker_url = self.docker_util.push_image(docker_registry, self.app_state.docker_image_tag) - def _generate_dockstore_cwl(self, cwl_output_path): + def _generate_dockstore_cwl(self, cwl_output_path, target_cwl_filename): - template = """ + template = f""" cwlVersion: v1.0 class: Workflow @@ -66,14 +67,15 @@ def _generate_dockstore_cwl(self, cwl_output_path): steps: step: - run: workflow.cwl + run: {target_cwl_filename} """ + # Hard code file name because it is a hard coded re dockstore_cwl_filename = os.path.join(cwl_output_path, "Dockstore.cwl") with open(dockstore_cwl_filename, "w") as cwl_file: cwl_file.write(template.lstrip()) - def create_cwl(self, cwl_output_path=None, docker_url=None): + def create_cwl(self, cwl_output_path=None, docker_url=None, monolithic=False): # Fall through using docker_image_tag if docker_url does not exist because no push has occurred # Or if docker_url is supplied as an argument use that @@ -99,14 +101,26 @@ def create_cwl(self, cwl_output_path=None, docker_url=None): app = ApplicationNotebook(notebook_filename) logger.info("Parameters:\n" + app.parameter_summary()) + + # Create CWL files depending on the mode of production + cwl_generators = [ ProcessCWL(app) ] - cwl = CWL(app) - desc = Descriptor(app, self.repo_info) + if monolithic: + cwl_generators.append( DataStagingCWL(app) ) - files = cwl.generate_all(cwl_output_path, docker_url) - files.append(desc.generate_descriptor(cwl_output_path, docker_url)) + files_created = [] + for cwl_gen in cwl_generators: + files_created += cwl_gen.generate_all(cwl_output_path, dockerurl=docker_url) + + # Add the JSON descriptor file + desc = Descriptor(app, self.repo_info) + files_created.append(desc.generate_descriptor(cwl_output_path, docker_url)) - self._generate_dockstore_cwl(cwl_output_path) + # Add Dockstore.cwl, point it to the appropriate entry point + if monolithic: + self._generate_dockstore_cwl(cwl_output_path, "workflow.cwl") + else: + self._generate_dockstore_cwl(cwl_output_path, "process.cwl") def notebook_parameters(self): diff --git a/unity_app_generator/version.py b/unity_app_generator/version.py index b4cd250..97123c1 100644 --- a/unity_app_generator/version.py +++ b/unity_app_generator/version.py @@ -1 +1 @@ -__version__="0.3.2" +__version__="1.0.0"