Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#38 add metadata #61

Merged
merged 9 commits into from
Oct 6, 2022
Merged

#38 add metadata #61

merged 9 commits into from
Oct 6, 2022

Conversation

funkydunc
Copy link
Contributor

#38

AddMetadata class with tests

@glenrobson glenrobson linked an issue May 27, 2022 that may be closed by this pull request
14 tasks
@digitaldogsbody
Copy link
Member

@funkydunc Can you rebase against main now that #63 is merged? That should hopefully fix the failing tests.

@funkydunc funkydunc requested a review from a team May 27, 2022 16:17
@digitaldogsbody
Copy link
Member

I don't know why the linter is failing only for one Python version 😕

Given that the tests pass for the others, I don't see this as a block to merge, but it would be nice to work out why!

@azaroth42
Copy link
Contributor

What happens if the function is passed a dict or langstring instance, per Glen's comment?

@funkydunc
Copy link
Contributor Author

What happens if the function is passed a dict or langstring instance, per Glen's comment?

@azaroth42 @glenrobson how would you like the function to accept args as different datatypes? Would something like this, using additional keyword arguments on the method be ok?

    def add_metadata(self, label, value, metadata_dict=None, langstring=None):
        #check the presence of the above arguments (and they are valid) before adding them to the metadata

@funkydunc funkydunc mentioned this pull request May 27, 2022
@glenrobson
Copy link
Contributor

I'd lean more on others (cc @azaroth42 @digitaldogsbody @giacomomarchioro) on if this is the python way of doing things but could you check the type to see if its String, dict or LngString?

@azaroth42
Copy link
Contributor

+1 to testing the type of the argument. if type(label) == dict: # do dict stuff

@funkydunc
Copy link
Contributor Author

@azaroth42 @glenrobson is there an exception type you would want me to import and raise if the supplied arguments are invalid? Thanks.

@digitaldogsbody
Copy link
Member

I would say raise TypeError if the value is not one of the correct types

@azaroth42
Copy link
Contributor

If the param is invalid, then upstream validation in pydantic should catch it? I would be fine with handling valid cases and ignoring invalid ones.

@funkydunc
Copy link
Contributor Author

@azaroth42 The add_metadata function now also accepts dict and LngString parameters.

It validates that the label and value params are either str, LngString or dict and, that they are the same type as each other.

Incorrect types, or params of unequal types returns ValueError. Validation also has a test.

Tests pass locally, although cancelled here.
image

@glenrobson
Copy link
Contributor

We need to re-run the tests to see why it failed.

Mike to change workflow on: target - forces workflow to run from main rather than remote target.

@glenrobson glenrobson added the help wanted Extra attention is needed label Sep 30, 2022
@digitaldogsbody digitaldogsbody merged commit 88695f2 into iiif-prezi:main Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Metadata
4 participants