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

Fix path_semantics and be robust against empty 'filled'. #59

Merged
merged 16 commits into from
Mar 28, 2019

Conversation

gwbischof
Copy link
Contributor

No description provided.

@gwbischof
Copy link
Contributor Author

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.

event_model/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@danielballan danielballan left a 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 Show resolved Hide resolved
@@ -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':
Copy link
Member

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, ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@danielballan danielballan changed the title Garrett Fix path_sematnics and be robust against empty 'filled'. Mar 25, 2019
Copy link
Member

@mrakitin mrakitin left a 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.

@@ -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'
Copy link
Member

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)

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@prjemian
Copy link
Contributor

prjemian commented Mar 25, 2019 via email

@mrakitin
Copy link
Member

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.

@mrakitin mrakitin changed the title Fix path_sematnics and be robust against empty 'filled'. Fix path_semantics and be robust against empty 'filled'. Mar 25, 2019
@danielballan
Copy link
Member

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 tmp_path fixture 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.

@prjemian
Copy link
Contributor

prjemian commented Mar 25, 2019 via email

@danielballan
Copy link
Member

If you do go with tmp_path @gwbischof you will need to specify pytest >3.9 here: https://github.com/NSLS-II/event-model/blob/873a874b87b75b0a35dc70d9830bc3790f0c7211/requirements-dev.txt#L6

Travis comes with an older version of pytest pre-installed, so you need to specifically pin it to prompt pip to upgrade.

@mrakitin
Copy link
Member

@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.

@danielballan
Copy link
Member

OK, sounds good.

@danielballan danielballan self-requested a review March 27, 2019 19:09
Copy link
Member

@mrakitin mrakitin left a 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!

@mrakitin mrakitin merged commit 6a6c579 into bluesky:master Mar 28, 2019
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

Successfully merging this pull request may close these issues.

None yet

5 participants