Skip to main content

Overview

Over the past few years, I’ve organically standardized on a structure for the code I write for my research. I’ve preferred to have each step of an analysis pipeline implemented as a standalone script, though usually with functions and classes that are importable in other modules – such scripts often load some data, perform some processing, save that processed data, save plots/figures, etc.

This package provides utilities for creating and finding labeled paths, which are suitable for storing data and plots. It’s often important to be able to compare results between different versions of some analysis step, so these paths are timestamped to prevent repeated runs of a script from overwriting previous results.

This package differentiates between “data” paths, to save things which might be loaded by another script at a further stage of an analysis pipeline, and “output” paths, for plots/etc. which are only intended for people to examine.

The main interface to this code is through the complementary functions create_data_path and find_newest_data_path, which each take a single “label” string argument and return a pathlib.Path. These can be used as follows:

input_path = find_newest_data_path('previous_script')
with open(input_path / 'filename') as f:
    data = load(f)

processed_data = do_something_with(data)

data_path = create_data_path('name_of_this_script')
with open(data_path / 'whatever_filename', 'w') as f:
    save(processed_data, f)

Output paths are likewise created by create_output_path. It is recommended that scripts which call create_data_path use the name of the script as the “label” argument, but this is not enforced – one can include parameter values or anything else relevant.

Additional functionality

With these calls to create_data_path and find_newest_data_path, one can then model a set of such scripts as a directed graph, with nodes representing both scripts and data paths, and edges denoting a “requires” relationship, e.g. “script X requires data label Y, which is produced by script Z”. This package also contains standalone scripts (which require the package NetworkX) that parse the Python files in a certain project, construct this graph, and use this graph to provide other useful functionality in the form of three standalone executable scripts:

  • dependency_graph: Plots this graph, using the pydotplus package, and a call to the dot GraphViz executable.

  • list_script_dependencies: takes a script filename as a command-line argument, and produces an ordered list of the data/script dependencies of that script by performing a topological sort on the subset of the graph reachable from that script. Useful for answering questions like “what should I run, in what order, to have everything in place to run this script of interest?” Note that this requires that the subgraph reachable from a script node be acyclic (which it should be anyway).

  • archive_script_data_dependencies: takes a script filename as a command-line argument, and identifies all data dependencies of that script. Archives all files under those data paths to a zip file which can easily be transported between machines.

Requirements

Python 3.6 or newer.

Things listed under “Additional functionality” require NetworkX and pydotplus.

Metadata

Release files for data-path-utils 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for data-path-utils 0.8.1
File Size Uploaded Provenance
data-path-utils-0.8.1.tar.gz 8.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for data-path-utils 0.8.1
File Interpreter ABI Platform
data_path_utils-0.8.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.3 kB

Release files / data-path-utils-0.8.1.tar.gz

Download URL data-path-utils-0.8.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3c60e0bd06362d213218704d4a302d33ebfdfcf630868b4e9edc48fcda612ea0
BLAKE2b-256 checksum
How to use checksums
59207682389c67af666dd75f8be0c13925609d8389ec5c8aa613adb5fb4b174e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / data_path_utils-0.8.1-py3-none-any.whl

Download URL data_path_utils-0.8.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b5c92d64b027ae72df54ceb910ed842a1e461f23ed4f4788879782a9999580d
BLAKE2b-256 checksum
How to use checksums
ca27c84298d3d2726d9e13dfa9a6b636e0a044ba241bb0873f3c4ab101c34700
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for data-path-utils 0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page