Package: xedocs
xedocs is meant to replace cmt and bodega as well as helping tracking all shared documents especially if
they need to be versioned.What does Xedocs give youData readingRead data from multiple formats (e.g. mongodb, pandas) and locations with a simple unified interface.Custom logic implemented on the document class, e.g. creating a tensorflow model from the data etc.Multiple APIs for reading data, fun functional, ODM style, pandas and xarray.Read data as objects, dataframes, dicts, json.Writing dataWrite data to multiple storage backends with the same interfaceCustom per-collection rules for data insertion, deletion and updating.Schema validation and type coercion so storage has uniform and consistent data.OtherCustom panel widgets for graphical representation of data, web clientAuto-generated API server and client + openapi documentationCLI for viewing and downloading dataBasic UsageExplore the available schemasimportxedocs>>>xedocs.list_schemas()>>>['detector_numbers','fax_configs','plugin_lineages','context_lineages','pmt_area_to_pes','global_versions','electron_drift_velocities',...]>>>xedocs.help('pmt_area_to_pes')>>>Schemaname:pmt_area_to_pesIndexfields:['version','time','detector','pmt']Columnfields:['created_date','comments','value']Read/write data from the shared development database,
this database is writable from the default analysis username/passwordimportxedocsdb=xedocs.development_db()docs=db.pmt_area_to_pes.find_docs(version='v1',pmt=[1,2,3,5],time='2021-01-01T00:00:00',detector='tpc')to_pes=[doc.valuefordocindocs]# passing a run_id will attempt to fetch the center time of that run from the runs dbdoc=db.pmt_area_to_pes.find_one(version='v1',pmt=1,run_id=25000,detector='tpc')to_pe=doc.valueRead from the straxen processing database, this database is read-only for the default analysis username/passwordimportxedocsdb=xedocs.straxen_db()...Read from the the corrections gitub repository, this database is read-onlyimportxedocsdb=xedocs.corrections_repo(branch="master")...If you cloned the corrections gitub repo to a local folder, this database can be read tooimportxedocsdb=xedocs.local_folder(PATH_TO_REPO_FOLDER)...Read data from alternative data sources specified by path,
e.g csv files which will be loaded by pandas.fromxedocs.schemasimportDetectorNumberg1_doc=DetectorNumber.find_one(datasource='/path/to/file.csv',version='v1',field='g1')g1_value=g1_doc.valueg1_error=g1_doc.uncertaintyThe path can also be a github URL or any other URL supported by fsspec.fromxedocs.schemasimportDetectorNumberg1_doc=DetectorNumber.find_one(datasource='github://org:repo@/path/to/file.csv',version='v1',field='g1')Supported data sourcesMongoDB collectionsTinyDB tablesJSON filesREST API clientsPlease open an issue onrframeif you want support for an additional data format.If you want a new datasource to be available from a schema class, you can register it to the class:fromxedocs.schemasimportDetectorNumberDetectorNumber.register_datasource('github://org:repo@/path/to/file.csv',name='github_repo')# The source will now be available under the given name:g1_doc=DetectorNumber.github_repo.find_one(version='v1',field='g1')DocumentationFull documentation hosted byReadthedocsCreditsThis package was created withCookiecutterand thebriggySmalls/cookiecutter-pypackageproject template.