Skip to content

feat: Add sidecar endpoint so UI can pass reference metadata updates to backend#217

Merged
cguedes merged 6 commits into
mainfrom
182-add-sidecar-endpoint-so-ui-can-pass-reference-metadata-updates-to-backend
Jun 29, 2023
Merged

feat: Add sidecar endpoint so UI can pass reference metadata updates to backend#217
cguedes merged 6 commits into
mainfrom
182-add-sidecar-endpoint-so-ui-can-pass-reference-metadata-updates-to-backend

Conversation

@gjreda

@gjreda gjreda commented Jun 28, 2023

Copy link
Copy Markdown
Collaborator

fixes #182


# Full example showing the update
$ cat .storage/references.json | jq '.[] | select(.source_filename | contains("fails")) | {"source_filename": .source_filename, "title": .title}'

{
  "source_filename": "grobid-fails.pdf",
  "title": null
}

# run the update
$ poetry run python main.py update --data '{"source_filename": "grobid-fails.pdf", "patch": {"title": "a title that was missing"}}'

{
  "status": "ok",
  "message": ""
}

# check that it worked
$ cat .storage/references.json | jq '.[] | select(.source_filename | contains("fails")) | {"source_filename": .source_filename, "title": .title}'

{
  "source_filename": "grobid-fails.pdf",
  "title": "a title that was missing"
}

@codecov

codecov Bot commented Jun 28, 2023

Copy link
Copy Markdown

Codecov Report

Merging #217 (4969ea3) into main (7f9cc08) will increase coverage by 1.22%.
The diff coverage is 70.27%.

@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   70.94%   72.17%   +1.22%     
==========================================
  Files          94      103       +9     
  Lines        4712     5099     +387     
  Branches      377      405      +28     
==========================================
+ Hits         3343     3680     +337     
- Misses       1352     1401      +49     
- Partials       17       18       +1     
Impacted Files Coverage Δ
python/main.py 0.00% <0.00%> (ø)
python/sidecar/cli.py 0.00% <0.00%> (ø)
python/sidecar/storage.py 88.88% <77.27%> (-1.78%) ⬇️
python/sidecar/typing.py 97.33% <100.00%> (+0.36%) ⬆️

... and 121 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@gjreda

gjreda commented Jun 28, 2023

Copy link
Copy Markdown
Collaborator Author

@cguedes one question on this and another thing to note:

  1. For nulling out fields, what do you think about just passing in an empty string, which I can then set to None on my end? It feels like if a user is entirely deleting a metadata value in the UI, we should interpret that to null.
  2. One thing to note here is that the client will need to pass all the metadata to update a nested object like authors.

For example, if we have the following Reference:

Reference(source_filename='abc.pdf', authors=[Author(full_name='Greg Reda'), Author(full_name='Carlos')])

and we want to update the full_name for only one author, we'll need to include all author details in the update, even ones that are not changing:

$ poetry run python main.py update --data \
    '{"source_filename": "abc.pdf", "patch": {"authors": [{"full_name": "Greg Reda"}, {"full_name": "Carlos Guedes"}]}}'

@gjreda gjreda marked this pull request as ready for review June 28, 2023 17:51
@gjreda gjreda changed the title Add sidecar endpoint so UI can pass reference metadata updates to backend feat: Add sidecar endpoint so UI can pass reference metadata updates to backend Jun 28, 2023
@gjreda gjreda requested review from cguedes and sehyod June 29, 2023 02:18
@sehyod

sehyod commented Jun 29, 2023

Copy link
Copy Markdown
Collaborator

For 1, I think it makes sense to interpret empty strings as null. I don't have any strong opinion on whether it is the frontend's job to send null instead of an empty string or if the backend should convert empty strings to null as you suggested.

And for 2, I think it's actually easier for the frontend too to send the whole array of authors to the backend rather than keeping track of what indexes have been updated

@cguedes

cguedes commented Jun 29, 2023

Copy link
Copy Markdown
Collaborator
  1. I'm ok with sending empty strings, bc most times that's what the UI can do/detect for when a field is cleared (one just remove all the text).
  2. That's ok.

@cguedes cguedes merged commit 123c45d into main Jun 29, 2023
@cguedes cguedes deleted the 182-add-sidecar-endpoint-so-ui-can-pass-reference-metadata-updates-to-backend branch June 29, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sidecar endpoint so UI can pass Reference metadata updates to backend

3 participants