Skip to content

Commit

Permalink
Removed 3.9 artifacts, updated syntax (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-turner-1 authored Nov 19, 2024
1 parent 38d4c45 commit ed6f9f2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout source
Expand Down
21 changes: 0 additions & 21 deletions ci/environment-3.9.yml

This file was deleted.

9 changes: 4 additions & 5 deletions src/access_nri_intake/catalog/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""Manager for adding/updating intake sources in an intake-dataframe-catalog like the ACCESS-NRI catalog"""

import os
from typing import Optional, Union

import intake
from intake_dataframe_catalog.core import DfFileCatalog, DfFileCatalogError
Expand Down Expand Up @@ -63,10 +62,10 @@ def build_esm(
name: str,
description: str,
builder,
path: Union[str, list[str]],
path: str | list[str],
translator=DefaultTranslator,
metadata: Optional[dict] = None,
directory: Optional[str] = None,
metadata: dict | None = None,
directory: str | None = None,
overwrite: bool = False,
**kwargs,
):
Expand Down Expand Up @@ -131,7 +130,7 @@ def load(
path: str,
driver: str = "esm_datastore",
translator=DefaultTranslator,
metadata: Optional[dict] = None,
metadata: dict | None = None,
**kwargs,
):
"""
Expand Down
14 changes: 7 additions & 7 deletions src/access_nri_intake/catalog/translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from dataclasses import dataclass
from functools import partial
from typing import Callable, Optional
from typing import Callable

import pandas as pd
import tlz
Expand Down Expand Up @@ -120,7 +120,7 @@ def _default_translator(self, column: str) -> pd.Series:

return pd.Series([val] * len_df)

def translate(self, groupby: Optional[list[str]] = None) -> pd.DataFrame:
def translate(self, groupby: list[str] | None = None) -> pd.DataFrame:
"""
Return the translated :py:class:`~pandas.DataFrame` of metadata and merge into set of
set of rows with unique values of the columns specified.
Expand Down Expand Up @@ -168,7 +168,7 @@ def _unique_values(series):
return df[self.columns] # Preserve ordering

def set_dispatch(
self, core_colname: str, func: Callable, input_name: Optional[str] = None
self, core_colname: str, func: Callable, input_name: str | None = None
):
"""
Set a dispatch function for a column. Typically only required when either:
Expand Down Expand Up @@ -549,10 +549,10 @@ class _DispatchKeys:
Data class to store the keys for the dispatch dictionary in the Translator classes
"""

model: Optional[str] = None
realm: Optional[str] = None
frequency: Optional[str] = None
variable: Optional[str] = None
model: str | None = None
realm: str | None = None
frequency: str | None = None
variable: str | None = None


def _cmip_realm_translator(series) -> pd.Series:
Expand Down
23 changes: 10 additions & 13 deletions src/access_nri_intake/source/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import re
import traceback
from pathlib import Path
from typing import Optional, Union

import xarray as xr
from ecgtools.builder import INVALID_ASSET, TRACEBACK, Builder
Expand Down Expand Up @@ -58,14 +57,14 @@ class BaseBuilder(Builder):

def __init__(
self,
path: Union[str, list[str]],
path: str | list[str],
depth: int = 0,
exclude_patterns: Optional[list[str]] = None,
include_patterns: Optional[list[str]] = None,
exclude_patterns: list[str] | None = None,
include_patterns: list[str] | None = None,
data_format: str = "netcdf",
groupby_attrs: Optional[list[str]] = None,
aggregations: Optional[list[dict]] = None,
storage_options: Optional[dict] = None,
groupby_attrs: list[str] | None = None,
aggregations: list[dict] | None = None,
storage_options: dict | None = None,
joblib_parallel_kwargs: dict = {"n_jobs": multiprocessing.cpu_count()},
):
"""
Expand Down Expand Up @@ -120,7 +119,7 @@ def parse(self):
self._parse()
return self

def _save(self, name: str, description: str, directory: Optional[str]):
def _save(self, name: str, description: str, directory: str | None):
super().save(
name=name,
path_column_name=PATH_COLUMN,
Expand All @@ -135,9 +134,7 @@ def _save(self, name: str, description: str, directory: Optional[str]):
to_csv_kwargs={"compression": "gzip"},
)

def save(
self, name: str, description: str, directory: Optional[str] = None
) -> None:
def save(self, name: str, description: str, directory: str | None = None) -> None:
"""
Save datastore contents to a file.
Expand Down Expand Up @@ -221,10 +218,10 @@ def parser(file):
def parse_access_filename(
cls,
filename: str,
patterns: Optional[list[str]] = None,
patterns: list[str] | None = None,
frequencies: dict = FREQUENCIES,
redaction_fill: str = "X",
) -> tuple[str, Optional[str], Optional[str]]:
) -> tuple[str, str | None, str | None]:
"""
Parse an ACCESS model filename and return a file id and any time information
Expand Down
11 changes: 5 additions & 6 deletions src/access_nri_intake/source/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dataclasses import asdict, dataclass, field
from datetime import timedelta
from pathlib import Path
from typing import Optional, Union

import cftime
import xarray as xr
Expand All @@ -30,10 +29,10 @@ class _AccessNCFileInfo:
more explicit tests are probably more important than the slight redundancy.
"""

filename: Union[str, Path]
filename: str | Path
file_id: str
path: str
filename_timestamp: Optional[str]
filename_timestamp: str | None
frequency: str
start_date: str
end_date: str
Expand All @@ -43,7 +42,7 @@ class _AccessNCFileInfo:
variable_cell_methods: list[str]
variable_units: list[str]

def to_dict(self) -> dict[str, Union[str, list[str]]]:
def to_dict(self) -> dict[str, str | list[str]]:
"""
Return a dictionary representation of the NcFileInfo object
"""
Expand Down Expand Up @@ -139,7 +138,7 @@ def _guess_start_end_dates(ts, te, frequency):

def get_timeinfo(
ds: xr.Dataset,
filename_frequency: Optional[str],
filename_frequency: str | None,
time_dim: str,
) -> tuple[str, str, str]:
"""
Expand Down Expand Up @@ -177,7 +176,7 @@ def _todate(t):
time_format = "%Y-%m-%d, %H:%M:%S"
ts = None
te = None
frequency: Union[str, tuple[Optional[int], str]] = "fx"
frequency: str | tuple[int | None, str] = "fx"
has_time = time_dim in ds

if has_time:
Expand Down

0 comments on commit ed6f9f2

Please sign in to comment.