-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #520 from ikondov/mongomock
Optionally use mongomock instead of pymongo/mongodb
- Loading branch information
Showing
14 changed files
with
199 additions
and
23 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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
============================================= | ||
Two-minute installation, setup and quickstart | ||
============================================= | ||
|
||
Install and setup | ||
================= | ||
|
||
Supposed you have a :doc:`virtual environment </virtualenv_tutorial>` with the `pip` package installed. Then simply type:: | ||
|
||
pip install fireworks[mongomock] | ||
mkdir -p ~/.fireworks | ||
echo MONGOMOCK_SERVERSTORE_FILE: $HOME/.fireworks/mongomock.json > ~/.fireworks/FW_config.yaml | ||
echo '{}' > ~/.fireworks/mongomock.json | ||
lpad reset --password="$(date +%Y-%m-%d)" | ||
|
||
See that the database contains no workflows:: | ||
|
||
lpad get_wflows | ||
|
||
*Output*:: | ||
|
||
[] | ||
|
||
Add and display a workflow | ||
========================== | ||
|
||
Add a script that prints the date as a single firework in a workflow:: | ||
|
||
lpad add_scripts 'date' -n date_printer_firework -w date_printer_workflow | ||
|
||
Let us display the workflow just added:: | ||
|
||
lpad get_wflows -d more | ||
|
||
*Output*:: | ||
|
||
{ | ||
"state": "READY", | ||
"name": "date_printer_workflow--1", | ||
"created_on": "2024-06-07T15:05:02.096000", | ||
"updated_on": "2024-06-07T15:05:02.096000", | ||
"states": { | ||
"date_printer_firework--1": "READY" | ||
}, | ||
"launch_dirs": { | ||
"date_printer_firework--1": [] | ||
} | ||
} | ||
|
||
We have only one workflow with only one firework on the database. | ||
|
||
Run a workflow | ||
============== | ||
|
||
Now we can run the firework in our workflow locally with this simple command:: | ||
|
||
rlaunch singleshot | ||
|
||
*Output*:: | ||
|
||
2024-06-07 17:15:08,515 INFO Hostname/IP lookup (this will take a few seconds) | ||
2024-06-07 17:15:08,517 INFO Launching Rocket | ||
2024-06-07 17:15:08,608 INFO RUNNING fw_id: 1 in directory: /home/ubuntu | ||
2024-06-07 17:15:08,610 INFO Task started: ScriptTask. | ||
Fri Jun 7 17:15:08 CEST 2024 | ||
2024-06-07 17:15:08,612 INFO Task completed: ScriptTask | ||
2024-06-07 17:15:08,616 INFO Rocket finished | ||
|
||
Further steps | ||
============= | ||
|
||
This setup uses a JSON file on the local computer as a database instead of MongoDB. You can continue with the other tutorials | ||
and do local testing by using this setting. If you want to complete the more advanced tutorials, such as the | ||
:doc:`queue tutorial </queue_tutorial>`, or use FireWorks productively on a computing cluster, then you should consider | ||
:doc:`installing and setting up FireWorks </installation>` with a MongoDB server. |
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
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import os | ||
|
||
import json | ||
from glob import glob | ||
from pymongo import DESCENDING | ||
from ruamel.yaml import YAML | ||
from fireworks.core.firework import FiretaskBase | ||
from fireworks.utilities.filepad import FilePad | ||
from fireworks.utilities.dict_mods import arrow_to_dot | ||
|
||
__author__ = "Kiran Mathew, Johannes Hoermann" | ||
__email__ = "[email protected], [email protected]" | ||
|
@@ -28,7 +32,6 @@ class AddFilesTask(FiretaskBase): | |
optional_params = ["identifiers", "directory", "filepad_file", "compress", "metadata"] | ||
|
||
def run_task(self, fw_spec) -> None: | ||
from glob import glob | ||
|
||
directory = os.path.abspath(self.get("directory", ".")) | ||
|
||
|
@@ -143,19 +146,12 @@ class GetFilesByQueryTask(FiretaskBase): | |
] | ||
|
||
def run_task(self, fw_spec) -> None: | ||
import json | ||
|
||
import pymongo | ||
from ruamel.yaml import YAML | ||
|
||
from fireworks.utilities.dict_mods import arrow_to_dot | ||
|
||
fpad = get_fpad(self.get("filepad_file", None)) | ||
dest_dir = self.get("dest_dir", os.path.abspath(".")) | ||
new_file_names = self.get("new_file_names", []) | ||
query = self.get("query", {}) | ||
sort_key = self.get("sort_key", None) | ||
sort_direction = self.get("sort_direction", pymongo.DESCENDING) | ||
sort_direction = self.get("sort_direction", DESCENDING) | ||
limit = self.get("limit", None) | ||
fizzle_empty_result = self.get("fizzle_empty_result", True) | ||
fizzle_degenerate_file_name = self.get("fizzle_degenerate_file_name", True) | ||
|
Oops, something went wrong.