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 67597f5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
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, max_conns=1)
try:
output = downloader.download()
except Exception as e:
raise DownloaderError from e
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#L22-L32

Added lines #L22 - L32 were 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

1 comment on commit 67597f5

@Cadair
Copy link
Contributor

@Cadair Cadair commented on 67597f5 Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my

Please sign in to comment.