-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 397-workflow-tutorial
- Loading branch information
Showing
28 changed files
with
541 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ slug: /cli-usage | |
|
||
#### Execute a job, run a workflow, adjust logging, maintain adaptors, and save the state. | ||
|
||
You're probably here to run jobs (expressions) or workflows, which the CLI makes | ||
easy. Keep reading for an outline of the basic usage scenarios of the CLI. | ||
You're probably here to run steps (expressions) or workflows, which the CLI | ||
makes easy. Keep reading for an outline of the basic usage scenarios of the CLI. | ||
|
||
--- | ||
|
||
|
@@ -17,25 +17,24 @@ To run a single job, you must explicitly specify which adaptor to use. You can | |
find the list of publicly available [adaptors here](/adaptors). See examples | ||
below. | ||
|
||
> Pass the `-i` flag to auto-install that adaptor (it's safe to do this | ||
> redundantly). | ||
> Adaptors are auto-installed if the specified version is not detected. | ||
**Use a shorthand (e.g., `http`):** | ||
|
||
```bash | ||
openfn path/to/job.js -ia http | ||
openfn path/to/job.js -a http | ||
``` | ||
|
||
**Use the full package name (e.g., `@openfn/language-http`):** | ||
|
||
```bash | ||
openfn path/to/job.js -ia @openfn/language-http | ||
openfn path/to/job.js -a @openfn/language-http | ||
``` | ||
|
||
**Add a specific version:** | ||
|
||
```bash | ||
openfn path/to/job.js -ia [email protected] | ||
openfn path/to/job.js -a [email protected] | ||
``` | ||
|
||
**Pass a path to a locally installed adaptor:** | ||
|
@@ -54,15 +53,15 @@ it creates an `output.json` next to the job file. | |
**You can specify custom paths for the output and state files:** | ||
|
||
```bash | ||
openfn path/to/job.js -ia adaptor-name -o path/to/output.json -s path/to/state.json | ||
openfn path/to/job.js -a adaptor-name -o path/to/output.json -s path/to/state.json | ||
``` | ||
|
||
### Return resulting state through stdout | ||
|
||
**Use `-O` to return the output through stdout:** | ||
|
||
```bash | ||
openfn path/to/job.js -ia adaptor-name -O | ||
openfn path/to/job.js -a adaptor-name -O | ||
``` | ||
|
||
--- | ||
|
@@ -98,7 +97,7 @@ export OPENFN_REPO_DIR=/path/to/repo | |
**Auto-install adaptors and check if a matching version is found in the repo:** | ||
|
||
```bash | ||
openfn path/to/job.js -ia adaptor-name | ||
openfn path/to/job.js -a adaptor-name | ||
``` | ||
|
||
**Remove all adaptors from the repo:** | ||
|
@@ -116,25 +115,31 @@ openfn repo clean | |
|
||
```json | ||
{ | ||
"start": "a", // optionally specify the start node (defaults to jobs[0]) | ||
"jobs": [ | ||
{ | ||
"id": "a", | ||
"expression": "fn((state) => state)", // code or a path | ||
"adaptor": "@openfn/[email protected]", // specifiy the adaptor to use (version optional) | ||
"data": {}, // optionally pre-populate the data object (this will be overriden by keys in in previous state) | ||
"configuration": {}, // Use this to pass credentials | ||
"next": { | ||
// This object defines which jobs to call next | ||
// All edges returning true will run | ||
// If there are no next edges, the workflow will end | ||
"b": true, | ||
"c": { | ||
"condition": "!state.error" // Note that this is an expression, not a function | ||
"options": { | ||
"start": "a" // optionally specify the start node (defaults to steps[0]) | ||
}, | ||
"workflows": { | ||
"steps": [ | ||
{ | ||
"id": "a", | ||
"expression": "fn((state) => state)", // code or a path | ||
"adaptor": "@openfn/[email protected]", // specifiy the adaptor to use (version optional) | ||
"state": { | ||
"data": {} // optionally pre-populate the data object (this will be overriden by keys in in previous state) | ||
}, | ||
"configuration": {}, // Use this to pass credentials | ||
"next": { | ||
// This object defines which steps to call next | ||
// All edges returning true will run | ||
// If there are no next edges, the workflow will end | ||
"b": true, | ||
"c": { | ||
"condition": "!state.error" // Note that this is an expression, not a function | ||
} | ||
} | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
``` | ||
|
||
|
@@ -143,7 +148,7 @@ openfn repo clean | |
**To run a workflow:** | ||
|
||
```bash | ||
openfn path/to/workflow.json -i | ||
openfn path/to/workflow.json -o tmp/output.json | ||
``` | ||
|
||
Check out this detailed [tutorial](cli-walkthrough#7-running-workflows) on | ||
|
Oops, something went wrong.