Skip to main content

eons sample analyzer and manager

Project description

eons Sample Analysis and Manager

Generalized framework for scientific data analysis.

Design in short: Self-registering functors with reflection to and from json for use with arbitrary data structures.

Installation

pip install esam

Usage

Quickstart: just go copy the example folder somewhere and run esam from that directory; then start hacking!

To use esam (or your own custom variant), you must first invent the universe. Once that's done and you've installed the program on your computer, you'll need to create a workspace. A workspace is any folder you'd like to store your data in which also contains a sam folder. In the sam folder should be the following sub-folders:

  • analysis
  • data
  • format/input
  • format/output

These folders will then be populated by your own data structures (Datum), parsers (InputFormatFunctor), report templates (OutputFormatFunctor), and analysis steps (AnalysisFunctor).

NOTE: it is not necessary to do anything besides place your files in these directories to use them. See below for more info on design. (and technically, it doesn't matter which folder what file is in but the organization will help keep things consistent when publishing or sharing your work)

Design

Functors

Functors are classes (objects) that have an invokable () operator, which allows you to treat them like functions. esam uses functors to provide input, analysis, and output functionality, which is made simple by classical inheritance.

The primary ways functors are used are:

  1. To digest input and store the contents of a file as workable data structures.
  2. To mutate stored data and do analytical work.
  3. To output stored data into a user-friendly report format.

Functors are also used to provide save and load functionality, which is different from inputs and outputs.

For extensibility, all functors take a **kwargs argument. This allows you to provide arbitrary key word arguments (e.g. key="value") to your objects.

Self Registration

Normally, one has to import the files they create into their "main" file in order to use them. That does not apply when using esam. Instead, you simply have to derive from an appropriate base class and then call SelfRegistering.RegisterAllClassesInDirectory(...) (which is done for you on the folder paths detailed above), providing the directory of the file as the only argument. This will essentially import all files in that directory and make them instantiable via SelfRegistering("ClassName").

Example

For example, in some MyDatum.py in a MyData directory, you might have:

import logging
from esam import Datum
class MyDatum(Datum): #Datum is a useful child of SelfRegistering
    def __init__(self, name="only relevant during direct instantiation"):
        logging.info(f"init MyDatum")
        super().__init__()

From our main.py, we can then call:

import sys, os
from esam import RegisterAllClassesInDirectory
RegisterAllClassesInDirectory(os.path.join(os.path.dirname(os.path.abspath(__file__)), "MyData"))

Here, we use os.path to make the file path relevant to the project folder and not the current working directory. Then, from main, etc. we can call:

myDatum = SelfRegistering("MyDatum")

and we will get a MyDatum object, fully instantiated.

Saving and Loading

In addition to having self-registering functors, the last primary feature of esam is reflection between python and json. As long as your Data and Functors (the classes you derive from esam.Datum and esam.UserFunctor or their children), have been registered through RegisterAllClassesInDirectory(), you'll be able to save, load, and thus, work with your data through json.

Saving files thus allows you to retain everything from your original data, no matter how complex the initial analysis was. Consider if you would like to design an analysis pipeline to share with your colleagues. All you have to do is create the functors and have your colleagues place them in their respective folders (no code change necessary on their part, since the new files will be automatically picked up). You can then pass your data as json between each other, potentially creating your own analysis steps, report outputs, etc., all which could be shared later or kept as personalized as you'd like.

Saving and loading is handled by esam, rather than the downstream application. Saved files will always be .json, unless you fork this repository and change the SAM base class.

Currently, jsonpickle is used for json reflection.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

esam-1.0.1.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

esam-1.0.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file esam-1.0.1.tar.gz.

File metadata

  • Download URL: esam-1.0.1.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for esam-1.0.1.tar.gz
Algorithm Hash digest
SHA256 51c0a57b93cedc154749a1efb25a23c07de7a65c794b14293b17bb3bbebec475
MD5 258f69d3f3cf12dac05781a7c3140c48
BLAKE2b-256 0f2472cde1ff2c9585f25f0fe8196917e1f43f539c817adaabf167b1bec63f0b

See more details on using hashes here.

File details

Details for the file esam-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: esam-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for esam-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e5430f35c8c135033c0564f1637d939fa61d581bc45111d18396c274c04de80
MD5 4f3a450096d61f68edf19536926b4945
BLAKE2b-256 03eb511dab61df6e0a1a34cf31f79407f37d77da37f4fb3a2cdd11dcafd07b11

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page