Skip to content

Instantly share code, notes, and snippets.

@mlin
Last active July 22, 2016 14:21
Show Gist options
  • Save mlin/3cce81f54a640c3f62a2725acbc98283 to your computer and use it in GitHub Desktop.
Save mlin/3cce81f54a640c3f62a2725acbc98283 to your computer and use it in GitHub Desktop.
dxapp.yml
#!/usr/bin/env python
#
# dx-yml-build: transcodes dxapp.yml to dxapp.json and then runs `dx build`
# with command-line arguments passed through.
#
# Requires PyYAML (apt-get install python-yaml OR pip install pyyaml)
import os, sys
import yaml, json
with open('dxapp.yml') as infile:
data = yaml.load(infile)
data["00COMMENT"] = "This dxapp.json has been generated from dxapp.yml automatically using dx-yml-build"
with open('dxapp.json', 'w') as outfile:
json.dump(data, outfile, sort_keys=True, indent=2)
outfile.write('\n')
os.execvp("dx", ["dx", "build"] + sys.argv[1:])
name: hello-world
dxapi: 1.0.0
version: 0.0.1
inputSpec:
- name: infile
class: file
optional: true
outputSpec:
- name: outfile
class: file
runSpec:
systemRequirements:
main:
instanceType: mem1_ssd1_x2
distribution: Ubuntu
release: "14.04"
execDepends:
- name: liblz4-tool
interpreter: bash
code: |
#!/bin/bash
main() {
set -ex -o pipefail
# dx-download-all-inputs --parallel
if [ -n "$infile" ]; then
dx cat "$infile" > /dev/null
fi
mkdir -p out/outfile
echo "Hello, world!" > out/outfile/hello-world.txt
# dx-upload-all-outputs --parallel
outfile=$(cat out/outfile/hello-world.txt | dx upload --destination "hello-world.txt" --brief -)
dx-jobutil-add-output outfile "$outfile" --class=file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment