Sample management backed by MongoDB
- Free software: 3-clause BSD license
- Documentation: (COMING SOON!) https://danielballan.github.io/amostra.
- TODO
amostra is a collection of light-weight sample management classes.
Home Page: https://nsls-ii.github.io/amostra
License: BSD 3-Clause "New" or "Revised" License
Sample management backed by MongoDB
Allow bulk insert of containers, samples and requests.
The first two will be heavily used when importing data from files.
Since we are allowed to update the entries for Sample, Container and others, it would be useful to also be allowed to update the time to reflect the last modified
time.
Also we should be allowed to update the name field, references must be made to the "uid" and not name, so there is no problem in updating it.
Attn. @arkilic
See: https://github.com/NSLS-II/amostra/blob/master/amostra/server/engine.py#L367
It should be:
raise compose_err_msg(500,
'Time, uid and name cannot be updated')
Or the name parameter must be removed from the verification.
Att. @arkilic
We want generate random fake sample data but human readable, not random unicode code point. In hypothesis, people could achieve this by alphabet
in strategies.text
, doc here.
We may want do same thing when call from_schema
. Unfortunately or Fortunately, hypothesis-jsonschema doesn't allow people explicitly specify string alphabet. Alternatively, we could setup pattern
in jsonschema. The role of current sample.json file is validation. A new file might be useful to separate template and validate roles.
(edited to add features)
@arkilic and I are going over Amostra locally and here are the bugs/improvements needed:
To be continued...
sample_ref.get_schema()
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
<ipython-input-12-bc74dccf93d4> in <module>()
----> 1 sample_ref.get_schema()
/home/slepicka/git/amostra/amostra/client/commands.py in get_schema(self)
152 r = requests.get(self._server_path +
153 '/schema_ref', params=ujson.dumps('sample'))
--> 154 r.raise_for_status()
155 return ujson.loads(r.text)
156
/home/slepicka/mc/envs/collection_dev/lib/python3.5/site-packages/requests/models.py in raise_for_status(self)
838
839 if http_error_msg:
--> 840 raise HTTPError(http_error_msg, response=self)
841
842 def close(self):
HTTPError: 404 Client Error: Not Found for url: http://localhost:7770//schema_ref?%22sample%22
Also get_schema is not present on the other References (Container & Requests).
I would like a way to reference files in amostra using filestore. This way we can load data associated with the sample. eg. keep a couple of potential atomic structures with the sample so that we can compare the the theoretical structure against the observed x-ray data.
Fix the setup.py so I can use the 📦 in my tests!
do this for analysisstore and conftrak as well
currently requiring tornado < 5 - with new releases, update code so the library can run with new tornado.
This library may be useful for validating 'composition'. Via @bruceravel: https://pypi.org/project/chempy/#parsing-formulae
A standard way to document REST APIs is with a swagger.io JSON file such as this example which can then be used to generate nice documentation.
The documentation at https://nsls-ii.github.io/amostra is out of date. Follow https://nsls-ii.github.io/scientific-python-cookiecutter/publishing-docs.html to set up doctr.
The deploy command should be slightly different than the one in that documentation, though, because we publish to an orgnaization repo, NSLS-II/NSLS-II.github.io. The command should be:
doctr deploy --deploy-repo NSLS-II/NSLS-II.github.io --deploy-branch-name master amostra;
The link in the README, which currently points to my personal fork, should also be updated.
I got this idea from here.
https://stackoverflow.com/questions/4185105/ways-to-implement-data-versioning-in-mongodb
This issue is continue discuss of #44. But it should be readable independently.
Usually Sample could create object successfully like scenario below.
Success
>>> from amostra.objects import Sample
>>> foo = Sample(None, name='abc')
>>> foo
Sample(composition='', description='', name='abc', projects=[], tags=[])
Failure
However, if name
is empty string ''
, recursion will be triggered. This was pointed by @tacaswell and I just copy past code here
>>> from amostra.objects import Sample
>>> foo = Sample(None, name='')
>>> foo
***Recursion maximum triggered
This issue tries to explain the details under the hood, but before there are some tips
Tips
compositioin
, description
and name
are Unicode
which is raw type. projects
and tags
are List
which inherent from Instance
in traitlets.Sample.__get__
is called, traitlets tries to get the value from Sample._trait_values
which is a dict of attribute_name: attribute_value
. If except, it tries to be smart to help you figure out(including call dynamic default to help you)._validate
function def _validate(self, obj, value):
if value is None and self.allow_none:
return value
if hasattr(self, 'validate'):
value = self.validate(obj, value)
if obj._cross_validation_lock is False:
value = self._cross_validate(obj, value)
return value
Pipelines of success scenario
traitlets
which is empty string ''
herename='abc'
self.hold_trait_notifications
__enter__
and set it back to False when __exit__
_validate_with_jsonschema
_validate_with_jsonschema
invokes to_dict
method which will call get
for all attributes.projects
wasn't initialized in here(not exist in foo._trait_values
), it end up to call dynamic default method to generate default value._validate
function_cross_validation_lock
== True, SKIP self._cross_validate
self._trait_values['projects'] = value
Pipelines of failure scenario
>>> foo
***Recursion maximum triggered
__repr__
,__get__
then get
method for all attributes'projects'
wasn't initialized in here(not exist in foo._trait_values
), it's call dynamic_default method to generate default value._validate
functionsince _cross_validation_lock
== False, RUN self._cross_validate
self._cross_validate
will trigger user defined validation function which is _validate_with_jsonschema
_validate_with_jsonschema
invoke to_dict
method which actually called __get__
for all attributes.Solution(has been implement in #52)
The solution could be using a cross_validation_lock
contextmanager to control steps 5 to break loop.
__repr__
,__get__
method for all attributes'projects'
wasn't initialized(not exist in foo._trait_values
),it's call dynamic default method to generate default value._validate
function_cross_validation_lock == False
in context, SKIP self._cross_validateself._trait_values['projects'] = value
https://github.com/danielballan/amostra/blob/first-pass/amostra/objects.py#L44
I feel user may want to see revision num when then dolist(sample.revisions())
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.