Skip to content

Commit 03d851e

Browse files
authored
Merge pull request #25 from unity-sds/optional_stage_inout
Remove bundling of stage in/out from unity-app-generator by default
2 parents cb31ecc + 296300e commit 03d851e

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
app_pack_generator>=0.4.3
2-
unity-sds-client==0.2.0
1+
app_pack_generator>=1.0.0
2+
unity-sds-client>=0.2.0

unity_app_generator/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def build_cwl(args):
7979

8080
app_gen = UnityApplicationGenerator(state_dir)
8181

82-
app_gen.create_cwl(cwl_output_path=args.cwl_output_path, docker_url=args.image_url)
82+
app_gen.create_cwl(cwl_output_path=args.cwl_output_path, docker_url=args.image_url, monolithic=args.monolithic)
8383

8484
def push_app_registry(args):
8585
state_dir = check_state_directory(state_directory_path(args))
@@ -152,6 +152,9 @@ def main():
152152
parser_build_cwl.add_argument("-u", "--image_url",
153153
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")
154154

155+
parser_build_cwl.add_argument("--monolithic", action="store_true",
156+
help="Use the deprecated 'monolithic' approach to generating CWL where stage in and out are bundled inside the application")
157+
155158
parser_build_cwl.set_defaults(func=build_cwl)
156159

157160
# push_app_registry

unity_app_generator/generator.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
from .state import ApplicationState
88

9-
from app_pack_generator import GitManager, DockerUtil, ApplicationNotebook, CWL, Descriptor
9+
from app_pack_generator import GitManager, DockerUtil, ApplicationNotebook
10+
from app_pack_generator import ProcessCWL, DataStagingCWL, Descriptor
1011

1112
from unity_sds_client.services.application_service import DockstoreAppCatalog
1213

@@ -55,9 +56,9 @@ def push_to_docker_registry(self, docker_registry, image_tag=None):
5556
# Push to remote repository
5657
self.app_state.docker_url = self.docker_util.push_image(docker_registry, self.app_state.docker_image_tag)
5758

58-
def _generate_dockstore_cwl(self, cwl_output_path):
59+
def _generate_dockstore_cwl(self, cwl_output_path, target_cwl_filename):
5960

60-
template = """
61+
template = f"""
6162
cwlVersion: v1.0
6263
6364
class: Workflow
@@ -66,14 +67,15 @@ def _generate_dockstore_cwl(self, cwl_output_path):
6667
6768
steps:
6869
step:
69-
run: workflow.cwl
70+
run: {target_cwl_filename}
7071
"""
72+
7173
# Hard code file name because it is a hard coded re
7274
dockstore_cwl_filename = os.path.join(cwl_output_path, "Dockstore.cwl")
7375
with open(dockstore_cwl_filename, "w") as cwl_file:
7476
cwl_file.write(template.lstrip())
7577

76-
def create_cwl(self, cwl_output_path=None, docker_url=None):
78+
def create_cwl(self, cwl_output_path=None, docker_url=None, monolithic=False):
7779

7880
# Fall through using docker_image_tag if docker_url does not exist because no push has occurred
7981
# 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):
99101
app = ApplicationNotebook(notebook_filename)
100102

101103
logger.info("Parameters:\n" + app.parameter_summary())
104+
105+
# Create CWL files depending on the mode of production
106+
cwl_generators = [ ProcessCWL(app) ]
102107

103-
cwl = CWL(app)
104-
desc = Descriptor(app, self.repo_info)
108+
if monolithic:
109+
cwl_generators.append( DataStagingCWL(app) )
105110

106-
files = cwl.generate_all(cwl_output_path, docker_url)
107-
files.append(desc.generate_descriptor(cwl_output_path, docker_url))
111+
files_created = []
112+
for cwl_gen in cwl_generators:
113+
files_created += cwl_gen.generate_all(cwl_output_path, dockerurl=docker_url)
114+
115+
# Add the JSON descriptor file
116+
desc = Descriptor(app, self.repo_info)
117+
files_created.append(desc.generate_descriptor(cwl_output_path, docker_url))
108118

109-
self._generate_dockstore_cwl(cwl_output_path)
119+
# Add Dockstore.cwl, point it to the appropriate entry point
120+
if monolithic:
121+
self._generate_dockstore_cwl(cwl_output_path, "workflow.cwl")
122+
else:
123+
self._generate_dockstore_cwl(cwl_output_path, "process.cwl")
110124

111125
def notebook_parameters(self):
112126

unity_app_generator/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__="0.3.2"
1+
__version__="1.0.0"

0 commit comments

Comments
 (0)