Skip to content

Commit

Permalink
run tests with latest pycromanager java source
Browse files Browse the repository at this point in the history
henrypinkard committed Sep 7, 2023
1 parent 6efafc7 commit eb9f910
Showing 2 changed files with 19 additions and 10 deletions.
19 changes: 14 additions & 5 deletions pycromanager/test/conftest.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import requests
import re
import time
import glob

import pycromanager
from pycromanager import start_headless
@@ -17,7 +18,6 @@ def is_port_in_use(port):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
return s.connect_ex(('localhost', port)) == 0


def find_jar(pathname, jar_name):
p = re.compile(jar_name + r"-(\d+).(\d+).(\d+).jar")

@@ -82,6 +82,7 @@ def install_mm(download_mm_nightly):
mm_running = False
mm_install_dir = os.path.join(os.path.expanduser('~'), "Micro-Manager-nightly")


# check if there is currently a Micro-manager instance running (used for local testing)
if is_port_in_use(4827):
mm_running = True
@@ -122,11 +123,19 @@ def install_mm(download_mm_nightly):
else:
raise RuntimeError('Could not find pycro-manager/java path')

# Update pycromanager jar files packaged with the Micro-manager nightly build

# Copy the pycromanagerjava.jar file that was compiled by the github action
# 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 where the jar file should be copied to
destination_path = os.path.join(mm_install_dir, 'plugins', 'Micro-Manager', 'PycromanagerJava.jar')
# Find the actual file that matches the pattern and copy it to the destination
for file_path in glob.glob(compiled_jar_path):
shutil.copy2(file_path, destination_path)
print(f'Copied {file_path} to {destination_path}')

# Update pycromanager dependency jar files packaged with the Micro-manager nightly build
# Files are updated only if they are larger version
if os.path.isdir(os.path.join(java_path, 'target')):
replace_jars(os.path.join(java_path, 'target'), os.path.join(mm_install_dir, 'plugins', 'Micro-Manager'),
['PycroManagerJava'])
# Copy dependency jar files if present in target/dependency
if os.path.isdir(os.path.join(java_path, 'target/dependency')):
replace_jars(os.path.join(java_path, 'target/dependency'), os.path.join(mm_install_dir, 'plugins', 'Micro-Manager'),
10 changes: 5 additions & 5 deletions pycromanager/test/test_viewer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import pytest
from pycromanager import JavaBackendAcquisition, ZMQRemoteMMCoreJ, multi_d_acquisition_events
from pycromanager import Acquisition, Core, multi_d_acquisition_events
import napari

# Skip tests in this module if it is running in GitHub Actions, which does not support NDViewer
@@ -14,7 +14,7 @@ def test_timelapse_NDViewer(launch_mm_headless, setup_data_folder):
time_interval_s=0,
)

with JavaBackendAcquisition(setup_data_folder, 'acq', show_display=True) as acq:
with Acquisition(setup_data_folder, 'acq', show_display=True) as acq:
acq.acquire(events)

# close viewer
@@ -33,7 +33,7 @@ def test_multi_d_acq_NDViewer(launch_mm_headless, setup_data_folder):
order="tcz",
)

with JavaBackendAcquisition(setup_data_folder, 'acq', show_display=True) as acq:
with Acquisition(setup_data_folder, 'acq', show_display=True) as acq:
acq.acquire(events)

# close viewer
@@ -48,7 +48,7 @@ def test_timelapse_napari_viewer(launch_mm_headless, setup_data_folder):

viewer = napari.Viewer()

acq = JavaBackendAcquisition(setup_data_folder, 'acq', napari_viewer=viewer)
acq = Acquisition(setup_data_folder, 'acq', napari_viewer=viewer)
acq.acquire(events)
acq.mark_finished()

@@ -71,7 +71,7 @@ def test_multi_d_acq_napari_viewer(launch_mm_headless, setup_data_folder):

viewer = napari.Viewer()

acq = JavaBackendAcquisition(setup_data_folder, 'acq', napari_viewer=viewer)
acq = Acquisition(setup_data_folder, 'acq', napari_viewer=viewer)
acq.acquire(events)
acq.mark_finished()

0 comments on commit eb9f910

Please sign in to comment.