-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update activity #12: help defining an activity that executes a program #20
Conversation
""" | ||
Examples: | ||
|
||
>>> with_named_arguments('a', 'b', c=1, d=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just forbid the mix of positional arguments and named arguments? What I mean is that if the task has chosen with_named_arguments
, then all its arguments should be passed as named arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the name is ambiguous. We could only keep the behavior of with_named_arguments
but change the name of the function.
Maybe a workflow test with mixture of different kinds of tasks? |
Yes, I'm improving it by adding some validation based on the signature of the decorated function:
Each kind will have at least a test as an example. |
Ok that will be cool. |
Most tasks have arguments of builtin types (string or int). When the values come from the command line they will be strings. If the task is an actual program, it expects strings. When the task is a program that wraps a callable, the program should know how to convert the command line arguments into the types expected by the callable. Hence we need a way to declare the type of each argument of a task. |
@ggreg would protocols like |
I find protocol buffers and thrift too heavy in this context. The way to serialize and define arguments should be flexible and allow such methods. However, I prefer that we start with a simple method such as telling the type in the decorator. The main limitation here would come from nested types for example a list of integers. In this case telling We could use |
85213ce
to
6d864ef
Compare
The Travis build with pypy is failing. Python2.7 build is fine. I'm figuring out how to fix the pypy build. @ampelmann @jbbarth please review. |
LGTM ! 😎 |
except: | ||
raise ValueError('cannot load arguments from {}'.format( | ||
raw_arguments)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we have 4 arguments on the command line, we continue and will get obscure errors later, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Even with such simple interface I should have use argparse
to document how the command behave. Note that it's not excuse for this lack of rigor 😉. At first I only thought of this as a private interface to run functions as programs but it could also be used directly from the command line.
6d864ef
to
ccc469e
Compare
90e167a
to
490bd75
Compare
Parsing the history with the pypy and CPython versions led to different event types and states for child workflows. It comes from the way simple-workflow lookups the name of event types. It iterates of the keys of the |
490bd75
to
c5f5ba1
Compare
2e6d8c7
to
ec29758
Compare
Green, at last! |
ec29758
to
ae8ea60
Compare
ae8ea60
to
807cad1
Compare
Added a very short document in |
Update activity #12: help defining an activity that executes a program
Please review. Fix #20.
These changes adds the ability to define an activity that executes an external program and a helper to execute a function with another Python interpreter in a sub-process.