Skip to main content

Simple client for fetching data from mofdb

Project description

mofdb-client

A typed lightweight client wrapping the mofdb api.

Installation

python3 -m pip install mofdb_client

Example

Example of mofdb-client IDE autocompletion

from mofdb_client import fetch
for mof in fetch(vf_min=0.5, vf_max=0.99):
    print(f"Mof {mof.name} has {len(mof.isotherms)} isotherms and elements {[str(e) for e in mof.elements]}")
    print(f"This mof's cif file starts with: '{mof.cif.splitlines()[1]}'")
Mof UTEWUM_clean has 2 isotherms and elements ['Cu', 'H', 'C', 'N']
This mof's cif file starts with: '_audit_creation_date              2014-07-02'
Mof ZECKID_clean has 1 isotherms and elements ['Cu', 'H', 'C', 'N', 'O']
This mof's cif file starts with: '_audit_creation_date              2014-07-02'
Mof AQOMAW_clean has 2 isotherms and elements ['N', 'C', 'H', 'Co', 'Cl', 'O']
This mof's cif file starts with: '_cell_length_a       18.8345'
Mof AQOLOJ_clean has 2 isotherms and elements ['N', 'C', 'H', 'Co', 'Cl']
This mof's cif file starts with: '_cell_length_a       18.794'
Mof SENWOZ_clean has 2 isotherms and elements ['Zn', 'H', 'C', 'O']
This mof's cif file starts with: '_audit_creation_date              2014-07-02'
Mof IYUCIQ_clean has 2 isotherms and elements ['Dy', 'O', 'N', 'C', 'H']
This mof's cif file starts with: '_cell_length_a       29.162'
Mof ORUKET_clean has 2 isotherms and elements ['P', 'O', 'N', 'C', 'H', 'Mg']
This mof's cif file starts with: '_cell_length_a       18.571'
...

Parameters

fetch supports a number of arguements

  • mofid: str
  • mofkey: str
  • vf_min: float
  • vf_max: float
  • lcd_min: float
  • lcd_max: float
  • pld_min: float
  • pld_max: float
  • sa_m2g_min: float
  • sa_m2g_max: float
  • sa_m2cm3_min: float
  • sa_m2cm3_max: float
  • limit: int
  • telemetry: bool default true (see telemetry section)

Design Note

fetch is lazy because mofDB is large. Be sure to loop over it with for mof in fetch() and NOT for mof in list(fetch()) since building the list will download all the mofs before it starts processing and this will be very slow and may well run out of memory.

Compatibility

Tested on Python 3.9 likely to work on any 3.x.

Future Enhancements:

  • Retries for transient network failures with exponential backoff

  • Support for unit conversions

Telemetry

This package may report crashes/calls to fetch in library code when the telemetry arg is true. This is done using sentry. Nothing in addition to fetch params and data captured by default by sentry is ever captured.

For example this could include:

  • a stack trace including your code
  • operating system version
  • time
  • python runtime version
  • hostname
  • anything else sentry captures by default

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

mofdb_client-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

mofdb_client-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file mofdb_client-0.1.0.tar.gz.

File metadata

  • Download URL: mofdb_client-0.1.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/24.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for mofdb_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7aa2173ac02c535532f381f9db4687cf68febbfbbd51895b2722e5f70f69848f
MD5 38cac559044b8fc2b08b2c82a8f098b4
BLAKE2b-256 2ba75e1bc403947051b067ea9d059fbaaaec4a407a02e419c2a541fc4351c134

See more details on using hashes here.

Provenance

File details

Details for the file mofdb_client-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mofdb_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/24.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for mofdb_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc9dbc19fc5f76ac87c0e4e96b9d70dd46f099beb523fe4880db8f559ef27b86
MD5 2a90c79f1a803acdde180ce8eb5ea411
BLAKE2b-256 dbc38714c36c34eb14ab83c3b1d5349415ff449c553e1d6a1c1a5be87fc6157a

See more details on using hashes here.

Provenance

Supported by

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