CLI Utils¶
_add_flow(project_path, name, before=None)
¶
Internal function to add a flow to an existing OneCode project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_path |
str
|
Path to the root of the OneCode project. |
required |
name |
str
|
Name of the new flow to add. Note that the name will be slugified, i-e all special
characters and whitespaces will be converted to "_". See |
required |
before |
str
|
Insert the new flow before this flow id. Set it to None to put it in last position. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
if the flow name is empty or is already used. |
_get_flow_choices(project_path)
¶
Internal function for CLI commands to get the existing OneCode project's flows as interactive Choice for InquirerPy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_path |
str
|
Path to the root of the OneCode project. |
required |
Returns:
Type | Description |
---|---|
List[Choice]
|
Flow id and label as InquirerPy Choices. |
extract_calls(entry_point, graph, calls)
¶
Given a code Call Graph, extract only the code calls related to OneCode-like elements. This
includes built-in input/output elements from OneCode and also any registered element coming from
onecode_ext
as well as derived OneCode packages. See Extending OneCode
for more information on how to register new element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry_point |
str
|
Call Graph function name from which to start the extraction from, e.g.
|
required |
graph |
Dict
|
Call Graph typically constructed by the DeepLime forked PyCG. Check out PyCG for more information about the graph structure or directly the forked repository at https://github.com/deeplime-io/PyCG/tree/onecode |
required |
calls |
List[Dict[str, str]]
|
List of calls as |
required |
get_flows(project_path)
¶
Get the flows configuration as stored at the OneCode project's root (filename is given by the
variable Env.ONECODE_CONFIG_FILE
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_path |
str
|
Path to the root of the OneCode project. |
required |
Returns:
Type | Description |
---|---|
Dict
|
The JSON content of the OneCode project flow configuration as a dictionnary. |
process_call_graph(project_path=None)
¶
Process a OneCode project to extract the code calls related to OneCode-like elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_path |
str
|
Path to the root of the OneCode project. |
None
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the OneCode project configuration file is not found. |
Returns:
Type | Description |
---|---|
OrderedDict
|
The list of OneCode-like elements code statements ready to be evaluated. |