Metadata-Version: 2.4
Name: jinko-sdk
Version: 1.0.0
Summary: A Python package containing jinko_helpers, jinko_stats, and crabbit modules aimed to be used with Jinko.ai API
Author-email: NovaInSilico <oss@novainsilico.ai>
License-Expression: MIT
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.13.4
Dynamic: license-file

# Jinkō Python SDK

## Installation

```bash
pip install jinko-sdk
```

## Development tests

See `tests/README.md`.

## Configuration

```bash
export JINKO_API_KEY="..."
export JINKO_PROJECT_ID="..."
export JINKO_BASE_URL="https://api.jinko.ai" # Already uses this adress by default
```
These variables can also be set through JinkoClient's init.

## Quickstart

```python
from jinko import JinkoClient

client = JinkoClient()  # Can receive api key and project id

model = client.models.get("cm-...")
print(model.name)

content = model.content()

trial = client.trials.get("tr-...")
trial.run()
trial.wait_until_completed()

summary = trial.results.summary()
scalars = trial.results.scalars(["AUC", "Cmax"]).to_dataframe()
```

## Model Components API

`Model.components` is the default ergonomic entrypoint for component edits.

```python
model = client.models.get("cm-...")

# typed read
p = model.components.get_parameter("k_clearance")

# immediate typed update in one API call
p.update(formula="CL / V", unit="L/h")

# staged multi-component edit in one commit
with model.components.batch(version_name="retune") as b:
    b.edit_parameter("k_clearance").set_formula("CL2 / V")
    b.create_parameter(id="k_new", formula=1.2, unit="1/h")
```

Low-level escape hatch is still available for advanced/raw payload workflows:

```python
from jinko.openapi_types import Parameter

model = model.edit_components(
    add=Parameter(id="k_raw", specifics={"formula": 2.0}),
    version_name="raw edit",
)
```

## Versioned resources

By default, the SDK works with the latest version of a resource.

```python
model = client.models.get("cm-...")
```

To access older versions:

```python
versions = model.versions.list()
old = model.versions.get(revision=3)
```

To restore an older version as the new latest version:

```python
model.versions.restore(revision=3, version_name="restore baseline")
```
