Skip to content

Commit

Permalink
revert accidental changes
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypinkard committed Jul 9, 2024
1 parent 1e13f6e commit ce1b028
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 39 deletions.
6 changes: 3 additions & 3 deletions pycromanager/acquisition/RAMStorage_java.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

class NDRAMDatasetJava(NDStorageBase):
"""
A python class that wraps a Java-backend RAM data storage_implementations.
A python class that wraps a Java-backend RAM data storage.
This class maintains an index of which images have been saved, but otherwise routes all calls to the Java
implementation of the RAM data storage_implementations.
implementation of the RAM data storage.
"""

def __init__(self, java_RAM_data_storage):
Expand All @@ -22,7 +22,7 @@ def close(self):

def add_available_axes(self, image_coordinates):
"""
The Java RAM storage_implementations has received a execution_engine image with the given axes. Add these axes to the index.
The Java RAM storage has received a new image with the given axes. Add these axes to the index.
"""
self._index_keys.add(frozenset(image_coordinates.items()))
# update information about the available images
Expand Down
17 changes: 0 additions & 17 deletions pycromanager/acquisition/acq_eng_py/internal/hooks.py

This file was deleted.

47 changes: 39 additions & 8 deletions pycromanager/headless.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import types
import os

# from pycromanager.acquisition.acq_eng_py.kernel.engine import Engine
from pycromanager.acquisition.acq_eng_py.internal.engine import Engine
from pymmcore import CMMCore
import pymmcore
from pyjavaz import DEFAULT_BRIDGE_PORT, server_terminated
Expand Down Expand Up @@ -36,7 +36,7 @@ def _create_pymmcore_instance():
2. add convenience methods to match the MMCoreJ API:
"""

# Create a execution_engine dictionary for the class attributes
# Create a new dictionary for the class attributes
new_attributes = {}

# Iterate through the original attributes
Expand All @@ -49,9 +49,42 @@ def _create_pymmcore_instance():
new_attr_name = _camel_to_snake(attr_name)
new_attributes[new_attr_name] = attr_value

# Create and return a execution_engine class that subclasses the original class and has the execution_engine attributes
# Create and return a new class that subclasses the original class and has the new attributes
clz = type(CMMCore.__name__ + "SnakeCase", (CMMCore,), new_attributes)

instance = clz()

def pop_next_tagged_image(self):
md = pymmcore.Metadata()
pix = self.pop_next_image_md(0, 0, md)
tags = {key: md.GetSingleTag(key).GetValue() for key in md.GetKeys()}
return TaggedImage(tags, pix)

def get_tagged_image(core, cam_index, camera, height, width, binning=None, pixel_type=None, roi_x_start=None,
roi_y_start=None):
"""
Different signature than the Java version because of difference in metadata handling in the swig layers
"""
pix = core.get_image()
md = pymmcore.Metadata()
# most of the same tags from pop_next_tagged_image, which may not be the same as the MMCoreJ version of this function
tags = {'Camera': camera, 'Height': height, 'Width': width, 'PixelType': pixel_type,
'CameraChannelIndex': cam_index}
# Could optionally add these for completeness but there might be a performance hit
if binning is not None:
tags['Binning'] = binning
if roi_x_start is not None:
tags['ROI-X-start'] = roi_x_start
if roi_y_start is not None:
tags['ROI-Y-start'] = roi_y_start

return TaggedImage(tags, pix)

instance.get_tagged_image = types.MethodType(get_tagged_image, instance)
instance.pop_next_tagged_image = types.MethodType(pop_next_tagged_image, instance)

# attach TaggedImage class
instance.TaggedImage = TaggedImage
return instance


Expand Down Expand Up @@ -79,9 +112,8 @@ def stop_headless(debug=False):
logger.debug('Stopping pymmcore instance')
c.unloadAllDevices()
if debug:
logger.debug('Unloaded all device_implementations.py')
# TODO: shutdown execution_engine engine
# Engine.get_instance().shutdown()
logger.debug('Unloaded all devices')
Engine.get_instance().shutdown()
if debug:
logger.debug('Engine shut down')
_PYMMCORES.clear()
Expand Down Expand Up @@ -137,8 +169,7 @@ def start_headless(
mmc.load_system_configuration(config_file)
mmc.set_circular_buffer_memory_footprint(buffer_size_mb)
_PYMMCORES.append(mmc) # Store so it doesn't get garbage collected
# TODO: startup execution_engine engine
# Engine(mmc)
Engine(mmc)
else:
classpath = mm_app_path + '/plugins/Micro-Manager/*'
if java_loc is None:
Expand Down
6 changes: 3 additions & 3 deletions pycromanager/mm_java_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __new__(
port: int
The port of the Bridge used to create the object
new_socket: bool
If True, will create execution_engine java object on a execution_engine port so that blocking calls will not interfere
If True, will create new java object on a new port so that blocking calls will not interfere
with the bridges main port
debug:
print debug messages
Expand Down Expand Up @@ -117,7 +117,7 @@ def __new__(
port: int
The port of the Bridge used to create the object
new_socket: bool
If True, will create execution_engine java object on a execution_engine port so that blocking calls will not interfere
If True, will create new java object on a new port so that blocking calls will not interfere
with the bridges main port
debug: bool
print debug messages
Expand All @@ -142,7 +142,7 @@ def __new__(
port: int
The port of the Bridge used to create the object
new_socket: bool
If True, will create execution_engine java object on a execution_engine port so that blocking calls will not interfere
If True, will create new java object on a new port so that blocking calls will not interfere
with the bridges main port
debug: bool
print debug messages
Expand Down
6 changes: 3 additions & 3 deletions pycromanager/napari_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def start_napari_signalling(viewer, dataset):
"""
Start up a threadworker, which will check for execution_engine images arrived in the dataset
Start up a threadworker, which will check for new images arrived in the dataset
and then signal to napari to update or refresh as needed
:param viewer: the napari Viewer
:param dataset: the Datatset being acquired
Expand All @@ -17,7 +17,7 @@ def start_napari_signalling(viewer, dataset):

def update_layer(image):
"""
update the napari layer with the execution_engine image
update the napari layer with the new image
"""
if image is not None:
try:
Expand All @@ -29,7 +29,7 @@ def update_layer(image):
@thread_worker(connect={'yielded': update_layer})
def napari_signaller():
"""
Monitor for signals that Acquisition has a execution_engine image ready, and when that happens
Monitor for signals that Acquisition has a new image ready, and when that happens
update napari appropriately
"""
# don't update faster than the display can handle
Expand Down
4 changes: 2 additions & 2 deletions pycromanager/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def install_mm():
# find pycro-manager/java path
if os.path.isdir('java'):
java_path = os.path.abspath('java')
# in case cwd is '/pycromanager/integration_tests'
# in case cwd is '/pycromanager/test'
elif os.path.isdir('../../java'):
java_path = os.path.abspath('../../java')
else:
Expand All @@ -86,7 +86,7 @@ def install_mm():
print(f'Removed {file_path}')

# Copy the pycromanagerjava.jar file that was compiled by the github action
# into the nightly build so that it will integration_tests with the latest code
# into the nightly build so that it will test with the latest code
compiled_jar_path = os.path.join(java_path, 'target', 'PycromanagerJava-*.jar')
destination_path = os.path.join(mm_install_dir, 'plugins', 'Micro-Manager', 'PycromanagerJava.jar')

Expand Down
2 changes: 1 addition & 1 deletion pycromanager/test/test_callback_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def hook_fn(event):
return None # cancel the event

with Acquisition(show_display=False, pre_hardware_hook_fn=hook_fn) as acq:
# copy list of event_implementations to avoid popping from original
# copy list of events to avoid popping from original
events_copy = [e for e in events]
for test_event in events:
acq.acquire(test_event)
Expand Down
4 changes: 2 additions & 2 deletions pycromanager/test/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# TODO: add tests for timing of blocking until different parts of the hardware sequence
# def test_async_images_read(launch_mm_headless, setup_data_folder):
# start = time.time()
# event_implementations = multi_d_acquisition_events(num_time_points=10, time_interval_s=0.5)
# events = multi_d_acquisition_events(num_time_points=10, time_interval_s=0.5)
# with Acquisition(directory=setup_data_folder, show_display=False) as acq:
# future = acq.acquire(event_implementations)
# future = acq.acquire(events)
#
# future.await_execution({'time': 5}, AcqNotification.Hardware.POST_HARDWARE)

Expand Down

0 comments on commit ce1b028

Please sign in to comment.