-
Notifications
You must be signed in to change notification settings - Fork 258
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
Migrate to pathlib #537
Migrate to pathlib #537
Conversation
The dagger object passed below: imitation/src/imitation/scripts/train_imitation.py Lines 99 to 108 in 81d1594
contains an expert_policy_path key that points to data/expert_models/cartpole_0/policies/final , but this path never exists during the lifecycle of the tests (not relative to the cwd or to any other directory), nor is it used anywhere in the tests. The actual location of the policy is in tests/testadata/ . This is injected through the TEST_DATA_PATH when the policy is actually accessed, but this strange path is still getting constructed.
|
Something closely related to this is what happens below: imitation/src/imitation/scripts/common/demonstrations.py Lines 37 to 49 in 81d1594
A similar path is constructed when I presume this is some sort of fallback-setting feature that tries to guess where the files are, but cannot find the test corresponding to this feature. |
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.
Thanks for making this change, seems like a significant improvement to our path handling.
Most of my comments are nits. The one substantive one is to actually add some tests for types.parse_path
-- shouldn't be too hard.
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.
LGTM, some small suggestions
Co-authored-by: Adam Gleave <[email protected]>
Co-authored-by: Adam Gleave <[email protected]>
Description
Fixes #531.
Migrate all path manipulation operations to be done under the pathlib package, a safe and robust way of handling paths accross platforms.
os.path
str
and convert them topathlib.Path
osp
Design Principles
pathlib.Path
objects only (except in some special places) accross internal layers of the APIpathlib.Path
,str
,bytes
, orpath-like
and convert with validation topathlib.Path
at the highest API level (user level)The reason for enforcing these checks is:
Path
objects, we should use them everywhere that is viable, unless there is a good reason for itcd
into the folder directly.Testing
Current tests should suffice, if the migration is done properly nothing should break. No new features are being added.