Safir

Latest version: v6.4.0

Safety actively analyzes 666166 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 8

6.4.0

New features

- Add support functions for using Alembic to manage database schema migrations and to verify that the current database schema matches the expectations of the running application. The support in Safir is designed to use asyncpg for all database operations, which avoids having to add a separate dependency on a sync database client.
- Add Alembic schema management support to the UWS library. This support is likely temporary and will probably be replaced in the future with a standalone UWS database service.

<a id='changelog-6.3.0'></a>

6.3.0

New features

- `safir.logging` is now available as a separate PyPI package, `safir-logging`, so that it can be installed in environments where the full Safir dependency may be too heavy-weight or conflict with other packages. Packages that do depend on `safir` can and should ignore this change and continue to assume depending on `safir` will be sufficient to provide `safir.logging`.
- Allow the database URL passed to `DatabaseSessionDependency.initialize` to be a Pydantic `Url`. This simplifies logic for applications that use `EnvAsyncPostgresDsn` or other Pydantic URL types for their configuration.
- Allow the hook URL argument to `safir.testing.slack.mock_slack_webhook` to be a Pydantic `SecretStr`.

Bug fixes

- `safir.logging` previously exported a `logger_name` variable holding the logger name configured via `safir.logging.configure_logging`. This variable was never documented and was not intended for use outside of the library. It is no longer exported, has been renamed, and is now private to the library.
- Fix construction of an `Availability` object reporting problems with the UWS database layer to use the correct field names and data type for the model.

<a id='changelog-6.2.0'></a>

6.2.0

New features

- Add new `safir.uws` and `safir.arq.uws` modules that provide the framework of an IVOA Universal Worker Service implementation.
- Add new `safir.testing.uws` module that provides a mock UWS job runner for testing UWS applications.
- `safir.arq` is now available as a separate PyPI package, `safir-arq`, so that it can be installed in environments where the full Safir dependency may be too heavy-weight or conflict with other packages. The `safir[arq]` dependency will continue to work as before (by installing `safir-arq` behind the scenes).
- Add new `abort_job` method to instances of `safir.arq.ArqQueue`, which tells arq to abort a job that has been queued or in progress. To successfully abort a job that has already started, the arq worker must enable support for aborting jobs.
- Add new utility function `safir.arq.build_arq_redis_settings`, which constructs the `RedisSettings` object used to create an arq Redis queue from a Pydantic Redis DSN.
- Add new `safir.arq.WorkerSettings` class that models the acceptable parameters for an arq `WorkerSettings` object or class that Safir applications have needed.
- Add new `safir.pydantic.SecondsDatetime` and `safir.pydantic.HumanDatetime` types for use in Pydantic models. These behave the same as `datetime.timedelta` fields but use custom validation. Both support a stringified number of seconds as input, and the latter also supports the interval strings parsed by `safir.datetime.parse_timedelta`.
- Add new types `safir.pydantic.EnvAsyncPostgresDsn` and `safir.pydantic.EnvRedisDsn`, which validate PostgreSQL and Redis DSNs but rewrite them based on the environment variables set by tox-docker. Programs using these types for their configuration will therefore automatically honor tox-docker environment variables when running the test suite. `EnvAsyncPostgresDsn` also enforces that the scheme of the DSN is compatible with asyncpg and the Safir database support.
- Add the decorator `safir.database.retry_async_transaction`, which retries a function or method a configurable number of times if it raises a SQLAlchemy exception from the underlying database API. This is primarily intended to retry database operations aborted due to transaction isolation.
- `safir.database.create_database_engine` now accepts the database URL as a Pydantic `Url` as well as a `str`.
- Allow the Slack webhook URL argument to `SlackWebhookClient` and `SlackRouteErrorHandler` to be given as a Pydantic `SecretStr` instead of a `str`. This simplifies code in applications that get that value from a secret.

Other changes

- Safir is now built with [nox](https://nox.thea.codes/en/stable/index.html) instead of [tox](https://tox.wiki/).

<a id='changelog-6.1.0'></a>

6.1.0

New features

- Add `pull_requests` to `GitHubCheckSuiteModel` to capture info about any pull requests associated with a GitHub check suite event.

<a id='changelog-6.0.0'></a>

6.0.0

Backwards-incompatible changes

- Drop `safir.database.create_sync_session`. This was only used by services that used Dramatiq for task management, since Dramatiq is sync-only. Services based on Safir should switch to arq and use only async database connections.
- Drop `DatabaseSessionDependency.override_engine`. This was used for Gafaelfawr to share a database engine across all tests for speed, but this technique breaks with current versions of pytest-asyncio and is no longer used or safe to use.

New features

- Allow the database password to be passed to `create_database_engine` and `DatabaseSessionDependency.initialize` as a Pydantic `SecretStr`.
- Add new function `safir.datetime.parse_timedelta`, which parses a human-friendly syntax for specifying time durations into a Python `datetime.timedelta`.
- Add support for `gs` URLs to `safir.gcs.SignedURLService`.
- Support pickling of `SlackException` so that subclasses of it can be thrown by arq workers and unpickled correctly when retrieving results.

Bug fixes

- Correctly honor the `default_queue_name` argument to `RedisArqQueue.initialize`.

<a id='changelog-5.2.2'></a>

5.2.2

Bug fixes

- Ensure that per-request database sessions provided by `db_session_dependency` are cleaned up even if the request aborts with an uncaught exception.

<a id='changelog-5.2.1'></a>

Page 1 of 8

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.