Skip to content

Sine wave addition for Galvos#337

Merged
annie-xd-wang merged 19 commits into
developfrom
melissa-branch-uno
Feb 8, 2023
Merged

Sine wave addition for Galvos#337
annie-xd-wang merged 19 commits into
developfrom
melissa-branch-uno

Conversation

@HoneybeeATc
Copy link
Copy Markdown
Contributor

Please note that the generic configuration file and the waveform_contstants file were both changed on accident. Please do not merge these into the main develop branch unless that is a change that we want.

HoneybeeATc and others added 6 commits January 18, 2023 16:18
Small addition for FTP-2000 stage.
Updating from develop.

Co-Authored-By: Kevin Dean <42547789+AdvancedImagingUTSW@users.noreply.github.com>
For #180 - Goal is to provide two sine waves that are 90 degrees out of phase to drive galvos for a ring TIRF application.  Ran into other errors that require further evaluation, but we have it working.  Will need to make sure that the changes to the configuration file are agreed upon by everyone, and that the proper changes are added so that we don't mess up other operation modes...

Co-Authored-By: Kevin Dean <42547789+AdvancedImagingUTSW@users.noreply.github.com>
Linter change.
@HoneybeeATc HoneybeeATc changed the title Sine wave addition for Galvos Sine wave addition for Galvos - Do not Merge Jan 25, 2023
@HoneybeeATc HoneybeeATc changed the title Sine wave addition for Galvos - Do not Merge Sine wave addition for Galvos - Do NOT Merge Jan 25, 2023
@HoneybeeATc HoneybeeATc requested review from annie-xd-wang and zacsimile and removed request for annie-xd-wang January 25, 2023 23:15
@HoneybeeATc HoneybeeATc changed the title Sine wave addition for Galvos - Do NOT Merge Sine wave addition for Galvos Jan 25, 2023
@zacsimile
Copy link
Copy Markdown
Collaborator

I assume this is ready for review now? Rather than writing DO NOT MERGE, we could consider using the "Convert to draft" button until we are ready for review. This is on the side bar underneath reviewers.

image

@zacsimile
Copy link
Copy Markdown
Collaborator

It looks like there is an error in the tests. This should be fixed before merging.

__________________ ERROR at setup of test_change_resolution ___________________

    @pytest.fixture(scope="function")
    def model():
        from types import SimpleNamespace
        from pathlib import Path
    
        from aslm.model.model import Model
        from multiprocessing import Manager, Queue
        from aslm.config.config import load_configs
    
        # Use configuration files that ship with the code base
        configuration_directory = Path.joinpath(
            Path(__file__).resolve().parent.parent.parent, "src", "aslm", "config"
        )
        configuration_path = Path.joinpath(configuration_directory, "configuration.yaml")
        experiment_path = Path.joinpath(configuration_directory, "experiment.yml")
        waveform_constants_path = Path.joinpath(configuration_directory, "waveform_constants.yml")
        rest_api_path = Path.joinpath(configuration_directory, "rest_api_config.yml")
    
        event_queue = Queue(100)
        manager = Manager()
    
        configuration = load_configs(
            manager,
            configuration=configuration_path,
            experiment=experiment_path,
            waveform_constants=waveform_constants_path,
            rest_api_config=rest_api_path,
        )
>       model = Model(
            USE_GPU=False,
            args=SimpleNamespace(synthetic_hardware=True),
            configuration=configuration,
            event_queue=event_queue,
        )

test\model\test_model.py:65: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src\aslm\model\model.py:114: in __init__
    self.microscopes[microscope_name] = Microscope(
src\aslm\model\microscope.py:182: in __init__
    exec(
<string>:1: in <module>
    ???
src\aslm\model\device_startup_functions.py:[80](https://github.com/TheDeanLab/ASLM/actions/runs/4010843225/jobs/6887788359#step:5:81)7: in start_galvo
    return SyntheticGalvo(microscope_name, device_connection, configuration, id)
src\aslm\model\devices\galvo\galvo_synthetic.py:86: in __init__
    super().__init__(microscope_name, device_connection, configuration, galvo_id)
src\aslm\model\devices\galvo\galvo_base.py:104: in __init__
    self.galvo_waveform = configuration["configuration"]["microscopes"][
<string>:2: in __getitem__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <DictProxy object, typeid 'dict' at 0x20c158dca90>
methodname = '__getitem__', args = ('waveform',), kwds = {}

    def _callmethod(self, methodname, args=(), kwds={}):
        '''
        Try to call a method of the referent and return a copy of the result
        '''
        try:
            conn = self._tls.connection
        except AttributeError:
            util.debug('thread %r does not own a connection',
                       threading.current_thread().name)
            self._connect()
            conn = self._tls.connection
    
        conn.send((self._id, methodname, args, kwds))
        kind, result = conn.recv()
    
        if kind == '#RETURN':
            return result
        elif kind == '#PROXY':
            exposed, token = result
            proxytype = self._manager._registry[token.typeid][-1]
            token.address = self._token.address
            proxy = proxytype(
                token, self._serializer, manager=self._manager,
                authkey=self._authkey, exposed=exposed
                )
            conn = self._Client(token.address, authkey=self._authkey)
            dispatch(conn, None, 'decref', (token.id,))
            return proxy
>       raise convert_to_error(kind, result)
E       KeyError: 'waveform'

C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\multiprocessing\managers.py:[82](https://github.com/TheDeanLab/ASLM/actions/runs/4010843225/jobs/6887788359#step:5:83)5: KeyError
---------------------------- Captured stdout setup ----------------------------
KeyError encountered in device_ref_dict, microscope.py

@AdvancedImagingUTSW
Copy link
Copy Markdown
Collaborator

I guess I am confused by the DictProxy. When I go in and debug the test that is showing the error, I can get the dictionary value that I want. However, this fails the rest of the time.

image

Stops the Ruff violence.

None of the device startup functions were being found because they are within an exec/f-string statement. By moving the import of these models into a similar f-string, I should be able to commit the code.

Trade one problem for another.
@zacsimile
Copy link
Copy Markdown
Collaborator

From the error in the tests, it looks like maybe the waveform key isn't specified for some of the galvos. Is that possible? You could swap that line to self.galvo_waveform = self.device_config.get('waveform', 'sawtooth') to make it default to sawtooth in the absence of a key.

@zacsimile
Copy link
Copy Markdown
Collaborator

Re: cc3f8d8. You could also have put # noqa: F401 at the end of the line for each of the "unused" imports.

@AdvancedImagingUTSW
Copy link
Copy Markdown
Collaborator

Whatever you think is the best approach for the imports I can adopt.

Wow.  Didn't realize there were two galvos specified. I feel a bit stupid after trying to diagnose that error for so long...
I struggle...  Updated local, but not the one in config.
@AdvancedImagingUTSW AdvancedImagingUTSW removed the request for review from zacsimile February 7, 2023 16:01
@AdvancedImagingUTSW
Copy link
Copy Markdown
Collaborator

@annie-xd-wang, I know this one is a bit painful. But if you want me to go through it with you I can. Would love to get it closed out.

@annie-xd-wang annie-xd-wang merged commit 5e59381 into develop Feb 8, 2023
@AdvancedImagingUTSW AdvancedImagingUTSW deleted the melissa-branch-uno branch December 15, 2023 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants