Skip to main content

NiPype-1 workflow serializer.

Project description

flowdump

Build codecov Code style: black L-GPL License

NiPype-1 workflow serializer for use with flowview.

Installation

flowdump is available on PyPI and can be installed with pip:

pip install flowdump

Usage

Using flowdump is as simple as calling run_and_save_workflow on a NiPype-1 workflow object. This will execute the workflow and save the pre- and post-execution workflow data to JSON files.

import nipype.pipeline.engine as pe  # pypeline engine
from flowdump import run_and_save_workflow

# Typical NiPype workflow creation
amazing_workflow = pe.Workflow(name="main_workflow")
# amazing_workflow.connect(...)
# amazing_workflow.connect(...)
# amazing_workflow.connect(...)

# Let `flowdump` execute and save pre- and post-execution data.
run_and_save_workflow(
    amazing_workflow,
    out_dir='my/target/dir'
)

Advanced:

If more control over the workflow execution is needed, the workflow can be serialized manually.

import nipype.pipeline.engine as pe  # pypeline engine
import os.path
from flowdump import WorkflowJSONMeta, save_workflow_json

# Typical NiPype workflow creation
amazing_workflow = pe.Workflow(name="main_workflow")
# amazing_workflow.connect(...)
# amazing_workflow.connect(...)
# amazing_workflow.connect(...)

# Create workflow metadata object (traces execution time and stage)
workflow_meta = WorkflowJSONMeta(
    pipeline_name='My amazing pipeline',
    stage='pre'
)
# Dump pre-execution workflow
save_workflow_json(
    filename=os.path.join('my/target/dir', workflow_meta.filename()),
    workflow=amazing_workflow,
    meta=workflow_meta
)

# Execute NiPype workflow
amazing_workflow_result = amazing_workflow.run()

# Update metadata
workflow_meta.stage = 'post'
# Dump post-execution workflow
save_workflow_json(
    filename=os.path.join('my/target/dir', workflow_meta.filename()),
    workflow=amazing_workflow_result,
    meta=workflow_meta
)

Custom field serialization

Custom serializers can be implemented for projects with custom NiPype Node types. The serializer is a function that takes a the default flowdump serializer function (to optionally fall back to) and an object and returns a JSON-serializable object.

def my_custom_serializer(
        flowdump_serializer: Callable[[object], object],
        obj: object
):
    if isinstance(obj, MyType):
        return my_make_string(obj)
    return flowdump_serializer(obj)

save_workflow_json(
    filename=os.path.join('my/target/dir', workflow_meta.filename()),
    workflow=amazing_workflow_result,
    meta=workflow_meta
)

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

flowdump-0.1.2.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flowdump-0.1.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file flowdump-0.1.2.tar.gz.

File metadata

  • Download URL: flowdump-0.1.2.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.10 Windows/10

File hashes

Hashes for flowdump-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8613e11db1172cc55186e3d02749da1e26fa3b839ec9a30b67414ee0c939b21f
MD5 27e4c052ace4ddb805d657d31e0a6b32
BLAKE2b-256 e2ff22b9d0da9291b9ecf3b5f0903a6888bb0e196658cb73a9ec3b9825665602

See more details on using hashes here.

File details

Details for the file flowdump-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: flowdump-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.10 Windows/10

File hashes

Hashes for flowdump-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64496fc2217f53ae73b9344a2cf099a0a338422cb454d90189cee343baf98b7e
MD5 0947d25fb2773739a3bec92fc195f924
BLAKE2b-256 b66de411014a15b0cb8891d8ead1ef06d8aa61815cf25b0008b08a32848b7283

See more details on using hashes here.

Supported by

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