gwl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gwl-devel] variable interpolation in code snippets


From: Ricardo Wurmus
Subject: [gwl-devel] variable interpolation in code snippets
Date: Wed, 20 Feb 2019 15:50:34 +0100
User-agent: mu4e 1.0; emacs 26.1

Hi,

code snippets can now reference variables.  Here’s an example:

--8<---------------cut here---------------start------------->8---
define-module : snippets-wisp

import
  gwl processes
  gwl workflows
  gwl sugar

process: python-test
  package-inputs : list "python2"
  data-inputs
    list "sample.bam" "hg38.fa" "abc"
  procedure # python {
import os

def hello():
  print "hello from python 2"
  print "{{data-inputs}}"
  print "{{name}}"
  print os.environ["_GWL_PROCESS_DATA_INPUTS"]
  print os.environ["_GWL_PROCESS_NAME"]

hello()
}
--8<---------------cut here---------------end--------------->8---

The “python-test” process refers to the variables “data-inputs” and
“name”.  These variables are provided by the “process” record (values
for all defined fields are let bound, so that other fields can access
them), but you could access any other variable that’s in scope.

This is accomplished with the same reader macro that implements the “# ”
syntax for procedures.

The above example also shows access of the same values through
environment variables.  Note that in both cases all values are forced to
be strings.  You can’t have a Scheme list and use it natively as Python
array.  This whole “# ” syntax only operates on strings.  (You can have
a Scheme string that *looks* like Python syntax, of course, and splice
it into your inline Python code, but … you probably shouldn’t do that.)

--
Ricardo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]