Skip to content

bundles and replay

Package a workflow source and inputs for execution in another workspace.

bundle() writes an archive without importing or running the workflow. replay() unpacks it into an empty workspace, verifies declared file checksums, imports the factory, and executes its tasks. A bundle includes one workflow source file, JSON inputs, and declared data files, not an entire Python environment.

Use this layer when transferring or inspecting workflow inputs explicitly. For ordinary remote submission, jobs.submit(source=...) creates a temporary bundle for you. Source imports, dependencies, and the solver must be available where replay runs. Only replay trusted archives: their contents are executable code, and checksum validation is not an authenticity or safety check.

Functions:

bundle

bundle(*, source: str | Path, destination: str | Path, inputs: Mapping[str, Any], files: Sequence[str | Path] | Mapping[str, str | Path] = (), entrypoint: str = 'build_workflow', overwrite: bool = False) -> Path

Write a zip containing one workflow Python file and declared data files.

source must define an entrypoint returning a Workflow. It may take an inputs parameter to choose stages and tasks from the saved inputs. Inputs must be JSON-serializable. Data file paths are relative to the source file's directory and appear at the same relative paths in the run workspace. Alternatively, map workspace-relative destinations to explicit local source paths (relative to the workflow source or absolute). Only declared files are uploaded; mapping destinations must still stay inside the remote workspace. The bundle does not include Python packages or the OpenSees executable.

Parameters:

Name Type Description Default
source str | Path

Python workflow file defining the factory at module scope.

required
destination str | Path

ZIP path to create.

required
inputs Mapping[str, Any]

JSON-serializable values; nonfinite numbers are rejected.

required
files Sequence | Mapping

Relative source files, or destination-to-source mapping.

()
entrypoint str

Factory function name in the source file.

'build_workflow'
overwrite bool

Permit replacing an existing destination ZIP.

False

Returns:

Name Type Description
archive Path

Absolute path to the created bundle.

Raises:

Type Description
ValueError

Source, entrypoint, file mapping, or JSON values are invalid.

TypeError

Inputs are not a mapping or contain non-JSON values.

FileExistsError

Destination exists and overwrite is False.

Example
from femora.jobs import bundle
archive = bundle(source="workflow.py", destination="workflow.zip",
                 inputs={"site": 1}, files=["inputs/motion.txt"])
Note

Packaging does not import or execute the workflow. It includes only the one source file and declared data, not imported helper modules automatically.

replay

replay(package: str | Path, *, workspace: str | Path, cores: int | None = None, backend: TACC | None = None) -> RunResult

Run a trusted bundle in a fresh workspace using the selected backend.

Bundle source is executable Python. Do not replay bundles from untrusted origins. This operation does not install dependencies or configure OpenSees.

Parameters:

Name Type Description Default
package str | Path

Trusted workflow ZIP created by bundle().

required
workspace str | Path

Empty directory or new directory for the run.

required
cores int | None

Execution capacity passed to execute().

None
backend TACC | None

Existing-allocation backend, or None for local execution.

None

Returns:

Name Type Description
run RunResult

Task return values, manifest, and selected artifact paths.

Raises:

Type Description
FileExistsError

Workspace is not empty or extraction would overwrite data.

ValueError

Bundle metadata, paths, checksums, or factory are invalid.

WorkflowExecutionError

Workflow execution fails.

Example
from femora.jobs import replay
if __name__ == "__main__":
    run = replay("workflow.zip", workspace="new-run", cores=1)
    print(run.manifest)
Warning

This executes bundled Python code and external commands. Checksums detect inconsistencies, not whether a bundle is safe or from a trusted author.