diff --git a/CHANGELOG.md b/CHANGELOG.md index aaab69f69..c494e0183 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Write the date in place of the "Unreleased" in the case a new version is release ### Fixed - Adapt to change in dask public API in dask 2024.9.0. +- Address miscellaneous deprecations in dependencies. ## v0.1.0b8 (2024-09-06) diff --git a/tiled/_tests/test_sync.py b/tiled/_tests/test_sync.py index 468054618..9f52d412e 100644 --- a/tiled/_tests/test_sync.py +++ b/tiled/_tests/test_sync.py @@ -65,7 +65,7 @@ def populate_internal(client): awkward.Array([1, [2, 3]]), key="d", metadata={"color": "red"}, specs=["alpha"] ) # sparse - coo = sparse.COO(coords=[[2, 5]], data=[1.3, 7.5], shape=(10,)) + coo = sparse.COO(coords=numpy.array([[2, 5]]), data=[1.3, 7.5], shape=(10,)) client.write_sparse(key="e", coords=coo.coords, data=coo.data, shape=coo.shape) # nested diff --git a/tiled/adapters/tiff.py b/tiled/adapters/tiff.py index 94a7f7e0c..2805ca35f 100644 --- a/tiled/adapters/tiff.py +++ b/tiled/adapters/tiff.py @@ -242,10 +242,10 @@ def read(self, slice: Optional[NDSlice] = ...) -> NDArray[Any]: return self._seq.asarray() if isinstance(slice, int): # e.g. read(slice=0) -- return an entire image - return tifffile.TiffFile(self._seq.files[slice]).asarray() + return tifffile.TiffFile(self._seq[slice]).asarray() if isinstance(slice, builtins.slice): # e.g. read(slice=(...)) -- return a slice along the image axis - return tifffile.TiffSequence(self._seq.files[slice]).asarray() + return tifffile.TiffSequence(self._seq[slice]).asarray() if isinstance(slice, tuple): if len(slice) == 0: return self._seq.asarray() @@ -255,10 +255,10 @@ def read(self, slice: Optional[NDSlice] = ...) -> NDArray[Any]: # Could be int or slice (0, slice(...)) or (0,....); the_rest is converted to a list if isinstance(image_axis, int): # e.g. read(slice=(0, ....)) - arr = tifffile.TiffFile(self._seq.files[image_axis]).asarray() + arr = tifffile.TiffFile(self._seq[image_axis]).asarray() elif image_axis is Ellipsis: # Return all images - arr = tifffile.TiffSequence(self._seq.files).asarray() + arr = tifffile.TiffSequence(self._seq).asarray() the_rest.insert(0, Ellipsis) # Include any leading dimensions elif isinstance(image_axis, builtins.slice): arr = self.read(slice=image_axis) diff --git a/tiled/authn_database/core.py b/tiled/authn_database/core.py index c03d87b58..1e37d0b4a 100644 --- a/tiled/authn_database/core.py +++ b/tiled/authn_database/core.py @@ -1,6 +1,6 @@ +import datetime import hashlib import uuid as uuid_module -from datetime import datetime from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.future import select @@ -77,7 +77,7 @@ async def purge_expired(db, cls): """ Remove expired entries. """ - now = datetime.utcnow() + now = datetime.datetime.now(datetime.UTC) num_expired = 0 statement = ( select(cls) @@ -146,7 +146,7 @@ async def lookup_valid_session(db, session_id): return None if ( session.expiration_time is not None - and session.expiration_time < datetime.utcnow() + and session.expiration_time < datetime.datetime.now(datetime.UTC) ): await db.delete(session) await db.commit() @@ -171,7 +171,7 @@ async def lookup_valid_pending_session_by_device_code(db, device_code): return None if ( pending_session.expiration_time is not None - and pending_session.expiration_time < datetime.utcnow() + and pending_session.expiration_time < datetime.datetime.now(datetime.UTC) ): await db.delete(pending_session) await db.commit() @@ -189,7 +189,7 @@ async def lookup_valid_pending_session_by_user_code(db, user_code): return None if ( pending_session.expiration_time is not None - and pending_session.expiration_time < datetime.utcnow() + and pending_session.expiration_time < datetime.datetime.now(datetime.UTC) ): await db.delete(pending_session) await db.commit() @@ -228,7 +228,7 @@ async def lookup_valid_api_key(db, secret): Look up an API key. Ensure that it is valid. """ - now = datetime.utcnow() + now = datetime.datetime.now(datetime.UTC) hashed_secret = hashlib.sha256(secret).digest() api_key = ( await db.execute( diff --git a/tiled/examples/xdi.py b/tiled/examples/xdi.py index 828ad2c52..89e5b03c4 100644 --- a/tiled/examples/xdi.py +++ b/tiled/examples/xdi.py @@ -80,7 +80,7 @@ def read_xdi(data_uri, structure=None, metadata=None, specs=None, access_policy= # TODO validate - df = pd.read_table(file, delim_whitespace=True, names=col_labels) + df = pd.read_table(file, sep=r"\s+", names=col_labels) return DataFrameAdapter.from_pandas( df, diff --git a/tiled/server/app.py b/tiled/server/app.py index 1f991d666..65a67ecb8 100644 --- a/tiled/server/app.py +++ b/tiled/server/app.py @@ -270,9 +270,9 @@ async def index( principal=Security(get_current_principal, scopes=[]), ): return templates.TemplateResponse( + request, "index.html", { - "request": request, # This is used to construct the link to the React UI. "root_url": get_root_url(request), # If defined, this adds a Binder link to the page. diff --git a/tiled/server/authentication.py b/tiled/server/authentication.py index 3a4fa5afa..3ac2f623f 100644 --- a/tiled/server/authentication.py +++ b/tiled/server/authentication.py @@ -1,9 +1,9 @@ +import datetime import enum import hashlib import secrets import uuid as uuid_module import warnings -from datetime import datetime, timedelta from pathlib import Path from typing import Optional @@ -67,7 +67,7 @@ from .utils import API_KEY_COOKIE_NAME, get_authenticators, get_base_url ALGORITHM = "HS256" -UNIT_SECOND = timedelta(seconds=1) +UNIT_SECOND = datetime.timedelta(seconds=1) # Max API keys and Sessions allowed to Principal. # This is here for at least two reasons: @@ -77,13 +77,13 @@ API_KEY_LIMIT = 100 SESSION_LIMIT = 200 -DEVICE_CODE_MAX_AGE = timedelta(minutes=15) +DEVICE_CODE_MAX_AGE = datetime.timedelta(minutes=15) DEVICE_CODE_POLLING_INTERVAL = 5 # seconds def utcnow(): "UTC now with second resolution" - return datetime.utcnow().replace(microsecond=0) + return datetime.datetime.now(datetime.UTC).replace(microsecond=0) class Mode(enum.Enum): @@ -759,7 +759,9 @@ async def generate_apikey(db, principal, apikey_params, request): ), ) if apikey_params.expires_in is not None: - expiration_time = utcnow() + timedelta(seconds=apikey_params.expires_in) + expiration_time = utcnow() + datetime.timedelta( + seconds=apikey_params.expires_in + ) else: expiration_time = None # The standard 32 byes of entropy, diff --git a/tiled/server/core.py b/tiled/server/core.py index 88e3d20da..81459302b 100644 --- a/tiled/server/core.py +++ b/tiled/server/core.py @@ -1,5 +1,6 @@ import collections.abc import dataclasses +import datetime import itertools import math import operator @@ -8,7 +9,6 @@ import types import uuid from collections import defaultdict -from datetime import datetime, timedelta from hashlib import md5 from typing import Any @@ -225,7 +225,9 @@ async def construct_entries_response( keys = tree.keys()[offset : offset + limit] # noqa: E203 items = [(key, None) for key in keys] # This value will not leak out. It just used to seed comparisons. - metadata_stale_at = datetime.utcnow() + timedelta(days=1_000_000) + metadata_stale_at = datetime.datetime.now(datetime.UTC) + datetime.timedelta( + days=1_000_000 + ) must_revalidate = getattr(tree, "must_revalidate", True) for key, entry in items: resource = await construct_resource( diff --git a/tiled/server/router.py b/tiled/server/router.py index a81a2fea3..81438c9e8 100644 --- a/tiled/server/router.py +++ b/tiled/server/router.py @@ -1,9 +1,9 @@ import dataclasses +import datetime import inspect import os import re import warnings -from datetime import datetime, timedelta from functools import partial from pathlib import Path from typing import Any, List, Optional @@ -149,7 +149,7 @@ async def about( }, meta={"root_path": request.scope.get("root_path") or "" + "/api"}, ).model_dump(), - expires=datetime.utcnow() + timedelta(seconds=600), + expires=datetime.datetime.now(datetime.UTC) + datetime.timedelta(seconds=600), )