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
20 changes: 11 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

exclude: ^src/pscpy/sample/.*$

repos:
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
rev: "1.19.1"
hooks:
- id: blacken-docs
additional_dependencies: [black==24.*]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
rev: "v5.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -33,27 +35,27 @@ repos:
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.1"
rev: "v0.8.4"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v18.1.4"
rev: "v19.1.5"
hooks:
- id: clang-format
types_or: [c++, c, cuda]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.9.0"
rev: "v1.13.0"
hooks:
- id: mypy
files: src|tests
Expand All @@ -64,7 +66,7 @@ repos:
- adios2

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
rev: "v2.3.0"
hooks:
- id: codespell

Expand All @@ -87,13 +89,13 @@ repos:
- id: cmake-format

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.16"
rev: "v0.23"
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.28.2"
rev: "0.30.0"
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
5 changes: 0 additions & 5 deletions CMakeLists.txt

This file was deleted.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Homepage = "https://github.com/psc-code/pscpy"
Discussions = "https://github.com/psc-code/pscpy/discussions"
Changelog = "https://github.com/psc-code/pscpy/releases"

[project.entry-points."xarray.backends"]
pscadios2_engine = "pscpy.pscadios2:PscAdios2BackendEntrypoint"

[build-system]
build-backend = "setuptools.build_meta"
Expand Down
5 changes: 5 additions & 0 deletions src/pscpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@

from __future__ import annotations

import pathlib

from pscpy import pscadios2 # noqa: F401

from ._version import version as __version__

sample_dir = pathlib.Path(__file__).parent / "sample"


__all__ = ["__version__"]
7 changes: 4 additions & 3 deletions src/pscpy/adios2py/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import os
from collections.abc import Collection
from types import TracebackType
from typing import Any, SupportsInt
Expand Down Expand Up @@ -109,10 +110,10 @@ def __repr__(self) -> str:
class FileState:
"""Collects the state of a `File` to reflect the fact that they are coupled."""

def __init__(self, filename: str) -> None:
def __init__(self, filename: str | os.PathLike[Any]) -> None:
self.io_name = f"io-{filename}"
self.io = _ad.declare_io(self.io_name)
self.engine = self.io.open(filename, adios2.bindings.Mode.Read)
self.engine = self.io.open(str(filename), adios2.bindings.Mode.Read)

@staticmethod
def is_open(maybe_state: FileState | None) -> TypeGuard[FileState]:
Expand All @@ -124,7 +125,7 @@ class File:

_state: FileState | None

def __init__(self, filename: str, mode: str = "r") -> None:
def __init__(self, filename: str | os.PathLike[Any], mode: str = "r") -> None:
logging.debug("adios2py: __init__ %s", filename)
assert mode == "r"
self._state = FileState(filename)
Expand Down
4 changes: 0 additions & 4 deletions src/pscpy/pscadios2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from typing_extensions import Never, override
from xarray.backends import CachingFileManager
from xarray.backends.common import (
BACKEND_ENTRYPOINTS,
AbstractDataStore,
BackendArray,
BackendEntrypoint,
Expand Down Expand Up @@ -198,6 +197,3 @@ def guess_can_open(self, filename_or_obj: str | os.PathLike[Any] | ReadBuffer[An
@override
def open_datatree(self, filename_or_obj: str | os.PathLike[Any] | ReadBuffer[Any] | AbstractDataStore, **kwargs: Any) -> DataTree:
raise NotImplementedError()


BACKEND_ENTRYPOINTS["pscadios2"] = ("pscpy", PscAdios2BackendEntrypoint)
Binary file added src/pscpy/sample/pfd.000000400.bp/data.0
Binary file not shown.
Binary file added src/pscpy/sample/pfd.000000400.bp/md.0
Binary file not shown.
Binary file added src/pscpy/sample/pfd.000000400.bp/md.idx
Binary file not shown.
6 changes: 6 additions & 0 deletions src/pscpy/sample/pfd.000000400.bp/profiling.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{ "rank": 0, "start": "Tue_Sep_27_10:16:01_2022", "threads": 1, "bytes": 590260, "mkdir_mus": 193, "memcpy_mus": 505340, "aggregation_mus": 0, "meta_sort_merge_mus": 320, "minmax_mus": 148649, "buffering_mus": 668923, "transport_0": { "type": "File_POSIX", "close_mus": 216, "write_mus": 643, "open_mus": 244 },"transport_1": { "type": "File_POSIX", "close_mus": 0, "write_mus": 41, "open_mus": 250 } },
{ "rank": 1, "start": "Tue_Sep_27_10:16:01_2022", "threads": 1, "bytes": 590193, "mkdir_mus": 201, "memcpy_mus": 505280, "aggregation_mus": 0, "meta_sort_merge_mus": 165, "minmax_mus": 147485, "buffering_mus": 667610, },
{ "rank": 2, "start": "Tue_Sep_27_10:16:01_2022", "threads": 1, "bytes": 590193, "mkdir_mus": 205, "memcpy_mus": 472637, "aggregation_mus": 0, "meta_sort_merge_mus": 52, "minmax_mus": 148323, "buffering_mus": 635610, },
{ "rank": 3, "start": "Tue_Sep_27_10:16:01_2022", "threads": 1, "bytes": 590193, "mkdir_mus": 201, "memcpy_mus": 484106, "aggregation_mus": 0, "meta_sort_merge_mus": 29, "minmax_mus": 148251, "buffering_mus": 647150, }
]
8 changes: 8 additions & 0 deletions tests/test_adios2py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from __future__ import annotations

import pscpy
from pscpy import adios2py


def test_adios2py_open():
adios2py.File(pscpy.sample_dir / "pfd.000000400.bp")
9 changes: 9 additions & 0 deletions tests/test_xarray_adios2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from __future__ import annotations

import xarray as xr

import pscpy


def test_open_dataset():
xr.open_dataset(pscpy.sample_dir / "pfd.000000400.bp", species_names=[], length=[10, 10, 10], corner=[0, 0, 0])
Loading