eawag-rdm / resup

Batch upload and download of resources to and from data package in CKAN.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`resup put` fails: `AttributeError: 'long' object has no attribute 'decode`

meowcat opened this issue · comments

This happens on an attempted upload of a single 200kb file.

(resup) C:\Daten\CD\wf>resup put expozol-sediment-analysis-dia-positive-mode
loading existing checksums
Found pre-calculated checksum for Untargeted_Metabolomics_NICO.cdProcessingWF.
uploading Untargeted_Metabolomics_NICO.cdProcessingWF (202078)
{'restricted_level': 'public', 'hashtype': 'sha256', 'package_id': 'expozol-sediment-analysis-dia-positive-mode', 'hash': 'ee35b42bc55e2af9023c94fec7071063de4d560ba2e56633aa7777911db130bb', 'name': 'Untargeted_Metabolomics_NICO.cdProcessingWF', 'url': 'dummy', 'citation': '', 'resource_type': 'Dataset', 'size': 202078L}
Traceback (most recent call last):
  File "C:\Software\Anaconda3\envs\resup\Scripts\resup-script.py", line 11, in <module>
    load_entry_point('resup', 'console_scripts', 'resup')()
  File "c:\daten\git\resup\resup\resup.py", line 578, in main
    put.upload()
  File "c:\daten\git\resup\resup\resup.py", line 376, in upload
    self._upload()
  File "c:\daten\git\resup\resup\resup.py", line 354, in _upload
    progress=progressbar.mkprogress, requests_kwargs={'verify': False})
  File "C:\Software\Anaconda3\envs\resup\lib\site-packages\ckanapi\remoteckan.py", line 86, in call_action
    action, data_dict, apikey or self.apikey, files)
  File "C:\Software\Anaconda3\envs\resup\lib\site-packages\ckanapi\common.py", line 100, in prepare_action
    data_dict[_encodehack(k)] = _encodehack(v)
  File "C:\Software\Anaconda3\envs\resup\lib\site-packages\ckanapi\common.py", line 80, in _encodehack
    return s.decode('utf-8').encode('utf-8') #type(s) is PY2<str> or illegal
AttributeError: 'long' object has no attribute 'decode

Same with a completely different file

This was on Windows 20H2. Works on Linux

Likely an issue with the Anaconda installation. resup is distributed as pip-installable source. Mixing the official packaging system with Conda generally can lead to hard-to-trace complications. Please try to replicate the error with an install in a clean (Anaconda-free) environment.

Exact same with a freshly installed Python 2.7, in a fresh env:

(env) C:\Daten\CD\wf>resup put expozol-sediment-analysis-dia-positive-mode
Calculating checksum for Untargeted_Metabolomics_NICO.cdProcessingWF ...
    time: 0.00200009346008 seconds
    sha256: ee35b42bc55e2af9023c94fec7071063de4d560ba2e56633aa7777911db130bb
uploading Untargeted_Metabolomics_NICO.cdProcessingWF (202078)
{'restricted_level': 'public', 'hashtype': 'sha256', 'package_id': 'expozol-sediment-analysis-dia-positive-mode', 'hash': 'ee35b42bc55e2af9023c94fec7071063de4d560ba2e56633aa7777911db130bb', 'name': 'Untargeted_Metabolomics_NICO.cdProcessingWF', 'url': 'dummy', 'citation': '', 'resource_type': 'Dataset', 'size': 202078L}
Traceback (most recent call last):
  File "C:\Daten\git\resup2\resup\env\Scripts\resup-script.py", line 11, in <module>
    load_entry_point('resup', 'console_scripts', 'resup')()
  File "c:\daten\git\resup2\resup\resup\resup.py", line 602, in main
    put.upload()
  File "c:\daten\git\resup2\resup\resup\resup.py", line 400, in upload
    self._upload()
  File "c:\daten\git\resup2\resup\resup\resup.py", line 378, in _upload
    progress=progressbar.mkprogress, requests_kwargs={'verify': False})
  File "C:\Daten\git\resup2\resup\env\lib\site-packages\ckanapi\remoteckan.py", line 86, in call_action
    action, data_dict, apikey or self.apikey, files)
  File "C:\Daten\git\resup2\resup\env\lib\site-packages\ckanapi\common.py", line 100, in prepare_action
    data_dict[_encodehack(k)] = _encodehack(v)
  File "C:\Daten\git\resup2\resup\env\lib\site-packages\ckanapi\common.py", line 80, in _encodehack
    return s.decode('utf-8').encode('utf-8') #type(s) is PY2<str> or illegal
AttributeError: 'long' object has no attribute 'decode'