My repo.py now has a whole bunch of config filepat...
# ask-community
g
My repo.py now has a whole bunch of config filepaths (with file_relative_path (easy place to make small dumb mistakes and I wan't to add testing for it. Can anyone provide an example for this?
o
hi @George Pearse! what sort of errors would you be looking to catch here -- would it basically just be making sure that a file did indeed exist at any path referenced that way?
there's no built-in way for testing that sort of thing, but one option that might help workflow would be to create a
safe_file_relative_path()
function, that basically just calls
file_relative_path
then does a check that there's a file there (erroring if there isn't). you could then use safe_file_relative_path in place of file_relative_path, which should help catch errors of that form more quickly
g
"would it basically just be making sure that a file did indeed exist at any path referenced that way" yeah exactly, wasn't sure how easy that would be because of the use of file_relative_path (if I was running the tests from another directory). I'd prefer a set of unit tests that I could run before something to set-up dagster in full (which I think safe_file_relative_path would require). Though I guess safe_file_relative_path would probably enable me to see all the errors in one go, e.g. if I've added a bunch of filepaths it'd be nice to see all the errors at once as opposed to one at a time.
👍 1
o
I think for a lot of unit test setups (although admittedly not all of them), you'd be initializing essentially your entire dagster repository (you could even add a "test_repo_loads" unit test to make sure it did). at this point in time, I believe any issues with missing file paths would be uncovered if you were using safe_file_relative_path (depending on where exactly you're making those calls). I don't think the directory that you run the tests from should have an impact on how the file relative path gets resolved.