Page MenuHomeSoftware Heritage

enable metadata injection from deposit
ClosedPublic

Authored by moranegg on Nov 8 2017, 5:17 PM.

Details

Diff Detail

Repository
rDDEP Push deposit
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

swh/deposit/api/private/deposit_read.py
204

I would have made this a class configuration instead (using class variable ADDITIONAL_CONFIG).

swh/deposit/migrations/0006_depositclient_url.py
18

I know we did this together but we must avoid hardcoding this.

Well, at least, we don't want this to stay as is in the long run.

At some point, this default should go away.
It's ok for now since we only have the one client :)

This comment was removed by moranegg.
  • Change metadata provider and tool as additional config
moranegg added inline comments.
swh/deposit/migrations/0006_depositclient_url.py
18

I'm not sure how to do it differently for now.
I will look into it this week.

swh/deposit/injection/loader.py
163

I think the metadata are important enough so we could consider this an error worth making the import fail altogether?
Any thought on this?

swh/deposit/migrations/0006_depositclient_url.py
18

No worries there.
Once we deploy this in production, we should "simply" make that default value disappear (i don't know yet how to do this in django :).

We needed this because in our db we already had one deposit client prior to adding that field.
Once migrated, that client won't cause problem since there will be a value in that field.

swh/deposit/tests/api/test_deposit_read_metadata.py
40–57

Maybe worth adding a value different than production to make it show that this is not coming from the db (well, the runtime db at least)?

  • Added tests for metadata injection
moranegg retitled this revision from Added metadata injection and url to client to enable metadata injection from deposit.Nov 20 2017, 3:37 PM
  • Change metadata provider and tool as additional config
  • Added tests for metadata injection
  • Refactor origin_metadata injection with prepare_metadata from loader-core

Almost ok!
Just some minor test override detail or typo.

docs/metadata.md
11 ↗(On Diff #905)

persistent

docs/spec-injection.md
208 ↗(On Diff #905)

I'm not so sure we want to integrate so much implementation detail.
We will be drowning ourselves in documentation update otherwise.

swh/deposit/api/private/deposit_read.py
153

Note: We must make sure that the deposit.client.url holds a trailing '/'.

Or, you can change this as:

os.path.join(deposit.client.url.rstrip('/') , deposit.external_id)
153–154

Yes, nice. Type deposit does exist in the db now.

swh/deposit/injection/loader.py
162

Same as in D266, we should raise an error to notify that the loading somehow failed since we were not able to actually store the metadata.

swh/deposit/tests/common.py
162

\m/

swh/deposit/tests/test_loader.py
165 ↗(On Diff #905)

Let the prepare_metadata do its job and do not override it here.

Prefer overriding the send_tool and send_provider instead as they are in a way leaf methods.
What i mean by leaf is they only have one simple action.
Sending the tool (respectively the provider) using the storage's api.

That one is more complicated as it orchestrates creation of tool and provider (this one has multiple actions including filtering...). Also, as you override it, we potentially let a bug crawl in as we do not pass in that runtime code in the test.

It's more ok to do so for the send* function as they are really covered by the swh-storage layer already.

232 ↗(On Diff #905)
return json.loads(r.content.decode('utf-8'))
This revision now requires changes to proceed.Nov 21 2017, 10:57 AM
  • Refactor tests: use actual prepare_metadata without mocking it for tests
swh/deposit/injection/loader.py
163

Yes, i agree with myself, add a raise here in the except clause :)
We must make the status of the loading in error if that problem arises.

This revision now requires changes to proceed.Nov 23 2017, 11:55 AM
  • Refactor tests: use actual prepare_metadata without mocking it for tests
  • Refactor tests: use actual prepare_metadata without mocking it for tests

Well, you did not mock, you overrode :)

This revision is now accepted and ready to land.Nov 23 2017, 12:14 PM
In D265#5625, @ardumont wrote:
  • Refactor tests: use actual prepare_metadata without mocking it for tests

Well, you did not mock, you overrode :)

haha.. ;-)

This revision was automatically updated to reflect the committed changes.