-
Notifications
You must be signed in to change notification settings - Fork 3
Add modules utils under mix_utils folder to avoid duplication in JSON… #36
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
Conversation
… file and uniform some date and JSON content
…ce to an uco-identity class
Hi @fabrizio-turchi , If you are in progress on pushing changes, please leave this PR in Draft status until you are done and ready for it to be reviewed for merging. Also, your first commit includes a compiled |
Hi Alex,
I'll remove the .pyc files and add them to the .gitignore, sorry it slipped my mind!
I stop working on the repo for the moment, so no worry I'll wait for your review.
Best regards.
F.
[cid:0a7159de-aa31-483f-a0a1-da5a8c203905]
[facebook]<https://www.facebook.com/CNRsocialFB> [twitter] <https://twitter.com/CNRsocial_> [instagram] <https://www.instagram.com/cnrsocial/> [linkedin] <https://www.linkedin.com/company/283032>
Fabrizio Turchi
CNR, ISTITUTO DI INFORMATICA GIURIDICA E SISTEMI GIUDIZIARI
[cid:69336b52-6f6a-4130-8edf-0cd2e5bc5fc6]
Tel. +39 055 4399672
Cell. +39 328 36 23 632
***@***.***
via de' Barucci, 20, 50121 – Firenze
[cid:856ad76e-5a6b-4d2f-bf5a-0b6b2254710b]
www.cnr.it<http://www.cnr.it/>
Devolvi il 5×1000 al CNR
CF 80054330586
…________________________________
From: Alex Nelson ***@***.***>
Sent: 20 February 2024 14:43
To: casework/CASE-Mapping-Python ***@***.***>
Cc: Fabrizio Turchi ***@***.***>; Mention ***@***.***>
Subject: Re: [casework/CASE-Mapping-Python] Add modules utils under mix_utils folder to avoid duplication in JSON… (PR #36)
Hi @fabrizio-turchi<https://github.com/fabrizio-turchi> ,
If you are in progress on pushing changes, please leave this PR in Draft status until you are done and ready for it to be reviewed for merging.
Also, your first commit includes a compiled .pyc file. Can you please git rm that, and also include a patch updating .gitignore to ignore __pycache__ and *.pyc? I leave it up to you if you want to revise the history to purge that file.
—
Reply to this email directly, view it on GitHub<#36 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEDCCDIQTCGO3XUHSUB2TVLYUSSBJAVCNFSM6AAAAABDPPLSSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJUGI2DKNRTGM>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things:
.gitignore
should prevent__pycache__
and*.pyc
files from being committed. It might also be good to purge those files from the first patch, whether in a force-push on this PR or in a separate PR.- The
adjust_json
function looks like it could use further explanation because of in-memory data modification. I'd personally prefer a doctest be added and run as part of the module test suite if we confirm the behavior's necessary. (See these lines for a doctest demonstration.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a pytest
is needed. There might be runtime issues in some configurations of Python, e.g. Python 3.8.
@ajnelson-nist I turned the class into a function at model level. The test_duplicate.py contains all the ways I invoke the code in the UFED parser. The JSON objects taken into account in the test are a simplified version of the ones included in the parser code but it doesn't affect the result of the test. Feel free to make any kind of comment for the benefit of the final result. |
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
I realized a few things running Also, thank you again for using the typing symbols from Python <3.9. But, I'd forgotten that 3.8 is not supported by this package. The CASE validation action only operates in 3.9 or later, and the Thank you for the pytest. I was expecting it would operate on your new module as a package, but where you put the test made me realize your code isn't positioned to be a part of the The way to see this is to have the file Last, be aware the node identifier style resolves to |
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
@ajnelson-nist I tried to use the example module to test the FacetUrlHistory and UrlHistoryEntry classes, but it raises the error: "PackageNotFoundError: case-mapping". Inside the init.py of the package there's a reference to case-mapping but the folder is case_mapping. Could you have a look to it? |
@fabrizio-turchi : I have a guess why you're seeing that, but first, it would be helpful for review purposes if you would run Back to your question - it sounds like the library is not installed in your testing environment. This is a reasonable expectation from tests being in separate directories from the package source. If you run make
source venv/bin/activate # Begin use of virtual environment
pytest
deactivate # End use of virtual environment
If you follow the above steps, you'll find there was a missed |
@ajnelson-nist I wouldn't like to bother you about the error I run into yesterday. |
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Reported-by: Keith Chason <kchason@users.noreply.github.com> Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
@ajnelson-nist I changed the code in the FacetUrlHistory class to fix the errors raised by case_validate. I didn't find a better way to fill in the uco-observable:urlHistoryEntry property. The code is borrowed by the _str_vars, _str_datetime ... methods of the FacetEntity class, but I couldn't use those methods. If you find a more elegant solution, do not hesitate to change teh code or suggest to me how to do it. 10x! |
JSON-LD needs the value with the `@value` key to be a JSON string. Some undesired type-coercion could happen if ints or floats are used. Python type signatures are added to check data flow consistency. Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
If `Tuple[str, ...]` is used, then each individual positional argument must be a tuple of strings. See PEP-484. `Any` is used instead, to allow for `float`s in the accompanying unit test, and `dict`s in future applications. With these changes, `/mix_utils` passes `mypy`. References: * https://peps.python.org/pep-0484/#arbitrary-argument-lists-and-default-argument-values Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
With these changes, `/mix_utils` passes `mypy --strict`. Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
The migrated test script demonstrates the module import pattern for consumers. Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
@fabrizio-turchi : I've moved some files around so you can meet your original goal of getting a shareable, importable library. I've also added Python type reviews on all of the files that were under If you look at the I'm approving this PR. If you agree with the changes, please feel free to merge, and then I'll start reviewing #38 . Note: I did not review changes pertaining to other Issues. I only checked that the unit testing ( |
Add the utils.py module under mix_utils folder to:
The module is shared among all parsers (UFED, AXIOM, OXYGEN and XAMN/XRY)