AuthenticationTest
GridfsStoredDataTest
LaunchPadDefuseReigniteRerunArchiveDeleteTestLaunchPadDefuseReigniteRerunArchiveDeleteTest.setUp()LaunchPadDefuseReigniteRerunArchiveDeleteTest.setUpClass()LaunchPadDefuseReigniteRerunArchiveDeleteTest.tearDown()LaunchPadDefuseReigniteRerunArchiveDeleteTest.tearDownClass()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_archive_wf()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_defuse_fw()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_defuse_fw_after_completion()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_defuse_wf()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_defuse_wf_after_partial_run()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_delete_wf()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_delete_wf_and_files()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_pause_fw()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_pause_wf()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_reignite_fw()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_reignite_wf()LaunchPadDefuseReigniteRerunArchiveDeleteTest.test_rerun_fws2()LaunchPadLostRunsDetectTestLaunchPadLostRunsDetectTest.setUp()LaunchPadLostRunsDetectTest.setUpClass()LaunchPadLostRunsDetectTest.tearDown()LaunchPadLostRunsDetectTest.tearDownClass()LaunchPadLostRunsDetectTest.test_detect_lostruns()LaunchPadLostRunsDetectTest.test_detect_lostruns_defuse()LaunchPadLostRunsDetectTest.test_state_after_run_start()LaunchPadOfflineTest
LaunchPadRerunExceptionTestLaunchPadRerunExceptionTest.setUp()LaunchPadRerunExceptionTest.setUpClass()LaunchPadRerunExceptionTest.tearDown()LaunchPadRerunExceptionTest.tearDownClass()LaunchPadRerunExceptionTest.test_except_details_on_rerun()LaunchPadRerunExceptionTest.test_get_recovery_wrong_launch_id()LaunchPadRerunExceptionTest.test_task_level_rerun()LaunchPadRerunExceptionTest.test_task_level_rerun_cp()LaunchPadRerunExceptionTest.test_task_level_rerun_no_recovery_info()LaunchPadRerunExceptionTest.test_task_level_rerun_prev_dir()LaunchPadRerunExceptionTest.test_task_level_rerun_recover_launch_id()LaunchPadRerunExceptionTest.test_task_level_rerun_wrong_fw_id()LaunchPadRerunExceptionTest.test_task_level_rerun_wrong_launch_id()LaunchPadRerunExceptionTest.test_task_level_rerun_wrong_state()LaunchPadTest
WFLockTest
WorkflowFireworkStatesTestWorkflowFireworkStatesTest.setUp()WorkflowFireworkStatesTest.setUpClass()WorkflowFireworkStatesTest.tearDown()WorkflowFireworkStatesTest.tearDownClass()WorkflowFireworkStatesTest.test_archive_wf()WorkflowFireworkStatesTest.test_defuse_fw()WorkflowFireworkStatesTest.test_defuse_fw_after_completion()WorkflowFireworkStatesTest.test_defuse_wf()WorkflowFireworkStatesTest.test_reignite_fw()WorkflowFireworkStatesTest.test_reignite_wf()WorkflowFireworkStatesTest.test_rerun_fws()WorkflowFireworkStatesTest.test_rerun_timed_fws()This module contains some of the most central FireWorks classes.
A Workflow is a sequence of FireWorks as a DAG (directed acyclic graph).
A Firework defines a workflow step and contains one or more Firetasks along with its Launches.
A Launch describes the run of a Firework on a computing resource.
A FiretaskBase defines the contract for tasks that run within a Firework (Firetasks).
A FWAction encapsulates the output of a Firetask and tells FireWorks what to do next after a job completes.
Bases: FWSerializable
A FWAction encapsulates the output of a Firetask (it is returned by a Firetask after the Firetask completes). The FWAction allows a user to store rudimentary output data as well as return commands that alter the workflow.
stored_data (dict) – data to store from the run. Does not affect the operation of FireWorks.
exit (bool) – if set to True, any remaining Firetasks within the same Firework are skipped.
update_spec (dict) – specifies how to update the child FW’s spec
mod_spec ([dict]) – update the child FW’s spec using the DictMod language (more flexible than update_spec)
additions ([Workflow]) – a list of WFs/FWs to add as children
detours ([Workflow]) – a list of WFs/FWs to add as children (they will inherit the current FW’s children)
append_wfs ([dict]) – generalization of additions and detours with additional parents
defuse_children (bool) – defuse all the original children of this Firework
defuse_workflow (bool) – defuse all incomplete steps of this workflow
propagate (bool) – apply any update_spec and mod_spec modifications not only to direct children, but to all dependent FireWorks down to the Workflow’s leaves.
If the FWAction gives any dynamic action, we skip the subsequent Firetasks.
bool
Bases: FiretaskBase
Bases: defaultdict, FWSerializable, ABC
FiretaskBase is used like an abstract class that defines a computing task (Firetask). All Firetasks should inherit from FiretaskBase.
You can set parameters of a Firetask like you’d use a dict.
This method gets called when the Firetask is run. It can take in a Firework spec, perform some task using that data, and then return an output in the form of a FWAction.
fw_spec (dict) – A Firework spec. This comes from the master spec. In addition, this spec contains a special “_fw_env” key that contains the env settings of the FWorker calling this method. This provides for abstracting out certain commands or settings. For example, “foo” may be named “foo1” in resource 1 and “foo2” in resource 2. The FWorker env can specify { “foo”: “foo1”}, which maps an abstract variable “foo” to the relevant “foo1” or “foo2”. You can then write a task that uses fw_spec[“_fw_env”][“foo”] that will work across all these multiple resources.
(FWAction)
Bases: FWSerializable
A Firework is a workflow step and might be contain several Firetasks.
tasks (Firetask or [Firetask]) – a list of Firetasks to run in sequence.
spec (dict) – specification of the job to run. Used by the Firetask.
launches ([Launch]) – a list of Launch objects of this Firework.
archived_launches ([Launch]) – a list of archived Launch objects of this Firework.
state (str) – the state of the FW (e.g. WAITING, RUNNING, COMPLETED, ARCHIVED)
created_on (datetime) – time of creation
fw_id (int) – an identification number for this Firework.
parents (Firework or [Firework]) – list of parent FWs this FW depends on.
updated_on (datetime) – last time the STATE was updated.
Returns: str: The current state of the Firework.
Return firework dict with updated launches and state.
Bases: FWSerializable
A Launch encapsulates data about a specific run of a Firework on a computing resource.
state (str) – the state of the Launch (e.g. RUNNING, COMPLETED)
launch_dir (str) – the directory where the Launch takes place
fworker (FWorker) – The FireWorker running the Launch
host (str) – the hostname where the launch took place (set automatically if None)
ip (str) – the IP address where the launch took place (set automatically if None)
trackers ([Tracker]) – File Trackers for this Launch
action (FWAction) – the output of the Launch
state_history ([dict]) – a history of all states of the Launch and when they occurred
launch_id (int) – launch_id set by the LaunchPad
fw_id (int) – id of the Firework this Launch is running.
Returns: datetime: the time the Launch last pinged a heartbeat that it was still running.
Returns: int: number of seconds the Launch was stuck as RESERVED in a queue.
Returns: int: the number of seconds that the Launch ran for.
Returns: str: The current state of the Launch.
Returns: datetime: the time the Launch was COMPLETED or FIZZLED.
Returns: datetime: the time the Launch was RESERVED in the queue.
Returns: datetime: the time the Launch started RUNNING.
Bases: FWSerializable
A Tracker monitors a file and returns the last N lines for updating the Launch object.
Bases: FWSerializable
A Workflow connects a group of FireWorks in an execution order.
Bases: dict, FWSerializable
An inner class for storing the DAG links between FireWorks.
Return list of all nodes.
Return a dict of child and its parents.
Note: if performance of parent_links becomes an issue, override delitem/setitem to update parent_links
Convert to str form for Mongo, which cannot have int keys .
dict
Convert to str form for Mongo, which cannot have int keys.
dict
fireworks ([Firework]) – all FireWorks in this workflow.
links_dict (dict) – links between the FWs as (parent_id):[(child_id1, child_id2)]
name (str) – name of workflow.
metadata (dict) – metadata for this Workflow.
created_on (datetime) – time of creation
updated_on (datetime) – time of update
fw_states (dict) – leave this alone unless you are purposefully creating a Lazy-style WF.
ValueError – when Firework IDs are duplicated or inconsistent, or links dictionary is invalid
Method to add a workflow as a child to a Firework Note: detours must have children that have STATE_RANK that is WAITING or below.
list of Firework ids that were updated or new.
TypeError – when detour is not boolean
ValueError – when detour or fw_ids inputs are invalid
Apply a FWAction on a Firework in the Workflow.
list of Firework ids that were updated or new.
ValueError – when duplicated Firework IDs are found in additions or detours
Return Workflow from its dict representation.
m_dict (dict) – either a Workflow dict or a Firework dict
Workflow
Return Workflow from the given Firework.
Create a fresh Workflow from an existing one.
wflow (Workflow)
Workflow
Refreshes the state of a Firework and any affected children.
Remove the fireworks corresponding to the input firework ids and update the workflow i.e the parents of the removed fireworks become the parents of the children fireworks (only if the children dont have any other parents).
fw_ids (list) – list of fw ids to remove.
Archives the launches of a Firework so that it can be re-run.
Reset the states of all Fireworks in this workflow to ‘WAITING’.
reset_ids (bool) – if True, give each Firework a new id.
This module contains FireWorker, which encapsulates information about a computing resource.
Bases: FWSerializable
name (str) – the name of the resource, should be unique
category (str or [str]) – a String describing a specific category of job to pull, does not need to be unique. If the FWorker should pull jobs of multiple categories, use a list of str.
query (dict) – a dict query that restricts the type of Firework this resource will run
env (dict) – a dict of special environment variables for the resource.
This env is passed to running Firetasks as a _fw_env in the
fw_spec, which provides for abstraction of resource-specific
commands or settings. See fireworks.core.firework.FiretaskBase
for information on how to use this env variable in Firetasks.
Returns FWorker object from settings file(my_fworker.yaml).
Returns updated query dict.
The LaunchPad manages the FireWorks database.
Bases: FWSerializable
The LaunchPad manages the FireWorks database.
host (str) – hostname. If uri_mode is True, a MongoDB connection string URI (https://docs.mongodb.com/manual/reference/connection-string/) can be used instead of the remaining options below.
port (int) – port number
name (str) – database name
username (str)
password (str)
logdir (str) – path to the log directory
strm_lvl (str) – the logger stream level
user_indices (list) – list of ‘fireworks’ collection indexes to be built
wf_user_indices (list) – list of ‘workflows’ collection indexes to be built
authsource (str) – authSource parameter for MongoDB authentication; defaults to “name” (i.e., db name) if not set
uri_mode (bool) – if set True, all Mongo connection parameters occur through a MongoDB URI string (set as the host).
mongoclient_kwargs (dict) – A list of any other custom keyword arguments to be passed into the MongoClient connection. Use these kwargs to specify SSL/TLS or serverSelectionTimeoutMS arguments. Note these arguments are different depending on the major pymongo version used; see pymongo documentation for more details.
Add the launch and firework to the offline_run collection.
Add workflow(or firework) to the launchpad. The firework ids will be reassigned.
Append a new workflow on top of an existing workflow.
new_wf (original children of the parent fw_ids to the) – The new workflow to append
fw_ids ([int]) – The parent fw_ids at which to append the workflow
detour (bool) – Whether to connect the new Workflow in a “detour” style, i.e., move
new_wf
pull_spec_mods (bool) – Whether the new Workflow should pull the FWActions of the parent fw_ids
Archive the workflow containing the given firework id.
fw_id (int) – firework id
Adds a list of workflows to the fireworks database using insert_many for both the fws and wfs, is more efficient than adding them one at a time.
wfs ([Workflow]) – list of workflows or fireworks
None
Given the launch id, cancel the reservation and rerun the fireworks.
Given the reservation id, cancel the reservation and rerun the corresponding fireworks.
Change the launch directory corresponding to the given launch id.
Checkout the next ready firework, mark it with the given state(RESERVED or RUNNING) and return it to the caller. The caller is responsible for running the Firework.
fworker (FWorker) – A FWorker instance
launch_dir (str) – the dir the FW will be run in (for creating a Launch object)
fw_id (int) – Firework id
host (str) – the host making the request (for creating a Launch object)
ip (str) – the ip making the request (for creating a Launch object)
state (str) – RESERVED or RUNNING, the fetched firework’s state will be set to this value.
firework and the new launch id.
Internal method used to mark a Firework’s Launch as completed.
Given the firework id, defuse the firework and refresh the workflow.
Defuse the workflow containing the given firework id.
Delete a set of fireworks identified by their fw_ids.
ATTENTION: This function serves maintenance purposes and will leave workflows untouched. Its use will thus result in a corrupted database. Use ‘delete_wf’ instead for consistently deleting workflows together with their fireworks.
Delete the workflow containing firework with the given id.
delete_launch_dirs
Detect lost runs i.e running fireworks that haven’t been updated within the specified time limit or running firework whose launch has been marked fizzed or completed.
This method uses batch queries and aggregation pipelines for optimal performance with large databases.
expiration_secs (seconds) – expiration time in seconds
fizzle (bool) – if True, mark the lost runs fizzed
rerun (bool) – if True, mark the lost runs fizzed and rerun
max_runtime (seconds) – maximum run time
min_runtime (seconds) – minimum run time
refresh (bool) – if True, refresh the workflow with inconsistent fireworks.
query (dict) – restrict search to FWs matching this query
launch_query (dict) – restrict search to launches matching this query (e.g. host restriction)
inconsistent firework ids.
Return the reserved launch ids that have not been updated for a while.
Unmark the offline run for the given launch or firework id.
Check if database has any current OR future Fireworks available.
True if database has any ready or waiting Fireworks.
Given a Firework id, give back a Firework object.
fw_id (int) – Firework id.
Firework object
Given firework id, return firework dict.
fw_id (int) – Firework id.
dict
ValueError – in case of invalid fw_ids
Return all the fw ids that match a query.
list of firework ids matching the query
Given the reservation id, return the list of firework ids.
Return all fw ids that match fw_query within workflows that match wf_query.
wf_query (dict) – representing a Mongo query on workflows
fw_query (dict) – representing a Mongo query on Fireworks
[ (sort) – sort argument in Pymongo format
limit (int) – limit the results
count_only (bool) – only return the count rather than explicit ids
launches_mode (bool) – query the launches collection instead of fireworks
list of firework ids matching the query
Given a Launch id, return details of the Launch.
launch_id (int) – launch id.
Launch object
ValueError – in case of invalid launch_id
Returns the directory of the most recent launch of a fw_id :param fw_id: (int) fw_id to get launch id for :param launch_idx: (int) index of the launch to get. Default is -1, which is most recent.
Return the log directory.
AJ: This is needed for job packing due to Proxy objects not being fully featured…
Checkout the next Firework id.
quantity (int) – optionally ask for many ids, otherwise defaults to 1 this then returns the first fw_id in that range
ValueError – if next Firework id cannot be found
Checkout the next Launch id.
Function to get recovery data for a given launch.
launch_id (int) – launch_id to get recovery data for
recovery metadata, None when no recovery retrieved
recovery (dict)
ValueError – raised when no launch under the the launch_id is found
Given the firework id, return the reservation id.
fw_id (id) – firework id.
list tracker dicts
[dict]
Given a Firework id, give back the Workflow containing that Firework.
fw_id (int) – Firework id.
A Workflow object
ValueError – in case of invalid fw_id
Given a FireWork id, give back the Workflow containing that FireWork.
fw_id (int) – FireWork id.
A Workflow object
ValueError – in case of invalid fw_id
Return one fw id for all workflows that match a query.
A much faster way to get summary information about a Workflow by querying only for needed information.
Perform launchpad maintenance: detect lost runs and unreserved RESERVE launches.
infinite (bool)
maintain_interval (seconds) – sleep time
Given the firework id, pauses the firework and refresh the workflow.
fw_id (int) – firework id
Pause the workflow containing the given firework id.
fw_id (int) – firework id
Ping that a Launch is still alive: updates the ‘update_on ‘field of the state history of a Launch.
launch_id (int)
ptime (datetime)
Update the launch state using the offline data in FW_offline.json file.
Given the firework id, re-ignite(set state=WAITING) the defused firework.
fw_id (int) – firework id
Reignite the workflow containing the given firework id.
fw_id (int) – firework id
Rerun the firework corresponding to the given id.
fw_id (int) – firework id
rerun_duplicates (bool) – flag for whether duplicates should be rerun
recover_launch ('last' or int) – launch_id for last recovery, if set to ‘last’ (default), recovery will find the last available launch. If it is an int, will recover that specific launch
recover_mode ('prev_dir' or 'cp') – flag to indicate whether to copy or run recovery fw in previous directory
list of firework ids that were rerun
[int]
ValueError – raised in case of firework, recover_launch or recovery info not found
Checkout the next ready firework and mark the launch reserved.
Create a new FireWorks database. This will overwrite the existing FireWorks database! To safeguard against accidentally erasing an existing database, a password must be entered.
password (str) – A String representing today’s date, e.g. ‘2012-12-31’
require_password (bool) – Whether a password is required to reset the DB. Setting to false is dangerous because running code unintentionally could clear your DB - use max_reset_wo_password to minimize risk.
max_reset_wo_password (int) – A failsafe; when require_password is set to False, FWS will not clear DBs that contain more workflows than this parameter
ValueError – in case of invalid password or failed password override
For the given launch id and firework id, restore the back up data.
Given the firework id, resume (set state=WAITING) the paused firework.
fw_id (int) – firework id
Checks to see if the database contains any FireWorks that are ready to run.
True if the database contains any FireWorks that are ready to run.
Set priority to the firework with the given id.
fw_id (int) – firework id
priority
Set reservation id to the launch corresponding to the given launch id.
Note: usernames/passwords are exported as unencrypted Strings!
Update fireworks with a spec. Sometimes you need to modify a firework in progress.
[int] (fw_ids) – All fw_ids to modify.
spec_document (dict) – The spec document. Note that only modifications to the spec key are allowed. So if you supply {“_tasks.1.parameter”: “hello”}, you are effectively modifying spec._tasks.1.parameter in the actual fireworks collection.
mongo (bool) – spec_document uses mongo syntax to directly update the spec
Bases: object
A LazyFirework only has the fw_id, and retrieves other data just-in-time. This representation can speed up Workflow loading as only “important” FWs need to be fully loaded.
fw_id (int) – firework id
fw_coll (pymongo.collection) – fireworks collection
launch_coll (pymongo.collection) – launches collection.
Bases: ValueError
Error raised if the context manager WFLock can’t acquire the lock on the WF within the selected time interval (WFLOCK_EXPIRATION_SECS), if the killing of the lock is disabled (WFLOCK_EXPIRATION_KILL).
Bases: object
Lock a Workflow, i.e. for performing update operations Raises a LockedWorkflowError if the lock couldn’t be acquired within expire_secs and kill==False. Calling functions are responsible for handling the error in order to avoid database inconsistencies.
Helper function to obtain the correct dictionary of the FWAction associated with a launch. If necessary retrieves the information from gridfs based on its identifier, otherwise simply returns the dictionary in input. Should be used when accessing a launch to ensure the presence of the correct action dictionary.
Build sorting aggregation pipeline.
[ (sort) – sorting keys and directions as a list of (str, int) tuples, i.e. [(‘updated_on’, 1)]
A Rocket fetches a Firework from the database, runs the sequence of Firetasks inside, and then completes the Launch.
Bases: object
The Rocket fetches a workflow step from the FireWorks database and executes it.
Run the rocket (check out a job from the database and execute it).
True if the rocket ran successfully, False is if it failed or no job in the DB was ready to run.
OSError – when creation of launch directory fails
This module contains methods for launching Rockets, both singly and in rapid-fire mode.
Run a single rocket in the current directory.
launchpad (LaunchPad)
fworker (FWorker)
fw_id (int) – if set, a particular Firework to run
strm_lvl (str) – level at which to output logs to stdout
pdb_on_exception (bool) – if True, Python will start the debugger on a firework exception
err_file (file object) – file to which stderr is redirected; None for no redirect
bool
Keeps running Rockets in m_dir until we reach an error. Automatically creates subdirectories for each Rocket. Usually stops when we run out of FireWorks from the LaunchPad.
launchpad (LaunchPad)
fworker (FWorker object)
m_dir (str) – the directory in which to loop Rocket running
nlaunches (int) – 0 means ‘until completion’, -1 or “infinite” means to loop until max_loops
max_loops (int) – maximum number of loops (default -1 is infinite)
sleep_time (int) – secs to sleep between rapidfire loop iterations
strm_lvl (str) – level at which to output logs to stdout
timeout (int) – of seconds after which to stop the rapidfire process
local_redirect (bool) – redirect standard output and standard error to local files
pdb_on_exception (bool) – if True, python will start the debugger on a firework exception