From a19ba655e7201da342eaeb64628b17620ac01bea Mon Sep 17 00:00:00 2001 From: Kristjan Eimre Date: Tue, 30 Jul 2024 19:38:49 +0300 Subject: [PATCH] rename python package to optimade-maker (#63) --- .github/workflows/ci.yml | 63 +++++++++---------- README.md | 14 ++--- pyproject.toml | 6 +- src/optimade_maker/__init__.py | 4 ++ .../archive/__init__.py | 0 .../archive/archive_record.py | 2 +- .../archive/cli.py | 0 .../archive/scan_records.py | 4 +- .../archive/utils.py | 0 src/{optimake => optimade_maker}/cli.py | 6 +- src/{optimake => optimade_maker}/config.py | 0 src/{optimake => optimade_maker}/convert.py | 0 src/{optimake => optimade_maker}/logger.py | 0 src/{optimake => optimade_maker}/parsers.py | 2 +- src/{optimake => optimade_maker}/serve.py | 4 +- src/optimake/__init__.py | 4 -- tests/test_archive.py | 6 +- tests/test_convert.py | 4 +- tests/test_yaml.py | 2 +- 19 files changed, 60 insertions(+), 61 deletions(-) create mode 100644 src/optimade_maker/__init__.py rename src/{optimake => optimade_maker}/archive/__init__.py (100%) rename src/{optimake => optimade_maker}/archive/archive_record.py (99%) rename src/{optimake => optimade_maker}/archive/cli.py (100%) rename src/{optimake => optimade_maker}/archive/scan_records.py (90%) rename src/{optimake => optimade_maker}/archive/utils.py (100%) rename src/{optimake => optimade_maker}/cli.py (93%) rename src/{optimake => optimade_maker}/config.py (100%) rename src/{optimake => optimade_maker}/convert.py (100%) rename src/{optimake => optimade_maker}/logger.py (100%) rename src/{optimake => optimade_maker}/parsers.py (98%) rename src/{optimake => optimade_maker}/serve.py (97%) delete mode 100644 src/optimake/__init__.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea9718e..e2a8d0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: pull_request: push: branches: - - main + - main env: PYTEST_ADDOPTS: "--color=yes" @@ -16,38 +16,37 @@ concurrency: cancel-in-progress: true jobs: - tests: - name: Test the `optimake` package + name: Test the `optimade-maker` package runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: '3.10' - cache: 'pip' - cache-dependency-path: | - pyproject.toml - - - name: Install latest compatible versions of immediate dependencies - run: | - python -m pip install --upgrade pip - pip install -U setuptools wheel - pip install -e .[tests,dev] - - - name: Run linters - run: | - pre-commit run --all-files - - - name: Run tests - run: pytest -vv --cov-report=xml --cov-report=term ./tests - - - name: Upload coverage - uses: codecov/codecov-action@v3 - with: - name: project - file: ./coverage.xml - flags: project + - uses: actions/checkout@v3 + + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: "pip" + cache-dependency-path: | + pyproject.toml + + - name: Install latest compatible versions of immediate dependencies + run: | + python -m pip install --upgrade pip + pip install -U setuptools wheel + pip install -e .[tests,dev] + + - name: Run linters + run: | + pre-commit run --all-files + + - name: Run tests + run: pytest -vv --cov-report=xml --cov-report=term ./tests + + - name: Upload coverage + uses: codecov/codecov-action@v3 + with: + name: project + file: ./coverage.xml + flags: project diff --git a/README.md b/README.md index 0f42b3c..9666e9c 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ #
optimade-maker
-[![PyPI - Version](https://img.shields.io/pypi/v/optimake?color=4CC61E)](https://pypi.org/project/optimake/) +[![PyPI - Version](https://img.shields.io/pypi/v/optimade-maker?color=4CC61E)](https://pypi.org/project/optimade-maker/) Tools for making [OPTIMADE APIs](https://optimade.org) from various formats of structural data (e.g. an archive of CIF files). -This repository contains the `src/optimake` Python packages that work towards this aim. Features include +This repository contains the `src/optimade-maker` Python package and the corresponding CLI tool `optimake` that work towards this aim. Features include - definition of a config file format (`optimade.yaml`) for annotating data archives to be used in the OPTIMADE ecosystem; - conversion of the raw data into corresponding OPTIMADE types using pre-existing parsers (e.g., ASE for structures); @@ -24,7 +24,7 @@ See `./examples` for a more complete set of supported formats and corresponding ### Annotating with `optimade.yaml` -To annotate your structural data for `optimake`, the data archive needs to be accompanied by an `optimade.yaml` config file. The following is a simple example for a zip archive (`structures.zip`) of cif files together with an optional property file (`data.csv`): +To annotate your structural data for `optimade-maker`, the data archive needs to be accompanied by an `optimade.yaml` config file. The following is a simple example for a zip archive (`structures.zip`) of cif files together with an optional property file (`data.csv`): ```yaml config_version: 0.1.0 @@ -49,7 +49,7 @@ entries: ### Structure `id`s and property files -`optimake` will assign an `id` for each structure based on its full path in the archive, following a simple deterministic rule: from the set of all archive paths, the maximum common path prefix and postfix (including file extensions) are removed. E.g. +`optimade-maker` will assign an `id` for each structure based on its full path in the archive, following a simple deterministic rule: from the set of all archive paths, the maximum common path prefix and postfix (including file extensions) are removed. E.g. ``` structures.zip/cifs/set1/101.cif @@ -71,7 +71,7 @@ structures.zip/cifs/set2/102.cif,3.2 Install with ```bash -pip install . +pip install optimade-maker ``` this will also make the `optimake` CLI utility available. @@ -83,9 +83,9 @@ For a folder containing the data archive and the `optimade.yaml` file (such as i For more detailed information see also `optimake --help`. -## `optimake` JSONLines Format +## `optimade-maker` JSONLines Format -As described above, `optimake` works via an intermediate JSONLines file representation of an OPTIMADE API (see also the [corresponding issue in the specification](https://github.com/Materials-Consortia/OPTIMADE/issues/471)). +As described above, `optimade-maker` works via an intermediate JSONLines file representation of an OPTIMADE API (see also the [corresponding issue in the specification](https://github.com/Materials-Consortia/OPTIMADE/issues/471)). This file should provide enough metadata to spin up an OPTIMADE API with many different entry types. The format is as follows: diff --git a/pyproject.toml b/pyproject.toml index af28ba7..24f5351 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "optimake" +name = "optimade-maker" description = "Tools for making OPTIMADE APIs from raw structural data." readme = "README.md" version = "0.2.2" @@ -51,8 +51,8 @@ ignore_missing_imports = true follow_imports = "skip" [tool.isort] -known_first_party = "optimake" +known_first_party = "optimade_maker" profile = "black" [project.scripts] -optimake = "optimake.cli:cli" +optimake = "optimade_maker.cli:cli" diff --git a/src/optimade_maker/__init__.py b/src/optimade_maker/__init__.py new file mode 100644 index 0000000..3e6689d --- /dev/null +++ b/src/optimade_maker/__init__.py @@ -0,0 +1,4 @@ +from optimade_maker.config import Config +from optimade_maker.convert import convert_archive + +__all__ = ("Config", "convert_archive") diff --git a/src/optimake/archive/__init__.py b/src/optimade_maker/archive/__init__.py similarity index 100% rename from src/optimake/archive/__init__.py rename to src/optimade_maker/archive/__init__.py diff --git a/src/optimake/archive/archive_record.py b/src/optimade_maker/archive/archive_record.py similarity index 99% rename from src/optimake/archive/archive_record.py rename to src/optimade_maker/archive/archive_record.py index 5decbbf..1da36c4 100644 --- a/src/optimake/archive/archive_record.py +++ b/src/optimade_maker/archive/archive_record.py @@ -4,7 +4,7 @@ import requests -from optimake.config import Config +from optimade_maker.config import Config DEFAULT_ARCHIVE_URL = "https://archive.materialscloud.org" diff --git a/src/optimake/archive/cli.py b/src/optimade_maker/archive/cli.py similarity index 100% rename from src/optimake/archive/cli.py rename to src/optimade_maker/archive/cli.py diff --git a/src/optimake/archive/scan_records.py b/src/optimade_maker/archive/scan_records.py similarity index 90% rename from src/optimake/archive/scan_records.py rename to src/optimade_maker/archive/scan_records.py index cc92908..374db00 100644 --- a/src/optimake/archive/scan_records.py +++ b/src/optimade_maker/archive/scan_records.py @@ -1,7 +1,7 @@ import tqdm -from optimake.archive.archive_record import ArchiveRecord -from optimake.archive.utils import get_all_records, get_parsed_records +from optimade_maker.archive.archive_record import ArchiveRecord +from optimade_maker.archive.utils import get_all_records, get_parsed_records DEFAULT_ARCHIVE_URL = "https://archive.materialscloud.org/" diff --git a/src/optimake/archive/utils.py b/src/optimade_maker/archive/utils.py similarity index 100% rename from src/optimake/archive/utils.py rename to src/optimade_maker/archive/utils.py diff --git a/src/optimake/cli.py b/src/optimade_maker/cli.py similarity index 93% rename from src/optimake/cli.py rename to src/optimade_maker/cli.py index 6121a66..acbf4c5 100644 --- a/src/optimake/cli.py +++ b/src/optimade_maker/cli.py @@ -2,9 +2,9 @@ import click -from optimake.convert import convert_archive -from optimake.logger import LOGGER -from optimake.serve import OptimakeServer +from optimade_maker.convert import convert_archive +from optimade_maker.logger import LOGGER +from optimade_maker.serve import OptimakeServer @click.group() diff --git a/src/optimake/config.py b/src/optimade_maker/config.py similarity index 100% rename from src/optimake/config.py rename to src/optimade_maker/config.py diff --git a/src/optimake/convert.py b/src/optimade_maker/convert.py similarity index 100% rename from src/optimake/convert.py rename to src/optimade_maker/convert.py diff --git a/src/optimake/logger.py b/src/optimade_maker/logger.py similarity index 100% rename from src/optimake/logger.py rename to src/optimade_maker/logger.py diff --git a/src/optimake/parsers.py b/src/optimade_maker/parsers.py similarity index 98% rename from src/optimake/parsers.py rename to src/optimade_maker/parsers.py index ac428c8..3aa033e 100644 --- a/src/optimake/parsers.py +++ b/src/optimade_maker/parsers.py @@ -10,7 +10,7 @@ from optimade.models import EntryResource from pymatgen.entries.computed_entries import ComputedStructureEntry -from optimake.config import PropertyDefinition +from optimade_maker.config import PropertyDefinition def pybtex_to_optimade(bib_entry: Any, properties=None) -> EntryResource: diff --git a/src/optimake/serve.py b/src/optimade_maker/serve.py similarity index 97% rename from src/optimake/serve.py rename to src/optimade_maker/serve.py index 4f880d5..971cfa3 100644 --- a/src/optimake/serve.py +++ b/src/optimade_maker/serve.py @@ -6,14 +6,14 @@ import bson.json_util import uvicorn -from optimake.logger import LOGGER +from optimade_maker.logger import LOGGER def get_optimake_provider_info(index_base_url=None): info = { "prefix": "optimake", "name": "Optimake", - "description": "Provider created with optimake", + "description": "Provider created with optimade-maker", "homepage": "https://github.com/materialscloud-org/optimade-maker", "index_base_url": index_base_url, } diff --git a/src/optimake/__init__.py b/src/optimake/__init__.py deleted file mode 100644 index 9e85e99..0000000 --- a/src/optimake/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from optimake.config import Config -from optimake.convert import convert_archive - -__all__ = ("Config", "convert_archive") diff --git a/tests/test_archive.py b/tests/test_archive.py index c442638..54d5bb3 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -1,6 +1,6 @@ import traceback -from optimake.config import UnsupportedConfigVersion +from optimade_maker.config import UnsupportedConfigVersion archive_url = "https://staging-archive.materialscloud.org/" test_record_id = 1408 @@ -8,7 +8,7 @@ def test_archive_record_metadata(): """Test ArchiveRecord to read metadata.""" - from optimake.archive.archive_record import ArchiveRecord + from optimade_maker.archive.archive_record import ArchiveRecord try: record = ArchiveRecord(test_record_id, archive_url=archive_url) @@ -22,7 +22,7 @@ def test_archive_record_process(): """Test ArchiveRecord to download files.""" import os - from optimake.archive.archive_record import ArchiveRecord + from optimade_maker.archive.archive_record import ArchiveRecord try: record = ArchiveRecord( diff --git a/tests/test_convert.py b/tests/test_convert.py index a84c1ea..c4ce8ff 100644 --- a/tests/test_convert.py +++ b/tests/test_convert.py @@ -5,7 +5,7 @@ import numpy as np import pytest from optimade.models import EntryInfoResource -from optimake.convert import convert_archive +from optimade_maker.convert import convert_archive EXAMPLE_ARCHIVES = (Path(__file__).parent.parent / "examples").glob("*") @@ -98,7 +98,7 @@ def check_arrays(reference, test, field): def test_unique_id_generator(): """Unit tests for some common cases of the unique ID generator.""" - from optimake.convert import _set_unique_entry_ids + from optimade_maker.convert import _set_unique_entry_ids entry_ids = [ "data/structures/1.cif", diff --git a/tests/test_yaml.py b/tests/test_yaml.py index 71747ee..65a7e9f 100644 --- a/tests/test_yaml.py +++ b/tests/test_yaml.py @@ -1,7 +1,7 @@ from pathlib import Path import pytest -from optimake.config import Config +from optimade_maker.config import Config EXAMPLE_YAMLS = (Path(__file__).parent.parent / "examples").glob("*/optimade.yaml")