Skip to main content

Cynric is a package for validating and uploading data to the Wessex SDE

Project description

cynric

Cynric

Wessex SDE data validation & API uploader

Cynric is a convenience package for validating research datasets against a data dictionary and securely uploading them into the Wessex Secure Data Environment (SDE).

Under the hood, Cynric uses Valediction for dictionary-driven constraint enforcement, then handles authenticated upload to targeted SDE database tables — including chunked uploads for large datasets and streamed reading to optimise local RAM usage.

Developed by the Wessex SDE, University of Southampton CIRU, and University Hospital Southampton SETT Centre for use in clinical research workflows, Cynric is designed to fit into reproducible analytical pipelines for automatic SDE validation & data upload.

Features:

  • Validates a user's dataset against an accompanying data dictionary to enforce constraints and data integrity
  • Uploads validated datasets to targeted Wessex SDE database tables
  • Chunking for large datasets to support stable transfer and RAM optimisation
  • Secures credentials via keyring to keep API keys out of repositories and retrieves for convenience
  • Checks table access quickly to confirm user permissions and review table access

🧭 Resources

⚡ Quickstart

Demo/Test

  1. Install: pip install cynric (or use your favoured package manager)
  2. Contact the Wessex SDE team for your API key and endpoint
  3. Request the demo tables be established in your workspace
  4. Run the following test using Cynric's inbuilt demo data:
import cynric

## Save Credentials to OS Credential Storage (one-time)
cynric.save_credentials(
    base_url = "https://YOUR_WESSEX_SDE_ENDPOINT",
    token = "YOUR_API_KEY"
)  # Scrub from code once saved for max security


## Identify Tables for Demo Upload
sde_tables = cynric.check_table_access(print=True)
## Upload Demo Data
cynric.demo.push_demo_data(
    target_table_map = {  # enter target tables
        "DEMOGRAPHICS": "dsXXXXXX",
        "DIAGNOSES": "dsXXXXXX",
        "LAB_TESTS": "dsXXXXXX",
        "VITALS": "dsXXXXXX",
    }
)

Data Upload

  1. Following Wessex SDE setup of workspace & tables, upload your data:
import cynric
from cynric import demo

# Import Data & Dictionary and Review
dataset = cynric.Dataset.create_from(demo.DEMO_DATA)
dataset.import_dictionary(demo.DEMO_DICTIONARY)
dataset
# Identify Tables
sde_tables = cynric.check_table_access(print=True)
cynric.validate_and_upload(
    dataset,
    target_table_map={
        "TABLE_NAME_1": "dsXXXXXX",
        "TABLE_NAME_2": "dsXXXXXX",
        # etc...
    },
)

🧠 Function Quicklist

Preparation

  • save_credentials() - securely store the Wessex SDE endpoint + API key in your OS's credential manager
  • delete_credentials() - remove stored credentials from your OS's credential manager
  • check_table_access() - confirm access/permissions to a target SDE table (useful before upload)

Validation & Upload

  • Dataset.create_from() - create a Cynric Dataset from a folder of files, or dictionary of DataFrames
  • validate_and_upload() - validate the dataset and upload to the target SDE tables (supports chunked upload)

🤝 Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

⚖️ License

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. CC BY-NC 4.0

🧑‍🔬 Authors

Cynric was developed by Ben Sale, Cai Davis, and Michael George across the Wessex SDE, University Hospital Southampton NHSFT's Data & AI Research Unit (DAIR), and the University of Southampton's Clinical Informatics Research Unit (CIRU)

Collaborators

NHS UHS SETT Centre

Wessex SDE

CIRU

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

cynric-1.0.0.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

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

cynric-1.0.0-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

Details for the file cynric-1.0.0.tar.gz.

File metadata

  • Download URL: cynric-1.0.0.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for cynric-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f75763ac8caeb3791f70caebf6ea5c0f0f16c89aebdd3d3284bf801718673649
MD5 92e27ed302e6eb074c86890dca15d786
BLAKE2b-256 ffca2de3e8541e68b858d397b828ffc613677b4ed175b3a2e4bbba1821026bb0

See more details on using hashes here.

File details

Details for the file cynric-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cynric-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for cynric-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d134eb6a579224b793fabb3975646dfba6c12d0e11dd416988af2f14cd3be57
MD5 4fbc881d821fd1118842c6b58809295c
BLAKE2b-256 79aa93884d37aa02da59d5de07ddedff3f37c023e7af3c6516ea66d5c28e074c

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