Skip to content

Commit

Permalink
LMAO @Cadair
Browse files Browse the repository at this point in the history
  • Loading branch information
nabobalis committed Dec 11, 2024
1 parent cf583d2 commit 381a6de
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
posargs: -n auto
envs: |
- linux: py312
secrets:
Expand All @@ -39,7 +38,6 @@ jobs:
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
posargs: -n auto
envs: |
- windows: py310
- macos: py311
Expand Down Expand Up @@ -73,7 +71,6 @@ jobs:
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
posargs: -n auto --dist loadgroup
envs: |
- linux: py312-online
secrets:
Expand Down
7 changes: 1 addition & 6 deletions aiapy/calibrate/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"""

import os

# This needs to be done before aiapy or sunpy is imported
os.environ["PARFIVE_SINGLE_DOWNLOAD"] = "True"
import pathlib
import warnings
from urllib.parse import urljoin
Expand All @@ -18,15 +15,13 @@
from astropy.time import Time
from erfa.core import ErfaWarning
from sunpy import log
from sunpy.data import manager
from sunpy.net import attrs as a
from sunpy.net import jsoc

from aiapy import _SSW_MIRRORS
from aiapy.data._manager import manager
from aiapy.util.decorators import validate_channel

os.environ.pop("PARFIVE_SINGLE_DOWNLOAD")

__all__ = ["get_correction_table", "get_error_table", "get_pointing_table"]

# Default version of the degradation calibration curve to use.
Expand Down
36 changes: 36 additions & 0 deletions aiapy/data/_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
This only exists to bypass the gzipped issue with parfive.
See https://github.com/Cadair/parfive/issues/121
If you want to complain, his name is Stuart Mumford, @cadair on GitHub
"""

from pathlib import Path

from sunpy import config
from sunpy.data.data_manager.cache import Cache
from sunpy.data.data_manager.downloader import DownloaderBase, DownloaderError
from sunpy.data.data_manager.manager import DataManager
from sunpy.data.data_manager.storage import SqliteStorage
from sunpy.util.parfive_helpers import Downloader

__all__ = ["manager"]


class AIAParfiveDownloader(DownloaderBase):
def download(self, url, path):
downloader = Downloader()
path = Path(path)
filename = path.name
directory = path.parent
downloader.enqueue_file(url, directory, filename, max_splits=1)
try:
output = downloader.download()
except Exception as e:
raise DownloaderError from e

Check warning on line 30 in aiapy/data/_manager.py

View check run for this annotation

Codecov / codecov/patch

aiapy/data/_manager.py#L29-L30

Added lines #L29 - L30 were not covered by tests
if output.errors:
raise DownloaderError(output.errors[0].exception)

Check warning on line 32 in aiapy/data/_manager.py

View check run for this annotation

Codecov / codecov/patch

aiapy/data/_manager.py#L32

Added line #L32 was not covered by tests


_download_dir = config.get("downloads", "remote_data_manager_dir")
manager = DataManager(Cache(AIAParfiveDownloader(), SqliteStorage(_download_dir + "/data_manager.db"), _download_dir))
2 changes: 1 addition & 1 deletion aiapy/response/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import astropy.constants as const
import astropy.units as u
import numpy as np
from sunpy.data import manager
from sunpy.io.special import read_genx
from sunpy.util.metadata import MetaDict

from aiapy import _SSW_MIRRORS
from aiapy.calibrate import degradation
from aiapy.calibrate.util import _select_epoch_from_correction_table, get_correction_table
from aiapy.data._manager import manager
from aiapy.util import telescope_number
from aiapy.util.decorators import validate_channel

Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ tests = [
"hissw",
"pytest",
"pytest-astropy",
"pytest-cov",
"pytest-xdist",
]
docs = [
"aiapy[all]",
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ allowlist_externals=
setenv =
MPLBACKEND = agg
SUNPY_SAMPLEDIR = {env:SUNPY_SAMPLEDIR:{toxinidir}/.tox/sample_data/}
PYTEST_COMMAND = pytest -vvv -r as --pyargs aiapy --cov-report=xml --cov=aiapy -n auto --color=yes {toxinidir}/docs
PYTEST_COMMAND = pytest -vvv -r as --pyargs aiapy --cov-report=xml --cov=aiapy --retries 3 --retry-delay 30 --color=yes {toxinidir}/docs
devdeps,build_docs,online: HOME = {envtmpdir}
PARFIVE_HIDE_PROGRESS = True
devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
changedir = .tmp/{envname}
description =
run tests
deps =
pytest-retry
pytest-cov
devdeps: astropy>=0.0.dev0
devdeps: sunpy>=0.0.dev0
extras =
Expand Down

0 comments on commit 381a6de

Please sign in to comment.