Exercise on new db
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
today's exercise:
- Generate a 'start' document with some metadata about a spectrum, an 'event' document with the spectrum, and the other required documents.
- Insert them into a development, disposable MongoDB database (
mongodb://xf08id-ca1:27017/dev_analyzed_data). - Access the saved metadata and data (as
xarray.Dataset). - Search for the saved spectra based on recency, element metadata, and
E0metadata.
The following needs to be wrapped into an easy-to-use function:
from event_model import compose_run
compose_run()
compose_run?
bundle = compose_run(metadata={'Sample_name': 'Pt', 'compound': 'Pt', 'Element' : 'Pt', 'Edge' : 'L3', 'E0': 11564})
bundle
bundle.start_doc
from suitcase.mongo_normalized import Serializer
ser = Serializer('mongodb://xf08id-ca1:27017/dev_analyzed_data', 'mongodb://xf08id-ca1:27017/dev_analyzed_data')
ser
ser('start', bundle.start_doc)
bundle.compose_descriptor(data_keys={'Energy' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]},''})
bundle.compose_descriptor(data_keys={'Energy' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]}, 'mu_norm' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]}})
bundle2 = bundle.compose_descriptor(data_keys={'Energy' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]}, 'mu_norm' : {'dtype' : 'array', 'source' : '', 'shape' : [-1]}}, name='primary')
bundle2
ser('descriptor', bundle2.descriptor_doc)
bundle2.compose_event(data={'Energy' : [1,2,3], 'mu_norm' : [0.1, 0.2, 0.3]}, timestamps={'Energy':0, 'mu_norm' : 0})
ser('event', _22)
bundle.compose_stop()
ser('stop', _24)
from databroker._drivers.mongo_normalized import BlueskyMongoCatalog
uri = "mongodb://xf08id-ca1:27017/dev_analyzed_data"
catalog = BlueskyMongoCatalog(uri, uri)
catalog
catalog[-1]
catalog[-1].primary
catalog[-1].primary.read()
len(catalog.search({'Element':'Pt'}))
len(catalog.search({'Element':'Co'}))
catalog[-1].metadata
len(catalog.search({'E0':{'$lt' : 10000}}))
len(catalog.search({'E0':{'$gt' : 10000}}))
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names compose_run, suitcase.mongo_normalized.Serializer, and databroker._drivers.mongo_normalized.BlueskyMongoCatalog as entry points, but identifies no repository file or test. Start by locating those APIs and define done as an easy-to-use function covering the document generation, MongoDB storage and access, and metadata searches described in the exercise.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100