Skip to content

Commit

Permalink
Add a crude version check for parameter compatibility with JülichData
Browse files Browse the repository at this point in the history
While it is still running on the 4.20 custom build, the data_format parameter isn't
supported, and needs to be removed from the get_datafile call.
  • Loading branch information
adswa committed Oct 23, 2024
1 parent ef3aa94 commit ed3032f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion datalad_dataverse/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)
import re

from looseversion import LooseVersion
from pyDataverse.api import ApiAuthorizationError
from pyDataverse.models import Datafile
from requests import (
Expand Down Expand Up @@ -171,7 +172,13 @@ def download_file(self, fid: int, path: Path):
# https://github.com/gdcc/pyDataverse/issues/49
# the code below is nevertheless readied for such a
# scenario
response = self.data_access_api.get_datafile(fid, is_pid=False, data_format="original")
# for JülichData compatibility while still running on 4.20, a
# version-dependent parameter adjustment is necessary
version = self._api.get_info_version().json()['data']['version']
if LooseVersion(version) < LooseVersion("6.0"):
response = self.data_access_api.get_datafile(fid, is_pid=False)
else:
response = self.data_access_api.get_datafile(fid, is_pid=False, data_format="original")
# http error handling
response.raise_for_status()
with path.open("wb") as f:
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ install_requires =
datalad_next >= 1.0.0b2
datalad >= 0.18.0
pydataverse >= 0.3.4
looseversion
packages = find_namespace:
include_package_data = True

Expand Down

0 comments on commit ed3032f

Please sign in to comment.