Skip to content
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

Support instance-based activities #72

Open
jbbarth opened this issue Dec 9, 2015 · 8 comments
Open

Support instance-based activities #72

jbbarth opened this issue Dec 9, 2015 · 8 comments
Assignees

Comments

@jbbarth
Copy link
Collaborator

jbbarth commented Dec 9, 2015

This has been discussed a little in #70 , but I open a separate issue for this. We'd like to be able to pass an object instance to Workflow.submit() directly to ease its instrumentation:

self.submit(Foo(bar))

The recent refactoring around activity tasks could help with that.

For now I have something working here: https://github.com/botify-labs/simpleflow/tree/feature/instance-based-activities but I'm not really satisfied (one more class concept, hacky generation of an Activity, "callable" still used everywhere where in fact we have an object, no automatic args/kwargs resolution, etc.). Will try to improve that later.

@jbbarth jbbarth self-assigned this Dec 9, 2015
@ybastide
Copy link
Contributor

[Speculating] Could we use metaclass thingies to defer the call to __init__ or wrap somewhat the future arguments?

@jbbarth
Copy link
Collaborator Author

jbbarth commented Dec 10, 2015

I don't know "metaclass thingies" (yet), pointer?

@ybastide
Copy link
Contributor

Sorry, no pointer found... __metaclass__, __new__, __call__ or some such things, but it's hand waving...

@jbbarth
Copy link
Collaborator Author

jbbarth commented Dec 10, 2015

Oh ok, I thought there was something special in abc or equivalent to do lazy evaluation or some other black magic. I'll read the docs about metaclasses then!

@ybastide
Copy link
Contributor

No magic, just metaprogramming :-)

It's easy, really. Just parse __init__'s arguments. If any is a Future, replace it with its result getter 😉

(I discovered a really marvelous implementation that this comment box's margin is too small to contain)

@ampelmann
Copy link
Member

@ybastide gist it ? :)

@jbbarth
Copy link
Collaborator Author

jbbarth commented Dec 10, 2015

Thanks Mr Fermat ;-) Actually I may find a smart solution with __new__, didn't know you have access to that in python!

@jbbarth
Copy link
Collaborator Author

jbbarth commented Dec 10, 2015

Arg, last problem (but not least): examples work well with ONE instance of a given task, but they'll mix up in the registry if there are two of them. We need to refine their name to include a unique ID per object. Going down the rabbit hole :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants