Skip to content

Commit b3ddfa0

Browse files
authored
Update Python support (#384)
* Update Python support * Add explicit sqlite dependency * Address comments * Add matrix testing * Additional fixes * Fixes 3rd try * Fixes 4th try * Fixes 5th try * Address comments but pip install fails * Implement suggestions from Claude * Functionality changes suggested by Claude * Doc version fix plus hpss_util fixes from Claude * Address further comments * Fix add_file
1 parent bc444ce commit b3ddfa0

File tree

9 files changed

+91
-124
lines changed

9 files changed

+91
-124
lines changed

.github/workflows/build_workflow.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,24 @@ jobs:
1919
- name: Checkout Code Repository
2020
uses: actions/checkout@v3
2121

22-
- name: Set up Python 3.9
22+
- name: Set up Python 3.13
2323
uses: actions/setup-python@v4
2424
with:
25-
python-version: 3.9
25+
python-version: "3.13"
2626

2727
# Run all pre-commit hooks on all the files.
2828
# Getting only staged files can be tricky in case a new PR is opened
2929
# since the action is run on a branch in detached head state.
3030
# This is the equivalent of running "pre-commit run --all-files" locally.
3131
# If you commit with the `--no-verify` flag, this check may fail.
3232
- name: Install and Run Pre-commit
33-
uses: pre-commit/[email protected].0
33+
uses: pre-commit/[email protected].1
3434

3535
build:
3636
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
python-version: ["3.11", "3.12", "3.13"]
3740
defaults:
3841
run:
3942
shell: bash -l {0}
@@ -44,11 +47,11 @@ jobs:
4447
- name: Cache Conda
4548
uses: actions/cache@v3
4649
env:
47-
CACHE_NUMBER: 0
50+
CACHE_NUMBER: 1 # Increment this to invalidate cache
4851
with:
4952
path: ~/conda_pkgs_dir
5053
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
51-
hashFiles('conda/dev.yml') }}
54+
hashFiles('conda/dev.yml') }}-python${{ matrix.python-version }}
5255

5356
- name: Build Conda Environment
5457
uses: conda-incubator/setup-miniconda@v3
@@ -57,13 +60,27 @@ jobs:
5760
miniforge-variant: Miniforge3
5861
miniforge-version: latest
5962
environment-file: conda/dev.yml
60-
channel-priority: strict
63+
channel-priority: flexible # Changed from strict to flexible
6164
auto-update-conda: true
65+
python-version: ${{ matrix.python-version }}
66+
channels: conda-forge
67+
use-only-tar-bz2: true
68+
69+
- name: Verify Environment and Fix Dependencies
70+
run: |
71+
conda info
72+
conda list
73+
# Ensure we have the right Python version
74+
python --version
75+
# Fix pip issues for Python 3.12+
76+
if [[ "${{ matrix.python-version }}" == "3.12" ]] || [[ "${{ matrix.python-version }}" == "3.13" ]]; then
77+
python -m ensurepip --upgrade || true
78+
python -m pip install --upgrade --force-reinstall pip setuptools wheel
79+
fi
6280
6381
- name: Install `zstash` Package
6482
run: |
65-
python -m pip install --upgrade pip
66-
pip install .
83+
python -m pip install .
6784
6885
- name: Run Tests
6986
run: |
@@ -77,7 +94,7 @@ jobs:
7794
defaults:
7895
run:
7996
shell: bash -l {0}
80-
timeout-minutes: 5
97+
timeout-minutes: 10 # Increased timeout for docs
8198
steps:
8299
- uses: actions/checkout@v3
83100
with:
@@ -87,11 +104,11 @@ jobs:
87104
- name: Cache Conda
88105
uses: actions/cache@v3
89106
env:
90-
CACHE_NUMBER: 0
107+
CACHE_NUMBER: 1 # Match the build job cache number
91108
with:
92109
path: ~/conda_pkgs_dir
93110
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
94-
hashFiles('conda/dev.yml') }}
111+
hashFiles('conda/dev.yml') }}-docs
95112

96113
- name: Build Conda Environment
97114
uses: conda-incubator/setup-miniconda@v3
@@ -100,8 +117,9 @@ jobs:
100117
miniforge-variant: Miniforge3
101118
miniforge-version: latest
102119
environment-file: conda/dev.yml
103-
channel-priority: strict
120+
channel-priority: flexible # Changed from strict to flexible
104121
auto-update-conda: true
122+
python-version: "3.13" # Use stable Python version for docs
105123

106124
# sphinx-multiversion allows for version docs.
107125
- name: Build Sphinx Docs

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ repos:
1212
exclude: conda/meta.yaml
1313

1414
- repo: https://github.com/psf/black
15-
rev: 24.10.0
15+
rev: 25.1.0
1616
hooks:
1717
- id: black
1818

1919
- repo: https://github.com/PyCQA/isort
20-
rev: 5.13.2
20+
rev: 6.0.1
2121
hooks:
2222
- id: isort
2323

2424
# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab
2525
# https://github.com/pre-commit/pre-commit/issues/1206
2626
- repo: https://github.com/pycqa/flake8
27-
rev: 7.1.1
27+
rev: 7.3.0
2828
hooks:
2929
- id: flake8
3030
args: ["--config=setup.cfg"]
3131
additional_dependencies: [flake8-isort]
3232
exclude: analysis_data_preprocess
3333

3434
- repo: https://github.com/pre-commit/mirrors-mypy
35-
rev: v1.11.2
35+
rev: v1.18.2
3636
hooks:
3737
- id: mypy
3838
args: ["--config=setup.cfg", "--install-types", "--non-interactive"]

conda/dev.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
name: zstash_dev
22
channels:
33
- conda-forge
4-
- defaults
54
dependencies:
65
# Base
76
# =================
8-
- pip=22.2.2
9-
- python=3.9.13
10-
- six=1.16.0
11-
- globus-sdk=3.15.0
7+
- pip
8+
- python >=3.11,<3.14
9+
- sqlite
10+
- six >=1.16.0
11+
- globus-sdk >=3.15.0
1212
# Developer Tools
1313
# =================
1414
# If versions are updated, also update 'rev' in `.pre-commit.config.yaml`
15-
- black=24.10.0
16-
- flake8=7.1.1
17-
- flake8-isort=6.1.1
18-
- mypy=1.11.2
19-
- pre-commit=4.0.1
20-
- tbump=6.9.0
15+
- black ==25.1.0
16+
- flake8 ==7.3.0
17+
- isort ==6.0.1
18+
- mypy ==1.18.2
19+
- pre-commit ==4.3.0
20+
- tbump >=6.9.0
2121
# Documentation
2222
# =================
2323
# If versions are updated, also update in `.github/workflows/workflow.yml`
24-
- jinja2<3.1
25-
- sphinx=5.2.3
26-
- sphinx-multiversion=0.2.4
27-
- sphinx_rtd_theme=1.0.0
24+
- jinja2 <3.1
25+
- sphinx >=5.2.0
26+
- sphinx-multiversion >=0.2.4
27+
- sphinx_rtd_theme >=1.0.0
2828
# Need to pin docutils because 0.17 has a bug with unordered lists
2929
# https://github.com/readthedocs/sphinx_rtd_theme/issues/1115
30-
- docutils=0.16
31-
prefix: /opt/miniconda3/envs/zstash_dev
30+
- docutils >=0.16,<0.17

conda/meta.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ exclude =
4646
venv
4747

4848
[mypy]
49-
python_version = 3.9
49+
python_version = 3.13
5050
check_untyped_defs = True
5151
ignore_missing_imports = True
5252
warn_unused_ignores = True

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
88
description="Long term HPSS archiving software for E3SM",
99
packages=find_packages(include=["zstash", "zstash.*"]),
10-
python_requires=">=3.9",
10+
python_requires=">=3.11,<3.14",
1111
entry_points={"console_scripts": ["zstash=zstash.main:main"]},
1212
)

zstash/extract.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ def extractFiles( # noqa: C901
591591
try:
592592
# Seek file position
593593
if tar.fileobj is not None:
594-
fileobj: _io.BufferedReader = tar.fileobj
594+
fileobj = tar.fileobj
595595
else:
596596
raise TypeError("Invalid tar.fileobj={}".format(tar.fileobj))
597597
fileobj.seek(files_row.offset)
@@ -665,7 +665,7 @@ def extractFiles( # noqa: C901
665665
# relying here on 'touch'. This is not the prettiest solution.
666666
# Maybe a better one can be implemented later.
667667
if tarinfo.issym():
668-
tmp1: int = tarinfo.mtime
668+
tmp1 = tarinfo.mtime
669669
tmp2: datetime = datetime.fromtimestamp(tmp1)
670670
tmp3: str = tmp2.strftime("%Y%m%d%H%M.%S")
671671
os.system("touch -h -t %s %s" % (tmp3, tarinfo.name))

zstash/globus.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def globus_activate(hpss: str):
5757

5858

5959
def file_exists(name: str) -> bool:
60-
global archive_directory_listing
6160

6261
for entry in archive_directory_listing:
6362
if entry.get("name") == name:
@@ -72,9 +71,6 @@ def file_exists(name: str) -> bool:
7271
def globus_transfer( # noqa: C901
7372
remote_ep: str, remote_path: str, name: str, transfer_type: str, non_blocking: bool
7473
):
75-
global transfer_client
76-
global local_endpoint
77-
global remote_endpoint
7874
global transfer_data
7975
global task_id
8076
global archive_directory_listing
@@ -199,7 +195,6 @@ def globus_transfer( # noqa: C901
199195
def globus_block_wait(
200196
task_id: str, wait_timeout: int, polling_interval: int, max_retries: int
201197
):
202-
global transfer_client
203198

204199
# poll every "polling_interval" seconds to speed up small transfers. Report every 2 hours, stop waiting aftert 5*2 = 10 hours
205200
logger.info(
@@ -211,7 +206,7 @@ def globus_block_wait(
211206
try:
212207
# Wait for the task to complete
213208
logger.info(
214-
f"{ts_utc()}: on task_wait try {retry_count+1} out of {max_retries}"
209+
f"{ts_utc()}: on task_wait try {retry_count + 1} out of {max_retries}"
215210
)
216211
transfer_client.task_wait(
217212
task_id, timeout=wait_timeout, polling_interval=10
@@ -244,7 +239,6 @@ def globus_block_wait(
244239

245240

246241
def globus_wait(task_id: str):
247-
global transfer_client
248242

249243
try:
250244
"""
@@ -288,9 +282,6 @@ def globus_wait(task_id: str):
288282

289283

290284
def globus_finalize(non_blocking: bool = False):
291-
global transfer_client
292-
global transfer_data
293-
global task_id
294285
global global_variable_tarfiles_pushed
295286

296287
last_task_id = None

0 commit comments

Comments
 (0)