fireworks.tests package — FireWorks 2.0.4 documentation

# fireworks.tests package

## Submodules

## fireworks.tests.master_tests module

Master tests for FireWorks - generally used to ensure that installation was completed properly.

class fireworks.tests.master_tests.BasicTests(methodName='runTest')

  Bases: `TestCase`

  Make sure that required external libraries can be imported.

  test_fwconnector() → None
  test_parent_connector() → None

class fireworks.tests.master_tests.SerializationTests(methodName='runTest')

  Bases: `TestCase`

  static get_data(obj_dict)
  test_recursive_deserialize() → None
  test_serialization_details() → None

class fireworks.tests.master_tests.TestImports(methodName='runTest')

  Bases: `TestCase`

  Make sure that required external libraries can be imported.

  test_imports() → None

## fireworks.tests.mongo_tests module

class fireworks.tests.mongo_tests.AppendWFActionTask(*args, **kwargs)

  Bases: `FiretaskBase`

  required_params = ['fw_name', 'tag', 'val', 'inputs', 'output', 'parents']
  run_task(fw_spec)

    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.

    Parameters:

      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.

    Returns:

      (FWAction)

class fireworks.tests.mongo_tests.ModSpecTask(*args, **kwargs)

  Bases: `FiretaskBase`

  run_task(fw_spec)

    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.

    Parameters:

      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.

    Returns:

      (FWAction)

class fireworks.tests.mongo_tests.MongoTests(methodName='runTest')

  Bases: `TestCase`

  setUp() → None

    Hook method for setting up the test fixture before exercising it.

  classmethod setUpClass() → None

    Hook method for setting up class fixture before running tests in the class.

  tearDown() → None

    Hook method for deconstructing the test fixture after testing it.

  classmethod tearDownClass() → None

    Hook method for deconstructing the class fixture after running all tests in the class.

  test_add_fw() → None
  test_add_lp_and_fw_id() → None
  test_append_wf() → None
  test_append_wf_detour() → None
  test_append_wf_detour_two_parents() → None

    Test the append_wf with one detour and two parents.

  test_append_wfs_action() → None

    Test the new append_wfs action.

  test_archive() → None
  test_backgroundtask() → None
  test_basic_fw() → None
  test_basic_fw_offline() → None
  test_category() → None
  test_category_pt2() → None
  test_defuse() → None
  test_delete_fw() → None
  test_dupefinder() → None
  test_duplicate_delete_fw() → None
  test_fibadder() → None
  test_files_in_out() → None
  test_fizzle() → None
  test_force_lock_removal() → None
  test_fw_env() → None
  test_job_info() → None
  test_multi_detour() → None
  test_multi_fw() → None
  test_multi_fw_complex() → None
  test_offline_fw_passinfo() → None
  test_org_wf() → None
  test_parallel_fibadder() → None
  test_preserve_fworker() → None
  test_spec_copy() → None
  test_stats() → None

class fireworks.tests.mongo_tests.MultipleDetourTask(*args, **kwargs)

  Bases: `FiretaskBase`

  run_task(fw_spec)

    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.

    Parameters:

      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.

    Returns:

      (FWAction)

class fireworks.tests.mongo_tests.SummationTask(*args, **kwargs)

  Bases: `FiretaskBase`

  required_params = ['inputs', 'output']
  run_task(fw_spec)

    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.

    Parameters:

      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.

    Returns:

      (FWAction)

class fireworks.tests.mongo_tests.UpdateSpecTask(*args, **kwargs)

  Bases: `FiretaskBase`

  run_task(fw_spec)

    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.

    Parameters:

      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.

    Returns:

      (FWAction)

fireworks.tests.mongo_tests.random_launch(lp_creds) → None

fireworks.tests.mongo_tests.throw_error(msg) → NoReturn

## fireworks.tests.multiprocessing_tests module

class fireworks.tests.multiprocessing_tests.TestCheckoutFW(methodName='runTest')

  Bases: `TestCase`

  lp = None
  setUp() → None

    Hook method for setting up the test fixture before exercising it.

  classmethod setUpClass() → None

    Hook method for setting up class fixture before running tests in the class.

  tearDown() → None

    Hook method for deconstructing the test fixture after testing it.

  classmethod tearDownClass() → None

    Hook method for deconstructing the class fixture after running all tests in the class.

  test_checkout_fw() → None

class fireworks.tests.multiprocessing_tests.TestEarlyExit(methodName='runTest')

  Bases: `TestCase`

  lp = None
  setUp() → None

    Hook method for setting up the test fixture before exercising it.

  classmethod setUpClass() → None

    Hook method for setting up class fixture before running tests in the class.

  tearDown() → None

    Hook method for deconstructing the test fixture after testing it.

  classmethod tearDownClass() → None

    Hook method for deconstructing the class fixture after running all tests in the class.

  test_early_exit() → None

class fireworks.tests.multiprocessing_tests.TestLinks(methodName='runTest')

  Bases: `TestCase`

  test_pickle() → None

## fireworks.tests.tasks module

TODO: Modify module doc.

class fireworks.tests.tasks.DummyFWEnvTask(*args, **kwargs)

  Bases: `FiretaskBase`

  run_task(fw_spec)

    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.

    Parameters:

      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.

    Returns:

      (FWAction)

class fireworks.tests.tasks.DummyJobPassTask(*args, **kwargs)

  Bases: `FiretaskBase`

  run_task(fw_spec)

    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.

    Parameters:

      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.

    Returns:

      (FWAction)

class fireworks.tests.tasks.DummyLPTask(*args, **kwargs)

  Bases: `FiretaskBase`

  run_task(fw_spec)

    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.

    Parameters:

      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.

    Returns:

      (FWAction)

## fireworks.tests.test_deserialization module

Tests for deserialization failures and DB env var override behavior.

class fireworks.tests.test_deserialization.FakeBadTask

  Bases: `object`

  Minimal task-like stub whose serialization points to a non-existent class/module.

  to_dict() → dict[str, Any]

    Return a bogus _fw_name that will fail deserialization.

fireworks.tests.test_deserialization.lpad() → Generator[LaunchPad, None, None]

  Create a clean test database, yield LaunchPad, then drop the database.

fireworks.tests.test_deserialization.test_fizzle_on_deserialization_failure(lpad: LaunchPad, tmp_path) → None

  Test basic deserialization failure handling.

  Verifies that a FW whose task cannot be deserialized is marked FIZZLED and that exception details are recorded in the spec for debugging. Tests firework-level behavior.

fireworks.tests.test_deserialization.test_queue_skips_bad_and_runs_next(lpad: LaunchPad, tmp_path) → None

  Test queue behavior with deserialization failures.

  Verifies that if the top-priority FW fails to deserialize, it is marked as FIZZLED and the queue doesn’t get stuck—it moves on to process the next available FW. Ensures the queue remains operational despite bad FWs.

fireworks.tests.test_deserialization.test_workflow_state_updated_on_deserialization_failure(lpad: LaunchPad, tmp_path) → None

  Test database consistency after deserialization failures.

  Verifies that when a FW fails deserialization, the workflow collection is properly updated with both workflows.state=”FIZZLED” and workflows.fw_states.{fw_id}=”FIZZLED”. Uses direct MongoDB queries (not LaunchPad API) to ensure _refresh_wf() correctly updates both fields, preventing database inconsistencies.

## fireworks.tests.test_fw_config module

class fireworks.tests.test_fw_config.ConfigTest(methodName='runTest')

  Bases: `TestCase`

  test_config() → None

class fireworks.tests.test_fw_config.FWConfigTest(methodName='runTest')

  Bases: `TestCase`

  Tests for the fw_config module.

  setUp()

    Hook method for setting up the test fixture before exercising it.

  tearDown()

    Hook method for deconstructing the test fixture after testing it.

  test_override_user_settings_empty_yaml() → None

    Test with empty fw_config file.

  test_override_user_settings_invalid_key() → None

    Test fw_config file with invalid key.

## fireworks.tests.test_workflow module

class fireworks.tests.test_workflow.TestWorkflowState(methodName='runTest')

  Bases: `TestCase`

  test_archived() → None
  test_completed() → None
  test_defused() → None
  test_fizzled_1() → None
  test_fizzled_2() → None
  test_fizzled_3() → None
  test_fizzled_4() → None
  test_fizzled_5() → None
  test_fizzled_6() → None
  test_paused() → None
  test_ready() → None
  test_reserved() → None
  test_running_1() → None
  test_running_2() → None

## Module contents