Skip to content

Commit 10633e9

Browse files
committed
Added --export-directives option to build mode to export component's
directives in JSON format to standard output.
1 parent a379785 commit 10633e9

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## Changes in upcoming release (dev branch)
3+
## Changes in upcoming release (`dev` branch)
44

55
### Components changes
66

@@ -10,6 +10,10 @@ Updated images for components `mash_dist`, `mash_screen` and
1010
### New components
1111
- Added component `fast_ani`.
1212

13+
### Minor/Other changes
14+
15+
- Added `--export-directives` option to `build` mode to export component's
16+
directives in JSON format to standard output.
1317

1418
## 1.3.0
1519

flowcraft/flowcraft.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ def get_args(args=None):
9797
"components (via -t option) in JSON format to stdout. "
9898
"No pipeline will be generated with this option."
9999
)
100+
build_parser.add_argument(
101+
"--export-directives", dest="export_directives", action="store_const",
102+
const=True, help="Only export the directives for the provided "
103+
"components (via -t option) in JSON format to stdout. "
104+
"No pipeline will be generated with this option."
105+
)
100106

101107
# GENERAL OPTIONS
102108
parser.add_argument(
@@ -177,7 +183,7 @@ def validate_build_arguments(args):
177183

178184
# Skill all checks when exporting parameters AND providing at least one
179185
# component
180-
if args.export_params:
186+
if args.export_params or args.export_directives:
181187
# Check if components provided
182188
if not args.tasks:
183189
logger.error(colored_print(
@@ -266,8 +272,9 @@ def copy_project(path):
266272

267273
def build(args):
268274

269-
# Disable standard logging for stdout when the following modes are executed:
270-
if args.export_params:
275+
# Disable standard logging for stdout when the following modes are
276+
# executed:
277+
if args.export_params or args.export_directives:
271278
logger.setLevel(logging.ERROR)
272279

273280
welcome = [
@@ -330,6 +337,9 @@ def build(args):
330337
if args.export_params:
331338
nfg.export_params()
332339
sys.exit(0)
340+
elif args.export_directives:
341+
nfg.export_directives()
342+
sys.exit(0)
333343
else:
334344
# building the actual pipeline nf file
335345
nfg.build()

flowcraft/generator/engine.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,19 @@ def export_params(self):
15061506
# Flush params json to stdout
15071507
sys.stdout.write(json.dumps(params_json))
15081508

1509+
def export_directives(self):
1510+
"""Export pipeline directives as a JSON to stdout
1511+
"""
1512+
1513+
directives_json = {}
1514+
1515+
# Skip first init process
1516+
for p in self.processes[1:]:
1517+
directives_json[p.template] = p.directives
1518+
1519+
# Flush params json to stdout
1520+
sys.stdout.write(json.dumps(directives_json))
1521+
15091522
def build(self):
15101523
"""Main pipeline builder
15111524

0 commit comments

Comments
 (0)