Commit e3841fc5 authored by davidwaroquiers's avatar davidwaroquiers
Browse files

Part 1 of the tuto.

parent c766ace1
%% Cell type:markdown id:northern-young tags:
# Five-minute quickstart
In this quickstart, you will:
* Add a simple workflow to the central database via the command line
* Run that workflow
* Monitor your job status with the FireWorks database
* Get a flavor of the Python API
## Start FireWorks
A MongoDB database (containing the FireWorks database) is running in your docker.
Reset/Initialize the FireWorks database (the LaunchPad) using the command line:
```lpad reset```
Note: All FireWorks commands come with built-in help. For example, type lpad -h or lpad reset -h. There often exist many different options for each command.
Note2: Resetting the FireWorks removes all your workflows and jobs from your database. During this tutorial, you may use this "often" but when you are in production and actually using FireWorks, you will most likely almost never use this reset.
## Add a Workflow
There are many ways to add Workflows to the database, including a Python API. Let’s start with an extremely simple example that can be added via the command line:
%% Cell type:code id:amended-jimmy tags:
``` python
!lpad add_scripts 'echo "hello"' 'echo "goodbye"' -n hello goodbye -w test_workflow
%% Cell type:markdown id:necessary-potato tags:
This added a two-job linear workflow. The first jobs prints hello to the command line, and the second job prints goodbye. We gave names (optional) to each step as “hello” and “goodbye”. We named the workflow overall (optional) as “test_workflow”.
Let’s look at our test workflow:
%% Cell type:code id:opponent-strip tags:
``` python
!lpad get_wflows -n test_workflow -d more
%% Cell type:markdown id:deadly-gravity tags:
We get back basic information on our workflows. The second step “goodbye” is waiting for the first one to complete; it is not ready to run because it depends on the first job.
## Run all Workflows
You can run jobs one at a time (“singleshot”) or all at once (“rapidfire”). Let’s run all jobs:
%% Cell type:code id:destroyed-flooring tags:
``` python
!rlaunch rapidfire
%% Cell type:markdown id:pressing-spiritual tags:
Clearly, both steps of our workflow ran in the correct order.
Let’s again look at our workflows:
%% Cell type:code id:presidential-macintosh tags:
``` python
!lpad get_wflows -n test_workflow -d more
%% Cell type:markdown id:designing-bruce tags:
FireWorks automatically created launcher_ directories for each step in the Workflow and ran them. We see that both steps are complete. Note that there exist options to choose where to run jobs, as well as to tear down empty directories after running jobs.
## Look at the web GUI
If you have a web browser, you can launch the web GUI to see your workflows using ```lpad webgui```. In this tutorial, the web GUI is directly integrated in the jupyter:
## Python code
The following Python code achieves the same behavior:
%% Cell type:code id:black-avatar tags:
``` python
from fireworks import Firework, Workflow, LaunchPad, ScriptTask
from fireworks.core.rocket_launcher import rapidfire
# set up the LaunchPad and reset it
launchpad = LaunchPad.auto_load()
launchpad.reset('', require_password=False)
# create the individual FireWorks and Workflow
fw1 = Firework(ScriptTask.from_str('echo "hello"'), name="hello")
fw2 = Firework(ScriptTask.from_str('echo "goodbye"'), name="goodbye")
wf = Workflow([fw1, fw2], {fw1:fw2}, name="test workflow")
# store workflow and launch it locally
- _fw_name: ScriptTask
script: echo "howdy, your job launched successfully!" >> howdy.txt
\ No newline at end of file