Page MenuHomeSoftware Heritage

Add possibility to fetch last SWHID for a deposit using an origin on deposit cli
Closed, MigratedEdits Locked


In IPOL for article #300, this information is added to the entry:

sw_title="Implementation of the LLCC method for image enhancement"
sw_authors="Jose-Luis Lisani"

The fields origin, title, authors, date, license and version can be easily retrieved from the IPOL description file.

But the id, anchor and visit fields are more difficult to retrieve.

Use case
An editor is trying to find out the simplest way to create a script that gives me the SWHID information for each deposited article. I kept all the deposits IDs, so there is no problem in using this information and the 'swh deposit status' command. I was just wondering if there was a more direct option using as query the 'slug'.

The slug is a.k.a the origin.

SWH answer in January:

Using the deposit-id is best because it identifies one artifact, when giving a slug(which creates an origin) it has the capacity to accept multiple versions of an artifact for one origin.
A request using the origin, can potentially return a list of SWHIDs or the last deposit, which might be ambiguous.
We will reflect on the possibilities to implement this functionality and get back to you.

Event Timeline

moranegg triaged this task as Normal priority.Apr 1 2021, 1:08 PM
moranegg created this task.

Discussed for 2021W18 or 2021W19 during today's call.

Ipol's editor has agreed that this solution will be good for their use case.

This is possible with the main API:

@moranegg I've went the script way in the end (what val initially proposed).

I had to slightly adapt the swh-web-client module [1] first (done, and unstucking the
packaging along the way ;).

The other way around is not that simple to implement. There are too many cogs to adapt
(client, and server side, D6210 would have been an incomplete start btw). As Val
suggested multiple times, information is already on the archive so i'm not willing to
duplicate the reading in the deposit.

Out of this change, a script [2] is ready to be duplicated if Jose Luis wants or
inspires from it. See the example use [3].

@vlorentz I pushed it on snippet since it hardcodes how to fetch the revision "path"
(from the snapshot) we are interested in for the deposit case. And also because it's
mostly intended for duplication.

As usual, feel free to suggest, adapt or push something better ;). For example, I don't
know whether we want an entry point directly in the swh web command line instead of
the snippet (if it's the case, that'd be extra work though and i feel like i've spent
too much time on this already).

[1] D6211



$ python3 -m cli
$ shuf ipol-deposit-origins.txt| head -1
$ python3 -m cli
$ python3 -m cli 2>&1 | tail -1
ValueError: No origin found matching


ardumont changed the task status from Open to Work in Progress.Sep 8 2021, 4:31 PM
ardumont moved this task from Backlog to In code review on the SWORD deposit board.