Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ jobs:
uses: ./actions/py/test
with:
python-version: ${{ matrix.python-version }}
unit-test-directory: tests/unit
unit-test-directory: tests/py/unit
# TMP disabled to allow publishing to PyPi
# - name: Run integration tests]
# - name: Run integration tests
# uses: ./actions/py/test
# with:
# integration-test-directory: tests/integration
# integration-test-directory: tests/py/integration
# env:
# TEST_HOST: platform.mat3ra.com
# TEST_PORT: 443
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down
72 changes: 59 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![PyPI version](https://badge.fury.io/py/exabyte-api-client.svg)](https://badge.fury.io/py/exabyte-api-client)
[![PyPI version](https://badge.fury.io/py/mat3ra-api-client.svg)](https://badge.fury.io/py/mat3ra-api-client)

This package provides access to Exabyte.io [RESTful API](https://docs.mat3ra.com/rest-api/overview/).
This package provides access to Mat3ra.com [RESTful API](https://docs.mat3ra.com/rest-api/overview/).

# Installation

Expand All @@ -16,35 +16,81 @@ Install using pip:
- from PyPI:

```bash
pip install exabyte-api-client
pip install mat3ra-api-client
```

- from source code in development mode:

```bash
git clone git@github.com:Exabyte-io/exabyte-api-client.git
cd exabyte-api-client
git clone git@github.com:Exabyte-io/api-client.git
cd api-client
pip install -e .
```

# Usage

```python
from mat3ra.api_client import APIClient

# Authenticate with OIDC token
client = APIClient.authenticate()

# Access endpoints
materials = client.materials.list()
```

# Examples

[exabyte-api-examples](https://github.com/Exabyte-io/exabyte-api-examples) repository contains examples for performing most-common tasks in the Exabyte.io platform through its RESTful API in Jupyter Notebook format.
[api-examples](https://github.com/Exabyte-io/api-examples) repository contains examples for performing most-common tasks in the Mat3ra.com platform through its RESTful API in Jupyter Notebook format.

# Testing
A Virtualenv environment can be created and the tests run with the included `run-tests.sh` script.
To run the unit tests in Python 3, you can:

The package uses pytest for testing. Tests are organized into unit and integration tests.

## Running Tests

### Unit Tests (No environment setup required)

Run all unit tests:
```bash
pytest tests/py/unit
```
./run-tests -t=unit

### Integration Tests (Requires API credentials)

Integration tests require the following environment variables to be set:

- `TEST_HOST` - API host (e.g., `platform.mat3ra.com`)
- `TEST_PORT` - API port (e.g., `443`)
- `TEST_ACCOUNT_ID` - Your account ID
- `TEST_AUTH_TOKEN` - Your authentication token
- `TEST_SECURE` - Use HTTPS (optional, default: `False`)
- `TEST_VERSION` - API version (optional, default: `2018-10-01`)

To run integration tests:
```bash
export TEST_HOST=platform.mat3ra.com
export TEST_PORT=443
export TEST_ACCOUNT_ID=your-account-id
export TEST_AUTH_TOKEN=your-auth-token
export TEST_SECURE=true

pytest tests/py/integration
```

To run the integration tests in Python 2, you can:
### Run All Tests

```bash
pytest tests/py
```
./run-tests -p=python2 -t=integration

### Run Tests with Coverage

```bash
pytest tests/py/unit --cov=mat3ra.api_client --cov-report=term --cov-report=html
```
(assuming you have a `python2` binary in your PATH environment).

Note that the integration tests require a REST API service against which the live tests will run. See `tests/integration/__init__.py` for the environment variable details.
**Note:** Integration tests will be automatically skipped if required environment variables are not set.


© 2020 Exabyte Inc.
18 changes: 0 additions & 18 deletions exabyte_api_client/__init__.py

This file was deleted.

103 changes: 99 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,105 @@
[project]
name = "mat3ra.api-client"
dynamic = ["version"]
description = "Mat3ra.com Python Client for RESTful API"
readme = "README.md"
requires-python = ">=3.10"
license = {file = "LICENSE.md"}
authors = [
{ name = "Exabyte Inc.", email = "info@mat3ra.com" }
]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development",
"License :: OSI Approved :: Apache Software License",
]
dependencies = [
"requests>=2.26.0",
"pydantic>=2,<3",
]

[project.optional-dependencies]
dev = [
"pre-commit",
"black",
"ruff",
"isort",
"mypy",
"pip-tools",
]
tests = [
"coverage[toml]>=5.3",
"pytest",
"pytest-cov",
"mock>=4.0.3",
]
all = [
"mat3ra-api-client[tests]",
"mat3ra-api-client[dev]",
]

[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
requires = [
"setuptools>=42",
"setuptools-scm[toml]>=3.4"
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "exabyte_api_client/_version.py"
git_describe_command = "git describe --tags --long"
write_to = "src/py/mat3ra/api_client/_version.py"

[tool.setuptools.packages.find]
where = ["src/py"]

[tool.black]
line-length = 120
target-version = ['py310']
extend-exclude = '''
(
tests\/fixtures*
)
'''

[tool.ruff]
extend-exclude = [
"tests/fixtures"
]
line-length = 120
target-version = "py310"

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]

[tool.isort]
profile = "black"
multi_line_output = 3
include_trailing_comma = true

[tool.pytest.ini_options]
pythonpath = [
"src/py",
]
testpaths = [
"tests/py"
]

[tool.coverage.run]
source = ['.']
omit = ['env*/*', 'venv*/*', 'tests/*']
source = ["src/py"]
omit = ["env*/*", "venv*/*", "tests/*", "src/py/mat3ra/api_client/_version.py"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
]
9 changes: 0 additions & 9 deletions requirements-dev.txt

This file was deleted.

49 changes: 0 additions & 49 deletions run-tests.sh

This file was deleted.

34 changes: 0 additions & 34 deletions setup.cfg

This file was deleted.

3 changes: 3 additions & 0 deletions src/py/mat3ra/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Mat3ra namespace package."""
__path__ = __import__("pkgutil").extend_path(__path__, __name__)

18 changes: 18 additions & 0 deletions src/py/mat3ra/api_client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ruff: noqa: F401
try:
from ._version import version as __version__
except ModuleNotFoundError:
__version__ = None

from mat3ra.api_client.endpoints.bank_materials import BankMaterialEndpoints
from mat3ra.api_client.endpoints.bank_workflows import BankWorkflowEndpoints
from mat3ra.api_client.endpoints.jobs import JobEndpoints
from mat3ra.api_client.endpoints.login import LoginEndpoint
from mat3ra.api_client.endpoints.logout import LogoutEndpoint
from mat3ra.api_client.endpoints.materials import MaterialEndpoints
from mat3ra.api_client.endpoints.metaproperties import MetaPropertiesEndpoints
from mat3ra.api_client.endpoints.projects import ProjectEndpoints
from mat3ra.api_client.endpoints.properties import PropertiesEndpoints
from mat3ra.api_client.endpoints.workflows import WorkflowEndpoints

from mat3ra.api_client.client import APIClient
Loading
Loading