Skip to content
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

Device persistence enhancements #2

Open
sequoiap opened this issue May 4, 2021 · 0 comments
Open

Device persistence enhancements #2

sequoiap opened this issue May 4, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@sequoiap
Copy link
Collaborator

sequoiap commented May 4, 2021

As per our discussion, @mcgeorge102938 , here's the sample file we whipped up (storing here so I don't have to keep track of it on my computer)

# autogator's __init__'
__CONFIG_DIR__ = appdirs.path


# registry.py
from autogator import __CONFIG_DIR__
if __CONFIG_DIR__ / "register.yaml" exists:
    load(item in config_dir)

class Registry:
    def __init__(self):
        self.register = {}

    def register(self, name, device):
        self.register[name] = device

    def get(self, name):
        return device

    def save(self):
        # writes configuration/registry to the yaml config file
        pass

class LocalDevice:
    pass

class PyrolabDevice:
    pass

registry = Registry()


# In scripts, we could then do something like this:
from autogator.registry import registry
registry.register("laser", LocalDevice("lasers.tsl550"))
registry.register("motion_x", PyrolabDevice("motion.kcubes.bpc303"))
registry.register("motion_y", LocalDevice(34878427))

motionstage = registry.get('motion_y')
motionstage.jog(0.1)



# experiment.py
class Experiment:
    def __init__(self):
        self.instruments = registry.get_instruments()

    def run(self):
        raise NotImplementedError


class MyExperiment(Experiment):
    def run():
        laser = self.instruments['laser']
        laser.sweep()
        scope.acquire()


# Future testrunner for batched tests
from autogator import testrunner

testrunner.add_test(MyExperiment)
testrunner.run_all()

"""
Review
------

* Naming conventions
* Logical modules
* tests folder
* examples folder
* Clean up parser
* Installation directory, pyyaml config files, persisting devices

1. refactor
2. example
3. test framework
4. added features (persistence, registry, testrunner)
"""

@sequoiap sequoiap added the enhancement New feature or request label May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants