Closed zupon closed 3 years ago
If it gets the right answer, it's close enough for me. I'd think that python has a yaml library so that one wouldn't need to regex. It seems like there is the possibility of finding some of these patterns in strings that some evil person has planted within the file. If both these patterns need to match from the beginning of a line, perhaps it would be prudent to add a ^ to save some debugging later (if that's at all how the python regexes work).
Just looking at some less-curated output from the OIAD UI, this needs some more work. The problem is I was trying to use the - asdf:
format to look for non-leaf nodes, but in the randomized order of the output, it now gets all sorts of things that shouldn't be gotten.
we should make a test for this once it's solved.
On Wed, Jul 7, 2021 at 9:11 AM zupon @.***> wrote:
External Email
Just looking at some less-curated output from the OIAD UI, this needs some more work. The problem is I was trying to use the - asdf: format to look for non-leaf nodes, but in the randomized order of the output, it now gets all sorts of things that shouldn't be gotten.
— You are receiving this because your review was requested. Reply to this email directly, view it on GitHub https://github.com/WorldModelers/Ontologies/pull/128#issuecomment-875735129, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJCPCKAQQXCMN4CU4PFVTTTWR4BVANCNFSM475AV7UQ .
I used the pyyaml
library to do some fancy stuff with this. Now, through some sort of magic, pyyaml reads in the metadata
file, sorts the fields the way we want, and the rest of my script does the rest the way it did before. I can't guarantee it will work if we decide to add new types of fields, but it does work with the ones we have now, no matter what order they are in.
nice! any chance we can add a unit test or two?
@kwalcock Your testing framework for Python seems to work well here. I revised strip_metadata.py
to make it play nicer with tests, then wrote test_strip_metadata.py
. Right now it only includes one relatively simple test, but it can be expanded later.
One area that I'm really unsure about is from my last commit. The Travis build wasn't succeeding because it could not find the pyyaml
module. I added a line to .travis.yml
to install it, and now it succeeds, but I wanted to make sure that wasn't going to totally mess everything up somewhere down the line.
@zupon, that seems like a perfectly good solution for now. There are apparently other conventions to know about, like use of setup.py. https://packaging.python.org/overview/ explains a lot. I don't know how formal it needs to get. Testing has been addressed in any case.
@kwalcock Is it alright to merge this PR? Or should I wait until the PR for your branch into master is merged first, since my branch now contains all of your changes?
This PR rewrites the
strip_metadata.py
script to make it simpler and more robust to variable order of metadata fields. It now does not rely onOntologyNode:
being first nor onpolarity
(orsemantic type
more recently) being last.