cernopendata / cernopendata-client

CERN Open Data command-line client
http://cernopendata-client.readthedocs.io/
GNU General Public License v3.0
10 stars 9 forks source link

search by DOI not working #18

Closed tiborsimko closed 4 years ago

tiborsimko commented 4 years ago

This works:

$ cernopendata-client get-record --recid 4910

This does not:

$ cernopendata-client get-record --doi '10.7483/OPENDATA.LHCB.N75T.TJPE'
Traceback (most recent call last):
  File "/home/simko/.virtualenvs/cernopendata/bin/cernopendata-client", line 8, in <module>
    sys.exit(cernopendata_client())
  File "/home/simko/.virtualenvs/cernopendata/lib/python3.8/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/simko/.virtualenvs/cernopendata/lib/python3.8/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/simko/.virtualenvs/cernopendata/lib/python3.8/site-packages/click/core.py", line 1135, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
  File "/home/simko/.virtualenvs/cernopendata/lib/python3.8/site-packages/click/core.py", line 641, in make_context
    self.parse_args(ctx, args)
  File "/home/simko/.virtualenvs/cernopendata/lib/python3.8/site-packages/click/core.py", line 940, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/home/simko/.virtualenvs/cernopendata/lib/python3.8/site-packages/click/core.py", line 1476, in handle_parse_result
    value = invoke_param_callback(
  File "/home/simko/.virtualenvs/cernopendata/lib/python3.8/site-packages/click/core.py", line 96, in invoke_param_callback
    return callback(ctx, param, value)
  File "/home/simko/.virtualenvs/cernopendata/lib/python3.8/site-packages/cernopendata_client/cli.py", line 31, in ensure_positive_int
    if value < 0:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

To be fixed.

tiborsimko commented 4 years ago

You can look at DOIs by using the search syntax doi:"value" in the Web UI.

Programmatically, the internal REST API to look at to get record ID out of DOI is http://opendata.cern.ch/api/records/?page=1&size=20&q=doi:%2210.7483/OPENDATA.LHCB.N75T.TJPE%22.

If there is only one record, we have our candidate. If there is zero record, the DOI does not seem to exist. If there is more than one record, something is very wrong, because each DOI should be there only once.

Once we have our record ID, we can continue as when --recid was passed.