MDF Enforced Validator and Loader

Logo

Documentation for MEVAL.

Prefect Workflows

The flows in workflows/prefect/ inside MEVAL repo are the deployable Prefect entrypoints (see prefect.yaml) that wrap MEVAL’s ModelParser, Validator, and Loader classes for use in Prefect Cloud.

Any flows that require a database connection will retrieve credentials from AWS Secrets Manager (db_account_id, db_creds_secret_name, plus secret key names) and most download MDF model files at runtime via libs/prefect-toolkit’s download_model_files(commons_acronym, tag).

Contents

prefect.yaml deployment config

prefect.yaml at the repo root defines how each flow below is deployed to Prefect Cloud. Each entry under deployments specifies:

Deploying a workflow from the terminal

With the prefect CLI installed and authenticated (prefect cloud login or PREFECT_API_URL/PREFECT_API_KEY set), deploy one of the named deployments from prefect.yaml:

# deploy a single named deployment (matches the `name:` field under `deployments`)
prefect deploy --name meval-dataloader

Once deployed, you will be able to find the deployed workflow under the Deployment tab of Prefect Cloud UI.

Workflow entrypoints

validate_tsv_files.py β€” Validate TSV Files

Runs the full local validation pipeline (Validator) against a set of TSV files for a study/program pulled from S3: TSV format check (always run), plus optional record check, relationship/linkage check, and unique-key check (toggle via validation_items). Validation summaries are uploaded back to S3. Include all files of a study/program in one run β€” validating a partial set can miss cross-file issues (e.g. broken relationships).

add_uuid_to_files.py β€” Add UUID to a set of TSV files

Downloads a folder of TSV files from S3, generates a deterministic UUID5 (guid by default) for every record and relationship column using Validator.add_uuid_to_tsv_file, and uploads the resulting *_added.tsv files. Should be run after files have passed the validate_tsv_files pipeline, and requires a subgraph_value (e.g. a study accession) as part of the UUID namespace.

upsert_workflow.py β€” Dataloading Upsert Workflow

Contains the two main data-loading flows:

validate_submission_against_db.py β€” Validate submission files against database

Runs database validation (Validator.validate_tsv_in_db) against an existing graph database for a given validation_mode ("New", "Update", or "Upsert"), reporting whether records/relationships would validly load and projecting the resulting node/edge changes. If the submission files don’t already have a guid column (does_file_contain_uuid="no"), the flow pauses to collect a subgraph_value and runs add_uuid_to_files first.

find_db_floating_nodes.py β€” Find/delete floating (orphan) nodes

Two small helper flows built on Loader:

These are used internally by upsert_workflow.py (optional cleanup step) rather than being deployed as standalone entrypoints.

precision_deletion_guid.py β€” Precision Deletion Nodes

Deletes a specific set of nodes identified by a UUID/guid property value (uuid_value_input, given as a list of strings or an S3 URI to a JSON file of UUIDs). Supports a dry_run mode (default True) that reports what would be deleted without performing the deletion, backed by Loader.delete_nodes_by_prop_value.

delete_database_study_subgraph.py β€” Delete Database Study Subgraph Flow

Deletes one or more entire rooted subgraphs (e.g. all data under one or more studies) by matching a root node label/property against a list of property values, using Loader.wipe_rooted_subgraph for each value.

find_anchored_traversals.py β€” Find Anchored Traversals Flow

For each given β€œintermediate root” node value (e.g. a list of participant IDs) within a larger rooted subgraph (e.g. a study), renders an interactive HTML visualization of all descendant traversals (Loader.viz_intermediate_anchored_traversals) and uploads it to S3. Useful for inspecting what would be affected before deleting a node and its descendants.

wipe_database.py β€” Wipe out Database Flow

Deletes all nodes, relationships, and indexes in the target database (Loader.wipe_database + drop_all_indexes). Destructive and irreversible β€” use with caution, typically only in non-production/test databases.

Typical pipeline order

  1. validate_tsv_files β€” local validation of submission TSVs.
  2. add_uuid_to_files β€” generate guid values (if not already present).
  3. validate_submission_against_db β€” check what would change in the target database.
  4. upsert_files / upsert_files_in_order β€” load the data.
  5. As needed: find_db_floating_nodes, precision_deletion_guid, delete_database_study_subgraph, find_anchored_traversals, or wipe_database for maintenance/cleanup.