Metadata-Version: 2.4
Name: pyscicat
Version: 0.4.8
Summary: a python API to communicate with the Scicat API
Project-URL: Homepage, https://github.com/scicatproject/pyscicat
Author-email: Scicat Project Contributors <dmcreynolds@lbl.gov>
Maintainer-email: Scicat Project Team <dmcreynolds@lbl.gov>
License-File: AUTHORS.rst
License-File: LICENSE
License-File: LICENSE.txt
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Requires-Python: >=3.9
Requires-Dist: pydantic
Requires-Dist: requests
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: codecov; extra == 'dev'
Requires-Dist: coverage; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: isort; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: requests-mock; extra == 'dev'
Requires-Dist: sphinx; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Requires-Dist: types-requests; extra == 'dev'
Provides-Extra: docs
Requires-Dist: ipython; extra == 'docs'
Requires-Dist: matplotlib; extra == 'docs'
Requires-Dist: mistune<2.0.0; extra == 'docs'
Requires-Dist: myst-parser; extra == 'docs'
Requires-Dist: numpydoc; extra == 'docs'
Requires-Dist: sphinx-click; extra == 'docs'
Requires-Dist: sphinx-copybutton; extra == 'docs'
Requires-Dist: sphinx-rtd-theme; extra == 'docs'
Requires-Dist: sphinxcontrib-openapi; extra == 'docs'
Provides-Extra: hdf5
Requires-Dist: h5py; extra == 'hdf5'
Requires-Dist: hdf5plugin; extra == 'hdf5'
Description-Content-Type: text/markdown

# Pyscicat

Pyscicat is a python client library for interacting with the [SciCat backend](https://scicatproject.github.io/). It sends messages to the SciCat backend over HTTP. It currently does not contain any command line interface.

Documentation for Pyscicat is [available here](https://scicatproject.github.io/pyscicat/).

### Basic usage example

```python
from datetime import datetime

from pyscicat.client import ScicatClient 
from pyscicat.model import (Ownable, RawDataset, DatasetType, Sample)

# Create a client object. The account used should have the ingestor role in SciCat
client = ScicatClient(base_url="http://localhost/api/v3", username="admin", password="2jf70TPNZsS")

ownable = Ownable(ownerGroup="aGroup", accessGroups=[])

# Create a Dataset object. Notice how we pass the `ownable` instance.
dataset = RawDataset(
    size=42,
    owner="ingestor",
    contactEmail="scicatingestor@your.site",
    creationLocation="magrathea",
    creationTime=str(datetime.now().isoformat()),
    instrumentId="earth",
    proposalId="deepthought",
    dataFormat="planet",
    type=DatasetType.raw,
    principalInvestigator="admin",
    sourceFolder="/foo/bar",
    scientificMetadata={"a": "field"},
    sampleId="gargleblaster",
    **ownable.model_dump(),
)
dataset_id = client.datasets_create(dataset)

sample = Sample(
    sampleId="gargleblaster",
    owner="Chamber of Commerce",
    description="A legendary drink.",
    sampleCharacteristics={"Flavour": "Unknown, but potent"},
    isPublished=False,
    **ownable.model_dump()
)
sample_id = client.samples_create(sample)
```

### Notes

To develop with SciCatLive, connect to your local running instance with:

```python
client = ScicatClient(base_url="http://localhost/api/v3", username="admin", password="2jf70TPNZsS", auto_login=False)
client._headers["Host"] = "backend.localhost"
client.login()
```

Then use the client normally.