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

Add run_checks method to checks module #13

Open
doulikecookiedough opened this issue Feb 5, 2025 · 1 comment
Open

Add run_checks method to checks module #13

doulikecookiedough opened this issue Feb 5, 2025 · 1 comment
Assignees

Comments

@doulikecookiedough
Copy link

We would like to be able to run checks in python without spinning up the java engine (and going through the dispatcher).

In the checks module, add a new function run_checks that can take a check and the desired document and return an output. There may be checks where multiple output and statuses are returned, so we may want to consider returning a dictionary.

@doulikecookiedough doulikecookiedough self-assigned this Feb 5, 2025
@doulikecookiedough
Copy link
Author

Greetings @jeanetteclark, I was able to get the run_check pytest working successfully! I ended up refactoring some pytests as well, and running pytest will now execute all tests successfully in the feature-13-runcheck branch. What's left to do is code clean-up, and also returning a dictionary of the results.

Also, do you happen to have a python check handy that will run and return more than one result? I may not fully understand that process - but I will look for a check after I've wrapped up my to-do items.

In terms of making checks easier to test, I suggest that we create a metadig command line client - similar to how we have one for hashstore, which gets installed when we execute poetry install. It will take arguments which will run the run_check function - I imagine the process to test a check to look something like this:

# Check-out hashstore and install it
$ cd ~/Code/hashstore
~/Code/hashstore $ poetry install 

# Create a HashStore at your desired store path (ex. /docs/dou/hashstore)
~/Code/hashstore $ hashstore /path/to/store/ -chs -dp=3 -wp=2 -ap=SHA-256 -nsp=\"http://www.ns.test/v1\"

# Store data object and associated metadata documents for the check
~/Code/hashstore $ hashstore /path/to/store/ -storeobject -pid=persistent_identifier -path=/path/to/object\n~/Code/hashstore
~/Code/hashstore $ hashstore /path/to/store/ -storemetadata -pid=persistent_identifier -path=/path/to/metadata/object -formatid=https://ns.dataone.org/service/types/v2.0#SystemMetadata

# Run check
# `store_path` will be used to retrieve the hashstore location and get `StoreManager` properties
# `data_pids` will pass the data pids to run the checks against
# A `check_vars` dictionary will be created to be passed onto `run_check` in the metadig client
$ cd ~/Code/metadig-py
~/Code/metadig-py $ metadig -runcheck -store_path=/path/to/store -check_xml=path/to/check/xml/check.xml -eml_doc=path/to/eml/metadata/doc data_pids=[array,of,pids]

# Results will be printed to stdout

If this sounds good to you, I can add that as part of this feature branch (or I could also create a new sub-issue for it).

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

No branches or pull requests

1 participant