Skip to main content

JSON Schema for FireWorks

Project description

JSON Schema for FireWorks

This package provides a JSON schema for the FireWorks package.

Why should I use JSON schema?

The input for FireWorks is often provided in JSON or YAML formats and generated by third-party software that is unaware of the valid data types in FireWorks. Latent mismatches of data types may produce run-time errors, such as missing keywords or wrong data types, that are more difficult to handle than a validation of the initial input.

The fireworks_schema package provides a formal human- and machine-readable description of the data types used in classes in FireWorks. Additionally, a function is provided that checks the validity of JSON and YAML inputs immediately before deserialization.

Installing fireworks_schema

The recommended way to install this package into your virtual environment is using pip (in any folder):

python -m pip install fireworks-schema

Alternatively you can download a release from the GitHub repository, unpack the archive, change into the folder containing setup.py and run:

python setup.py install

After the installation you can run the tests, for example using the nose package:

nosetests fireworks_schema.tests

Using fireworks_schema to validate input for FireWorks

There are two ways to perform JSON schema validation:

  • Call the schema validator explicitly
  • Activate automatic schema validation

Call the schema validator explicitly

This is the case when you use Python but read JSON/YAML serialized objects provided externally. In the following example, a serialized workflow object is loaded from a YAML file and validated against the Workflow schema:

  import yaml
  import fireworks_schema
  from fireworks import Workflow

  with open('empty_fws.yaml', 'rt') as yf:
      dct = yaml.safe_load(yf)
  fireworks_schema.validate(dct, 'Workflow')
  wf = Workflow.from_dict(dct)

Activate automatic schema validation

To activate automatic schema validation you must specify:

  JSON_SCHEMA_VALIDATE: true

in your FWConfig file. For more details about managing your FWConfig file see the FW Config tutorial.

The default value of JSON_SCHEMA_VALIDATE is false.

If automatic validation is turned on, i.e. JSON_SCHEMA_VALIDATE is true, then validation is performed only for the classes specified in the list JSON_SCHEMA_VALIDATE_LIST, whenever an object of these classes is loaded from file. There is no default for JSON_SCHEMA_VALIDATE_LIST and therefore you must set JSON_SCHEMA_VALIDATE_LIST in your FWConfig file. For example, to turn on automatic validation for serialized Firework and Workflow objects these two lines must be added to the FWConfig file:

  JSON_SCHEMA_VALIDATE: true
  JSON_SCHEMA_VALIDATE_LIST: [Firework, Workflow]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fireworks_schema-1.1.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

fireworks_schema-1.1.0-py3-none-any.whl (68.0 kB view details)

Uploaded Python 3

File details

Details for the file fireworks_schema-1.1.0.tar.gz.

File metadata

  • Download URL: fireworks_schema-1.1.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for fireworks_schema-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9fac9f8f4b85adadd0953bfa14515febfcff486cc9f0292e84a3bb1c1fdec1a9
MD5 856a42621b32f959abde474396d0049b
BLAKE2b-256 15aea6f7783b215fb0f47b171542d1aec963b48c5294592177a6e62a27a9f600

See more details on using hashes here.

File details

Details for the file fireworks_schema-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: fireworks_schema-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 68.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for fireworks_schema-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad2414ff732b31f8c90db9f6bb20a6a8e2a478d988623bdf177f5a37a5bbd850
MD5 bd636a0ce31409318e29a4af2269da30
BLAKE2b-256 401dd4b499e07ac6a68a592d65b0317e9da299af155c4ede7fab674d9109f8ea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page