Skip to main content

SSM Python Client

Project description

Smart Spectal Matching Python Client Library

Smart Spectral Matching Python Client

Installation

Using pip

coming soon...

Manually

Clone the repository either via:

  • HTTP:
git clone https://github.com/smart-spectral-matching/ssm-client-python.git
  • SSH:
git clone git@github.com:smart-spectral-matching/ssm-client-python.git

Create a virtual environment and activate to install the package in the isolated environment:

python -m venv <name of env>
source <env>/bin/activate

To install the package from the local source tree into the environment, run:

python -m pip install .

Or to do so in "Development Mode", you can run:

python -m pip install -e .

To deactivate the virtual environment

deactivate

When finished, remove the virtual environment by deleting the directory:

rm -rf <name of env>

Usage

After installation, you can use the two main components of this package for the following functions:

Also, there are Jupyter Notebooks in the tutorials/ directory to help get started and test files under tests/data in different directories.

IO Module

This module is used to translate to and from different spectroscopy file formats. The currently supported file formats are:

The module has two main functions, read and write.

The read function reads in spectroscopy files and translates them to SciData JSON-LD dictionaries.

The write function takes SciData JSON-LD dictionaries and writes them out in the specified spectroscopy file format.

Example:

from ssm_client.io import read, write

# Read in from RRUFF, write out to JCAMP-DX
scidata_dict = read("./tests/data/rruff/raman_studtite.rruff", ioformat="rruff")
write("./raman_studtite.jdx", scidata_dict, ioformat="jcamp")

# Modify SciData JSON-LD and write back out to RRUFF
uid = 'my:example:jsonld'
scidata_dict["@graph"]["uid"] = uid
write("./my_raman_studtite.rruff", scidata_dict, ioformat="rruff")

SSMRester

The SSMRester is a REST client for the SSM REST API for storing datasets.

The SSMRester is a class and you can create an object by providing the REST API server information (hostname + port) you want to interact with for uploading / downloading datasets.

A dataset is a collection of individual data you want to store and a model is the individual data you store as a graph.

You must have a dataset that a model is associated with.

With a SSMRester object, you can perform common Create-Read-Update-Delete (CRUD) tasks for datasets and models.

Example:

import json
from ssm_client import SSMRester

rester = SSMRester(hostname="http://ssm.ornl.gov")
dataset = rester.dataset.create()
rester.initialize_model_for_dataset(dataset)

model = rester.model.create(scidata_dict)
print(dataset.uuid)
print(model.uuid)
rester.dataset.delete_by_uuid(dataset.uuid)

Development

Install via pdm

Install via pdm with dev dependencies:

pdm install -G:all

Then, run commands via pdm:

pdm run python -c "import ssm_client"

Tests / Linting

Flake8 linting

Run linting over the package with flake8 via:

pdm run flake8 src/ssm_client/ tests/

Pytest testing

Run tests using pytest:

pdm run pytest tests/

Code coverage

Get code coverage reporting using the pytest-cov plugin:

pdm run pytest --cov=src/ssm_client --cov-report=term-missing tests/

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Links

Licensing

BSD 3-clause

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

ssm_client-0.5.1.tar.gz (423.3 kB view details)

Uploaded Source

Built Distribution

ssm_client-0.5.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file ssm_client-0.5.1.tar.gz.

File metadata

  • Download URL: ssm_client-0.5.1.tar.gz
  • Upload date:
  • Size: 423.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.1 CPython/3.10.12 Linux/6.5.0-45-generic

File hashes

Hashes for ssm_client-0.5.1.tar.gz
Algorithm Hash digest
SHA256 bcbdcee532e14e9b5727456f9998fc281b31d3d47ff2bb80645f2eb4d95584bf
MD5 598bbe50b395c1577fcd9621685b37b9
BLAKE2b-256 234277fb31bb801c69056cc97ec2cbcace73e1c116288c43a64177c94ca151b6

See more details on using hashes here.

File details

Details for the file ssm_client-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: ssm_client-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.1 CPython/3.10.12 Linux/6.5.0-45-generic

File hashes

Hashes for ssm_client-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 745fc458ece35f11d9c22501114708f3d6441dab8c823d78ae1198660e6e9198
MD5 4357656ba3b5ab30701b71908839e5f5
BLAKE2b-256 9dd24fa56c2d92b055594ae2a7d246dfa47533d561f669cc6e650377ad18178c

See more details on using hashes here.

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