From 6d5e43891c36c831e1aa176d85d62a0b619c7ee5 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 11 Jul 2024 21:47:25 +0200 Subject: [PATCH 1/6] chore(deps): support xopen major version 2 See xopen changelog: https://github.com/pycompression/xopen/blob/main/README.rst#v200-2024-03-26 Maintain compatibility with v1 and v2, deprecate v1 with period of 4 months and requiring major version bump --- CHANGES.md | 5 +++++ DEPRECATED.md | 4 ++++ augur/io/file.py | 16 +++++++++++++++- setup.py | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b78fdeecd..e6aef8934 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,11 @@ ## __NEXT__ +### Features + +* Support xopen major version 2. [#1532][] (@corneliusroemer) + +[#1532]: https://github.com/nextstrain/augur/pull/1532 ## 25.0.0 (10 July 2024) diff --git a/DEPRECATED.md b/DEPRECATED.md index 772b428c0..2e0026950 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -4,6 +4,10 @@ These features are deprecated, which means they are no longer maintained and will go away in a future major version of Augur. They are currently still available for backwards compatibility, but should not be used in new code. +## `xopen` major version 1 + +*Deprecated in version __NEXT__ (Month Year). Planned for removal at the earliest with next major version and not before November 2024* + ## `augur parse` preference of `name` over `strain` as the sequence ID field *Deprecated in February 2024. Planned to be reordered June 2024 or after.* diff --git a/augur/io/file.py b/augur/io/file.py index 5b8a7bc13..11966b7ab 100644 --- a/augur/io/file.py +++ b/augur/io/file.py @@ -2,9 +2,23 @@ from contextlib import contextmanager from io import IOBase from textwrap import dedent -from xopen import PipedCompressionReader, PipedCompressionWriter, xopen + +from xopen import xopen + from augur.errors import AugurError +# Workaround to maintain compatibility with both xopen v1 and v2 +# In some time, we can drop support for xopen v1 +# by removing the try-except block and using +# _PipedCompressionProgram directly +try: + from xopen import _PipedCompressionProgram as PipedCompressionReader + from xopen import _PipedCompressionProgram as PipedCompressionWriter +except ImportError: + from xopen import ( # type: ignore[attr-defined, no-redef] + PipedCompressionReader, + PipedCompressionWriter, + ) ENCODING = "utf-8" diff --git a/setup.py b/setup.py index efc46cd06..a0ea8bc2c 100644 --- a/setup.py +++ b/setup.py @@ -65,7 +65,7 @@ "phylo-treetime >=0.11.2, <0.12", "pyfastx >=1.0.0, <3.0", "scipy ==1.*", - "xopen[zstd] >=1.7.0, ==1.*" + "xopen[zstd] >=1.7.0, <3" ], extras_require = { 'dev': [ From 1124e2f1ac19d8895700580dbcf63e31b6ea0f4d Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 11 Jul 2024 23:30:17 +0200 Subject: [PATCH 2/6] Add deprecation todo to setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a0ea8bc2c..14ca3ee5e 100644 --- a/setup.py +++ b/setup.py @@ -65,7 +65,7 @@ "phylo-treetime >=0.11.2, <0.12", "pyfastx >=1.0.0, <3.0", "scipy ==1.*", - "xopen[zstd] >=1.7.0, <3" + "xopen[zstd] >=1.7.0, <3" # TODO: Deprecated, remove v1 support around November 2024 ], extras_require = { 'dev': [ From a1b73de0125ea15e713570450d06a806fba61cea Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 11 Jul 2024 23:31:24 +0200 Subject: [PATCH 3/6] Update DEPRECATED.md --- DEPRECATED.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPRECATED.md b/DEPRECATED.md index 2e0026950..090326fe8 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -6,7 +6,7 @@ available for backwards compatibility, but should not be used in new code. ## `xopen` major version 1 -*Deprecated in version __NEXT__ (Month Year). Planned for removal at the earliest with next major version and not before November 2024* +*Deprecated in version __NEXT__ (July 2024). Planned for removal at the earliest with major version 26 not before November 2024* ## `augur parse` preference of `name` over `strain` as the sequence ID field From 00287b8c2997dfdf02ea2b7a868db9815d4eef57 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 11 Jul 2024 23:32:34 +0200 Subject: [PATCH 4/6] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index e6aef8934..e0ecf7ea6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ ### Features -* Support xopen major version 2. [#1532][] (@corneliusroemer) +* Support xopen major version 2. Deprecate v1. Schedule for removal around November 2024. [#1532][] (@corneliusroemer) [#1532]: https://github.com/nextstrain/augur/pull/1532 From 2ceacbff57b1270b5014697d78960604b5ddb00e Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 11 Jul 2024 23:33:07 +0200 Subject: [PATCH 5/6] Update augur/io/file.py --- augur/io/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/augur/io/file.py b/augur/io/file.py index 11966b7ab..e0fec2b2e 100644 --- a/augur/io/file.py +++ b/augur/io/file.py @@ -8,7 +8,7 @@ from augur.errors import AugurError # Workaround to maintain compatibility with both xopen v1 and v2 -# In some time, we can drop support for xopen v1 +# Around November 2024, we shall drop support for xopen v1 # by removing the try-except block and using # _PipedCompressionProgram directly try: From 9064b5590f65a2385ad3efc419a7ce486c5e3894 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Fri, 12 Jul 2024 00:28:17 +0200 Subject: [PATCH 6/6] Update augur/io/file.py Co-authored-by: Victor Lin <13424970+victorlin@users.noreply.github.com> --- augur/io/file.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/augur/io/file.py b/augur/io/file.py index e0fec2b2e..1aa5f59af 100644 --- a/augur/io/file.py +++ b/augur/io/file.py @@ -2,9 +2,7 @@ from contextlib import contextmanager from io import IOBase from textwrap import dedent - from xopen import xopen - from augur.errors import AugurError # Workaround to maintain compatibility with both xopen v1 and v2