From bd77626cac8cbd85498cdddef383bbb24876e409 Mon Sep 17 00:00:00 2001 From: Alex Hadley Date: Tue, 16 Apr 2024 14:38:59 -0700 Subject: [PATCH] Rename package from datalogger to datalogs --- .github/workflows/ci.yml | 2 +- .github/workflows/github-pages.yml | 2 +- CHANGELOG.md | 18 +++++++++------ README.md | 10 ++++----- datalogger/__init__.py | 17 -------------- datalogs/__init__.py | 17 ++++++++++++++ {datalogger => datalogs}/_get_filename.py | 0 {datalogger => datalogs}/_load_log.py | 2 +- {datalogger => datalogs}/_logger.py | 8 +++---- {datalogger => datalogs}/_logs.py | 4 ++-- {datalogger => datalogs}/_variables.py | 0 {datalogger => datalogs}/py.typed | 0 docs/api-reference.md | 8 +++---- docs/conf.py | 2 +- docs/index.md | 2 +- docs/usage.md | 27 +++++++++++------------ pyproject.toml | 4 ++-- tests/conftest.py | 2 +- tests/test_get_filename.py | 4 ++-- tests/test_load_log.py | 4 ++-- tests/test_logger.py | 6 ++--- tests/test_logs.py | 4 ++-- tests/test_variables.py | 4 ++-- 23 files changed, 75 insertions(+), 72 deletions(-) delete mode 100644 datalogger/__init__.py create mode 100644 datalogs/__init__.py rename {datalogger => datalogs}/_get_filename.py (100%) rename {datalogger => datalogs}/_load_log.py (93%) rename {datalogger => datalogs}/_logger.py (97%) rename {datalogger => datalogs}/_logs.py (98%) rename {datalogger => datalogs}/_variables.py (100%) rename {datalogger => datalogs}/py.typed (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a499221..e831d7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: env: POETRY_VERSION: "1.8.2" MAIN_PYTHON_VERSION: "3.9" - PACKAGE_NAME: "datalogger" + PACKAGE_NAME: "datalogs" jobs: ci: diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 7a4365f..2fa259e 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -5,7 +5,7 @@ on: workflow_dispatch env: POETRY_VERSION: "1.8.2" PYTHON_VERSION: "3.9" - PACKAGE_NAME: "datalogger" + PACKAGE_NAME: "datalogs" PACKAGE_VERSION: "0.3.2" jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index 080fe41..a08a613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed + +- Rename package from `datalogger` to `datalogs` (since datalogger was taken on PyPI). + ## [0.3.2] (Mar 27 2024) ### Changed @@ -64,10 +68,10 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Function `load_log()` to load log files. - Initial documentation website. -[unreleased]: https://github.com/PainterQubits/datalogger/compare/v0.3.2...main -[0.3.2]: https://github.com/PainterQubits/datalogger/releases/tag/v0.3.2 -[0.3.1]: https://github.com/PainterQubits/datalogger/releases/tag/v0.3.1 -[0.3.0]: https://github.com/PainterQubits/datalogger/releases/tag/v0.3.0 -[0.2.0]: https://github.com/PainterQubits/datalogger/releases/tag/v0.2.0 -[0.1.1]: https://github.com/PainterQubits/datalogger/releases/tag/v0.1.1 -[0.1.0]: https://github.com/PainterQubits/datalogger/releases/tag/v0.1.0 +[unreleased]: https://github.com/PainterQubits/datalogs/compare/v0.3.2...main +[0.3.2]: https://github.com/PainterQubits/datalogs/releases/tag/v0.3.2 +[0.3.1]: https://github.com/PainterQubits/datalogs/releases/tag/v0.3.1 +[0.3.0]: https://github.com/PainterQubits/datalogs/releases/tag/v0.3.0 +[0.2.0]: https://github.com/PainterQubits/datalogs/releases/tag/v0.2.0 +[0.1.1]: https://github.com/PainterQubits/datalogs/releases/tag/v0.1.1 +[0.1.0]: https://github.com/PainterQubits/datalogs/releases/tag/v0.1.0 diff --git a/README.md b/README.md index 5343d0b..ae5b09c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DataLogger +# DataLogs @@ -10,17 +10,17 @@ Python package for logging data from scientific experiments. -Install the latest version of DataLogger using pip: +Install the latest version of DataLogs using pip: ``` -pip install -U datalogger --extra-index-url https://painterqubits.github.io/datalogger/releases +pip install -U datalogs --extra-index-url https://painterqubits.github.io/datalogs/releases ``` To install along with [ParamDB] for support for tagging logs with the latest commit ID, -DataLogger can be installed with the `paramdb` extra: +DataLogs can be installed with the `paramdb` extra: ``` -pip install -U "datalogger[paramdb]" --extra-index-url https://painterqubits.github.io/datalogger/releases +pip install -U "datalogs[paramdb]" --extra-index-url https://painterqubits.github.io/datalogs/releases ``` [ParamDB]: https://paramdb.readthedocs.io/en/stable/ diff --git a/datalogger/__init__.py b/datalogger/__init__.py deleted file mode 100644 index 20cb8be..0000000 --- a/datalogger/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -"""Data logger for scientific experiments.""" - -from datalogger._variables import Coord, DataVar -from datalogger._logs import LogMetadata, DataLog, DictLog -from datalogger._logger import LoggedProp, Logger -from datalogger._load_log import load_log - -__all__ = [ - "Coord", - "DataVar", - "LogMetadata", - "DataLog", - "DictLog", - "LoggedProp", - "Logger", - "load_log", -] diff --git a/datalogs/__init__.py b/datalogs/__init__.py new file mode 100644 index 0000000..52a5b50 --- /dev/null +++ b/datalogs/__init__.py @@ -0,0 +1,17 @@ +"""Data logger for scientific experiments.""" + +from datalogs._variables import Coord, DataVar +from datalogs._logs import LogMetadata, DataLog, DictLog +from datalogs._logger import LoggedProp, Logger +from datalogs._load_log import load_log + +__all__ = [ + "Coord", + "DataVar", + "LogMetadata", + "DataLog", + "DictLog", + "LoggedProp", + "Logger", + "load_log", +] diff --git a/datalogger/_get_filename.py b/datalogs/_get_filename.py similarity index 100% rename from datalogger/_get_filename.py rename to datalogs/_get_filename.py diff --git a/datalogger/_load_log.py b/datalogs/_load_log.py similarity index 93% rename from datalogger/_load_log.py rename to datalogs/_load_log.py index 563c10c..d2c4c70 100644 --- a/datalogger/_load_log.py +++ b/datalogs/_load_log.py @@ -2,7 +2,7 @@ from __future__ import annotations import os -from datalogger._logs import DataLog, DictLog +from datalogs._logs import DataLog, DictLog def load_log(path: str) -> DataLog | DictLog: diff --git a/datalogger/_logger.py b/datalogs/_logger.py similarity index 97% rename from datalogger/_logger.py rename to datalogs/_logger.py index ee68967..d0dcd5e 100644 --- a/datalogger/_logger.py +++ b/datalogs/_logger.py @@ -8,9 +8,9 @@ from datetime import datetime, timezone import numpy as np import pandas as pd # type: ignore -from datalogger._variables import Coord, DataVar -from datalogger._logs import LogMetadata, DataLog, DictLog -from datalogger._get_filename import get_filename +from datalogs._variables import Coord, DataVar +from datalogs._logs import LogMetadata, DataLog, DictLog +from datalogs._get_filename import get_filename try: from paramdb import ParamDB @@ -277,7 +277,7 @@ def log_props( a JSON file, and return a :py:class:`DictLog` with this data and metadata. Only properties that have been marked with a - :py:const:`~datalogger._logger.LoggedProp` type hint at the top of the class + :py:const:`~datalogs._logger.LoggedProp` type hint at the top of the class definition will be saved. For example:: class Example: diff --git a/datalogger/_logs.py b/datalogs/_logs.py similarity index 98% rename from datalogger/_logs.py rename to datalogs/_logs.py index 62ce0cc..1f4434b 100644 --- a/datalogger/_logs.py +++ b/datalogs/_logs.py @@ -15,8 +15,8 @@ from textwrap import indent from typing_extensions import Self import xarray as xr -from datalogger._variables import Coord, DataVar -from datalogger._get_filename import get_filename +from datalogs._variables import Coord, DataVar +from datalogs._get_filename import get_filename _T = TypeVar("_T") diff --git a/datalogger/_variables.py b/datalogs/_variables.py similarity index 100% rename from datalogger/_variables.py rename to datalogs/_variables.py diff --git a/datalogger/py.typed b/datalogs/py.typed similarity index 100% rename from datalogger/py.typed rename to datalogs/py.typed diff --git a/docs/api-reference.md b/docs/api-reference.md index a1e5ead..ee9353f 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -1,19 +1,19 @@ # API Reference -```{py:currentmodule} datalogger +```{py:currentmodule} datalogs ``` -All of the following can be imported from `datalogger`. +All of the following can be imported from `datalogs`. ## Logger ```{eval-rst} .. autoclass:: Logger -.. py:currentmodule:: datalogger._logger +.. py:currentmodule:: datalogs._logger .. autoclass:: LoggedProp -.. py:currentmodule:: datalogger +.. py:currentmodule:: datalogs ``` ## Load Log diff --git a/docs/conf.py b/docs/conf.py index e1e2fdc..905c1c1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,7 @@ # See https://www.sphinx-doc.org/en/master/usage/configuration.html for all options # Project information -project = "DataLogger" +project = "DataLogs" copyright = "2023–2024, California Institute of Technology" author = "Alex Hadley" release = "0.3.2" diff --git a/docs/index.md b/docs/index.md index 5eba8cf..eaea43c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,4 +1,4 @@ -# DataLogger +# DataLogs ```{include} ../README.md :start-after: diff --git a/docs/usage.md b/docs/usage.md index ceb0a57..e54a55a 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -1,6 +1,6 @@ # Usage -```{py:currentmodule} datalogger +```{py:currentmodule} datalogs ``` @@ -19,13 +19,12 @@ os.chdir(tmp_dir.name) ## Background -DataLogger is Python package to log array and dictionary data from scientific -experiments. These logs are stored in files (netCDF for array data and JSON for -dictionary data). The log files are organized within a nested directory structure and -tagged with metadata, such as timestamp or optionally a commit ID from a [ParamDB] -database. +DataLogs is Python package to log array and dictionary data from scientific experiments. +These logs are stored in files (netCDF for array data and JSON for dictionary data). The +log files are organized within a nested directory structure and tagged with metadata, such +as timestamp or optionally a commit ID from a [ParamDB] database. -The original purpose of DataLogger was to store logs from graph calibration experiments, +The original purpose of DataLogs was to store logs from graph calibration experiments, where directories correspond to nodes in a graph, so the examples below are based on this application. However, the core functionality is very general. @@ -38,7 +37,7 @@ To log data, we first have to create a root {py:class}`Logger` object, passing t does not exist. ```{jupyter-execute} -from datalogger import Logger +from datalogs import Logger root_logger = Logger("data_logs") ``` @@ -107,12 +106,12 @@ To learn more about Xarray data, see [Data Structures] in the Xarray user guide. ``` To aid in creating [`xarray.Dataset`] objects and to enforce certain conventions, -DataLogger provides {py:class}`Coord` as a wrapper for an Xarray coordinate and +DataLogs provides {py:class}`Coord` as a wrapper for an Xarray coordinate and {py:class}`DataVar` as a wrapper for a Xarray data variable. We can create a data log using these objects and {py:meth}`Logger.log_data`. ```{jupyter-execute} -from datalogger import Coord, DataVar +from datalogs import Coord, DataVar times = [1, 2, 3] signal = [10, 20, 30] @@ -158,7 +157,7 @@ display_tree("data_logs") ### Property Logs Property logs automatically store the properties of an object within a dictionary log. -Only properties marked with the type hint {py:class}`~datalogger._logger.LoggedProp` will +Only properties marked with the type hint {py:class}`~datalogs._logger.LoggedProp` will be saved. We can create a property log using {py:meth}`Logger.log_props`. ```{note} @@ -168,7 +167,7 @@ the variable, which is only used by code analysis tools. ```{jupyter-execute} from typing import Optional -from datalogger import LoggedProp +from datalogs import LoggedProp class SpecNode: _element: LoggedProp @@ -201,7 +200,7 @@ Logs can be loaded by passing a file path to {py:func}`load_log`. We can also us also be passed in directly if known.) ```{jupyter-execute} -from datalogger import load_log +from datalogs import load_log q1_spec_signal_log = load_log(node_logger.file_path("q1_spec_signal.nc")) q1_spec_frequency_log = load_log(node_logger.file_path("q1_spec_frequency.json")) @@ -214,7 +213,7 @@ already infers the log type from the file extension, but is useful for static ty checking when the log type is known. ```{jupyter-execute} -from datalogger import DataLog, DictLog +from datalogs import DataLog, DictLog q1_spec_signal_log = DataLog.load(node_logger.file_path("q1_spec_signal.nc")) q1_spec_frequency_log = DictLog.load(node_logger.file_path("q1_spec_frequency.json")) diff --git a/pyproject.toml b/pyproject.toml index 8c4240a..3b7356a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,13 +3,13 @@ requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.poetry] -name = "datalogger" +name = "datalogs" version = "0.3.2" description = "Python package for logging data from scientific experiments." authors = ["Alex Hadley "] license = "BSD-3-Clause" readme = "README.md" -repository = "https://github.com/PainterQubits/datalogger" +repository = "https://github.com/PainterQubits/datalogs" [tool.poetry.dependencies] python = "^3.9" diff --git a/tests/conftest.py b/tests/conftest.py index 4af855a..523821b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,7 +8,7 @@ import xarray as xr import pytest from paramdb import ParamDB -from datalogger import Coord, DataVar, LogMetadata, DataLog, DictLog, Logger +from datalogs import Coord, DataVar, LogMetadata, DataLog, DictLog, Logger @pytest.fixture(name="cd_tempdir") diff --git a/tests/test_get_filename.py b/tests/test_get_filename.py index 5fa52c1..46c26b4 100644 --- a/tests/test_get_filename.py +++ b/tests/test_get_filename.py @@ -1,10 +1,10 @@ -"""Tests for datalogger._get_filename.""" +"""Tests for datalogs._get_filename.""" from __future__ import annotations import os from datetime import datetime import pytest -from datalogger._get_filename import get_filename +from datalogs._get_filename import get_filename def new_file(path: str) -> None: diff --git a/tests/test_load_log.py b/tests/test_load_log.py index ba700d3..40318d9 100644 --- a/tests/test_load_log.py +++ b/tests/test_load_log.py @@ -1,10 +1,10 @@ -"""Tests for datalogger._load_log.""" +"""Tests for datalogs._load_log.""" from __future__ import annotations from typing import Any import xarray.testing import pytest -from datalogger import Logger, Coord, DataVar, DataLog, DictLog, load_log +from datalogs import Logger, Coord, DataVar, DataLog, DictLog, load_log @pytest.mark.usefixtures("cd_tempdir") diff --git a/tests/test_logger.py b/tests/test_logger.py index 618977f..1a41335 100644 --- a/tests/test_logger.py +++ b/tests/test_logger.py @@ -1,4 +1,4 @@ -"""Tests for datalogger._logger.""" +"""Tests for datalogs._logger.""" # pylint: disable=too-few-public-methods # pylint: disable=missing-class-docstring @@ -17,8 +17,8 @@ import pytest from freezegun import freeze_time from paramdb import ParamDB -from datalogger._get_filename import get_filename -from datalogger import Coord, DataVar, LoggedProp, Logger +from datalogs._get_filename import get_filename +from datalogs import Coord, DataVar, LoggedProp, Logger PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}" diff --git a/tests/test_logs.py b/tests/test_logs.py index ee67aec..a1934ab 100644 --- a/tests/test_logs.py +++ b/tests/test_logs.py @@ -1,4 +1,4 @@ -"""Tests for datalogger._logs.""" +"""Tests for datalogs._logs.""" from __future__ import annotations from typing import Any @@ -10,7 +10,7 @@ import xarray as xr import xarray.testing import pytest -from datalogger import Coord, DataVar, LogMetadata, DataLog, DictLog +from datalogs import Coord, DataVar, LogMetadata, DataLog, DictLog def test_log_metadata_properties( diff --git a/tests/test_variables.py b/tests/test_variables.py index 4cd32e7..508f962 100644 --- a/tests/test_variables.py +++ b/tests/test_variables.py @@ -1,9 +1,9 @@ -"""Tests for datalogger._variables.""" +"""Tests for datalogs._variables.""" from __future__ import annotations from numpy.testing import assert_array_equal import xarray as xr -from datalogger import Coord, DataVar +from datalogs import Coord, DataVar def test_coord_name(coord: Coord) -> None: