Interface for creating and running a project.
Contents
Project: the universal interface for chrisjen projects.
Project(name, id, automatic, library, clerk, idea, workflow=None, report=None, item=None)
dataclass
¶
Creates a workflow from settings and applies it.
A project moves through two stages:
draft: the settings (idea) are turned into aworkflow.apply: the workflow is applied to an item.
Creating a Project drafts it. If automatic is True, the project is
also applied.
Use the create class method to create a Project instance unless you are
passing all the arguments to the Project instance. The create method
is more flexible and converts datatypes, validates arguments, and loads
appropriate files and classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
name of the project. |
required |
id
|
str
|
unique name for this run of the project. |
required |
automatic
|
bool
|
whether to apply the project as soon as it is created. |
required |
library
|
Library
|
library of the classes used to build the workflow. |
required |
clerk
|
FileManager
|
file manager for the project's files. |
required |
idea
|
Idea
|
settings that describe the project. |
required |
workflow
|
Worker | None
|
the workflow of the project. Defaults to |
None
|
report
|
Report | None
|
report generated after the project is applied. Defaults to
|
None
|
item
|
Any
|
data or object that the workflow is applied to. Defaults to
|
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
result |
Any
|
the result of the last call to |
result = dataclasses.field(default=None, init=False, repr=False)
class-attribute
instance-attribute
¶
Initialization Methods
apply(item=None, **kwargs)
¶
Applies the workflow to item and generates the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Any
|
data or object to change. Defaults to |
None
|
**kwargs
|
Any
|
keyword arguments passed to the nodes in the workflow. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The result of the workflow, which is also stored in |
Source code in src/chrisjen/interface.py
create(idea, *, name=None, id=None, automatic=True, library=base.library, clerk=None, **kwargs)
classmethod
¶
Creates a project.
Every argument after idea must be passed by keyword.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idea
|
Idea | MutableMapping[str, Any] | Path | str
|
settings that describe the project: an |
required |
name
|
str | None
|
name of the project. Defaults to |
None
|
id
|
str | None
|
unique name for this run. Defaults to |
None
|
automatic
|
bool
|
whether to apply the project as soon as it is created.
Defaults to |
True
|
library
|
Library
|
library of the classes used to build the workflow.
Defaults to |
library
|
clerk
|
FileManager | Path | str | None
|
file manager, or the root folder for one. Defaults to
|
None
|
**kwargs
|
Any
|
other arguments for |
{}
|
Returns:
| Type | Description |
|---|---|
Project
|
A |
Source code in src/chrisjen/interface.py
draft()
¶
to_dot(path=None, name=None)
¶
Returns the workflow as a Graphviz dot str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str | None
|
file to save the text to. Defaults to |
None
|
name
|
str | None
|
name of the graph. Defaults to the name of the project. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The dot text. |
Source code in src/chrisjen/interface.py
to_mermaid(path=None, name=None)
¶
Returns the workflow as a mermaid flowchart str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str | None
|
file to save the text to. Defaults to |
None
|
name
|
str | None
|
name of the chart. Defaults to the name of the project. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The mermaid text. |