-
Notifications
You must be signed in to change notification settings - Fork 123
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
Add python code block to workflows
#509
Conversation
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.
This looks pretty epic.
inference/core/workflows/execution_engine/dynamic_blocs/block_scaffolding.py
Outdated
Show resolved
Hide resolved
WorkflowBlockManifest, | ||
) | ||
|
||
IMPORTS_LINES = [ |
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.
If your custom code block needs other available dependencies (eg time, json, os, requests, cv2, shapely, our CLIP Model, etc) is there a way to add them to the import list?
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.
one may import more in the string with python code, like:
import cv2
# any other import
def function(x, y, z):
pass
we could also extend the imports, yet for instance CLIP
should probably be used via model manager as manual init in multiple blocks may end up OOM on multiple instances on the same model. We can obviously add more imports which I will do, the question is what we suggest people regarding model usage - I believe it would be better to suggest using models within existing blocks if possible and only use model in-place when there is no other option
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.
ok, added separate field in manifest to declare optional imports - that is going to give us more visibility
description="Definition of manifest for dynamic block to be created in runtime by " | ||
"workflows execution engine." | ||
) | ||
code: PythonCode = Field( |
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.
Probably also needs an init function
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.
👍 changed the way how it will work to have init function and run function with self
injected as first param which would have access to self._init_results
description="Accepted dimensionality offset for parameter. Dimensionality works the same as for " | ||
"traditional workflows blocks.", | ||
) | ||
selector_types: List[SelectorType] = Field( |
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.
How do you accept an image (whether it be an output of a previous step or an input to the workflow)?
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.
u choose union of
class SelectorType(Enum):
INPUT_IMAGE = "input_image"
INPUT_PARAMETER = "input_parameter"
STEP_OUTPUT = "step_output"
which is almost 1-1 mapping to types: WorkflowImageSelector
, WorkflowParameterSelector
, StepOutputSelector
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.
This looks good to me 🔥
(but going to wait for someone else to give the official ✅)
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.
lgtm, discussed/reviewed on tuple/zoom
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.
Probably the file name should be test_dimension_collapse.py
Description
This is the preview of custom python code block in
workflows
- so far implemented quite ugly - but showcasing what will be possible.Methodology:
init()
function to define state)"steps"
listPOST /workflows/blocks/describe
which takes optional payload with list of blocks - once it is done -dynamic blocks schemas and connections are generated into output -GET /workflows/blocks/describe
remained, yet deprecated to be removed laterGET /workflows/blocks/describe
andPOST /workflows/blocks/describe
will return OpenAPI schema for manifest of dynamic blockType of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
Any specific deployment considerations
Docs