-
Notifications
You must be signed in to change notification settings - Fork 34
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 projections schema to start doc #179
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5d840b5
Add projections schema to start doc
dylanmcreynolds 12e9551
cleaned linbreaks nad added a description
dylanmcreynolds a3b7b99
Change start_doc creation, moved and added tests
dylanmcreynolds d374efc
add callable
dylanmcreynolds 7171fe7
backed out change to compose_run
dylanmcreynolds 01ff096
simplified test
dylanmcreynolds 50efe13
Removed static option for projection
dylanmcreynolds 3fb6a56
removed chagned " back to "configuration".
dylanmcreynolds e71851d
Added a note about experimental projections
dylanmcreynolds 41af2e0
flake8 fixes
dylanmcreynolds 5f56320
flake8 fixes
dylanmcreynolds 2701b09
flake8 fixes
dylanmcreynolds 2ca0aec
Do not specify 'projection' as required twice.
danielballan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import event_model | ||
import pytest | ||
from jsonschema.exceptions import ValidationError | ||
|
||
def test_projection_start_doc(): | ||
metadata = {'so_long': 'thanks_for_all_the_fish'} | ||
# proejctions are added to metadata which is added to start document, so | ||
# we have several paths to test here | ||
|
||
# 1 add proection without metadata | ||
run_bundle = event_model.compose_run(uid="42", projections=valid_projections) | ||
start_doc = run_bundle.start_doc | ||
assert start_doc['projections'] == valid_projections | ||
|
||
# 2 add no projection | ||
run_bundle = event_model.compose_run(uid="42", metadata=metadata) | ||
start_doc = run_bundle.start_doc | ||
assert 'projections' not in start_doc | ||
assert start_doc['so_long'] == 'thanks_for_all_the_fish' | ||
|
||
|
||
# 3 add projection with metadata | ||
run_bundle = event_model.compose_run(uid="42", metadata=metadata, projections=valid_projections) | ||
start_doc = run_bundle.start_doc | ||
assert start_doc['projections'] == valid_projections | ||
assert start_doc['so_long'] == 'thanks_for_all_the_fish' | ||
|
||
|
||
def test_projection_schema(): | ||
start_doc['projections'] = valid_projections | ||
event_model.schema_validators[event_model.DocumentNames.start].validate(start_doc) | ||
|
||
with pytest.raises(ValidationError): | ||
start_doc['projections'] = invalid_projections | ||
event_model.schema_validators[event_model.DocumentNames.start].validate(start_doc) | ||
|
||
|
||
valid_projections = [ | ||
{ | ||
"name": "test", | ||
"version": "42.0.0", | ||
"configuration": {}, | ||
"projection": { | ||
'entry/instrument/detector/data': { | ||
'location': 'event', | ||
'stream': 'primary', | ||
'field': 'ccd', | ||
'slice_args': ['sdfsdfds'] | ||
}, | ||
}, | ||
} | ||
] | ||
|
||
|
||
invalid_projections = [ | ||
{ | ||
"name": "test", | ||
"version": "42.0.0", | ||
"configuration": {}, | ||
"projection": { | ||
'entry/instrument/detector/data': { | ||
'location': 'THIS IS NOT VALID', | ||
'stream': 'primary', | ||
'field': 'ccd', | ||
'slice_args': ['sdfsdfds', 1] | ||
}, | ||
}, | ||
} | ||
] | ||
start_doc = { | ||
"uid": "abc", | ||
"time": 0, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
All other non-required keys enter in through
metadata
. I think we should either add all of them to the signature or leaveprojections
out of the signature.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'll back out that change, let you add a projection to metadata.