-
Notifications
You must be signed in to change notification settings - Fork 29
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
Fix path_semantics and be robust against empty 'filled'. #59
Conversation
…filled key, made a fix for this
There are so many commits because the tests fail on my windows machine, so I'm using travis until I can fix the windows errors. |
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 the fix! Some small suggestions.
event_model/__init__.py
Outdated
@@ -499,6 +499,8 @@ def compose_resource(*, start, spec, root, resource_path, resource_kwargs, | |||
path_semantics=os.name, uid=None, validate=True): | |||
if uid is None: | |||
uid = str(uuid.uuid4()) | |||
if path_semantics == 'nt': |
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 worry that this might confuse users who look at the function signature (i.e. compose_resource?
in IPython) and find a default valid that is not a valid value. Have you considered doing this translation from os.name
to path_semantics
above the function definition rather than inside it?
default_path_semantics = {...}[os.name]
def compose_resource(..., path_semantics=default_path_semantics, ...)
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.
updated
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.
Looks good to me after @danielballan's suggestions are implemented.
Left one important suggestion regarding paths.
event_model/tests/test_em.py
Outdated
@@ -131,8 +146,14 @@ def test_bulk_events_to_event_page(): | |||
desc_bundle_baseline = run_bundle.compose_descriptor( | |||
data_keys={'motor': {'shape': [], 'dtype': 'number', 'source': '...'}}, | |||
name='baseline') | |||
|
|||
if os.name == 'nt': | |||
path_root = 'C:\tmp' |
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.
To avoid it to be evaluated as "tab" (\t
)
path_root = 'C:\tmp' | |
path_root = 'C:\\tmp' |
Quick IPython demo:
In [1]: path_root = 'C:\tmp'
In [2]: path_root
Out[2]: 'C:\tmp'
In [3]: print(path_root)
C: mp
In [4]: path_root = 'C:\\tmp'
In [5]: path_root
Out[5]: 'C:\\tmp'
In [6]: print(path_root)
C:\tmp
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.
updated
Isn't there an OS specific python term for the temporary directory? Lacking
that, Windows has an environment variable for TEMPDIR (iirc, need to
confirm exact spelling) so we can relax the assumption on the C: drive.
Otherwise, that is a point of failure, albeit uncommon.
…On Mon, Mar 25, 2019, 4:54 PM Maksim Rakitin ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Looks good to me after @danielballan <https://github.com/danielballan>'s
suggestions are implemented.
Left one important suggestion regarding paths.
------------------------------
In event_model/tests/test_em.py
<#59 (comment)>:
> @@ -131,8 +146,14 @@ def test_bulk_events_to_event_page():
desc_bundle_baseline = run_bundle.compose_descriptor(
data_keys={'motor': {'shape': [], 'dtype': 'number', 'source': '...'}},
name='baseline')
+
+ if os.name == 'nt':
+ path_root = 'C:\tmp'
To avoid it to be evaluated as "tab" (\t)
⬇️ Suggested change
- path_root = 'C:\tmp'
+ path_root = 'C:\\tmp'
Quick IPython demo:
In [1]: path_root = 'C:\tmp'
In [2]: path_root
Out[2]: 'C:\tmp'
In [3]: print(path_root)
C: mp
In [4]: path_root = 'C:\\tmp'
In [5]: path_root
Out[5]: 'C:\\tmp'
In [6]: print(path_root)
C:\tmp
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#59 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACLKMGcmOowawNZ93aDHzHa_jMZvy8u2ks5vaPEmgaJpZM4b63Y8>
.
|
Thanks for the feedback, @prjemian! I think the motivation here is to test with the Windows path semantics as it would be on a Windows collection machine with real paths, not just temporary placeholders. We had a similar problem in ophyd, bluesky/ophyd#703. A general comment: it would be nice to have a template for the issues/PRs the same way we have it for Bluesky. I hope it will enforce stricter descriptions and motivations sections. |
I had the same thought as @prjemian but didn't bother raising it. I'm not sure I understand your point about testing a "real path". I think this would be a reasonable place to use pytest's |
+1 for tmp_path
…On Mon, Mar 25, 2019, 6:33 PM Dan Allan ***@***.***> wrote:
I had the same thought as @prjemian <https://github.com/prjemian> but
didn't bother raising it. I'm not sure I understand your point about
testing a "real path". I think this would be a reasonable place to use pytest's
tmp_path fixture <https://docs.pytest.org/en/latest/tmpdir.html> which is
how we handle this in suitcase-utils. It would remove a bunch of if
blocks and also ensure that the sample files are cleaned up on test exit.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#59 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACLKMMGb2kMPF-IUTXooxADMRUIvQaLJks5vaQhKgaJpZM4b63Y8>
.
|
If you do go with Travis comes with an older version of |
@danielballan, it seems the suggested tmp_path fixture will help here. My point was to have test cases, realistically describing different use cases. But I believe it can be obtained via the fixtures by providing different sets of parameters. |
OK, sounds good. |
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.
Looks good to me!
No description provided.