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

Update to 4.2.8 #9

Merged
merged 11 commits into from
Oct 17, 2024
2 changes: 1 addition & 1 deletion cellprofiler_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.2.6"
__version__ = "4.2.8"
55 changes: 0 additions & 55 deletions cellprofiler_core/__main__.py
Original file line number Diff line number Diff line change
@@ -1,55 +0,0 @@
import os
import pathlib

import click

import cellprofiler_core.commands

CONTEXT_SETTINGS = dict(auto_envvar_prefix="COMPLEX")


class Command(click.MultiCommand):
def get_command(self, context, name):
try:
name = f"cellprofiler_core.commands._{name}_command"

imported_module = __import__(name, None, None, ["command"])
except ImportError:
return

return imported_module.command

def list_commands(self, context):
command_names = []

commands_pathname = cellprofiler_core.commands.__file__

commands_directory = pathlib.Path(commands_pathname).parent

for filename in os.listdir(commands_directory):
if filename.endswith("_command.py") and filename.startswith("_"):
command_name = filename[1:-11]

command_names += [command_name]

command_names.sort()

return command_names


class Environment:
def __init__(self):
pass


pass_environment = click.make_pass_decorator(Environment, ensure=True)


@click.command(cls=Command, context_settings=CONTEXT_SETTINGS)
@pass_environment
def main(context):
pass


if __name__ == "__main__":
main({})
2 changes: 1 addition & 1 deletion cellprofiler_core/analysis/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
# should have jobserver() call load_measurements_from_buffer() rather
# than interface() doing so. Currently, passing measurements in this
# way seems like it might be buggy:
# http://code.google.com/p/h5py/issues/detail?id=244
# https://github.com/h5py/h5py/issues/244
self.received_measurements_queue = queue.Queue(maxsize=10)

self.shared_dicts = None
Expand Down
Empty file.
40 changes: 0 additions & 40 deletions cellprofiler_core/commands/_pipeline_command.py

This file was deleted.

15 changes: 0 additions & 15 deletions cellprofiler_core/commands/_worker_command.py

This file was deleted.

2 changes: 1 addition & 1 deletion cellprofiler_core/module/_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def set_notes(self, notes):
"""Give the module new user-entered notes
"""
sanitization_dict = {"“":"\"","”":"\""}
sanitization_dict = {"“":"\"","”":"\"","—":"-","’":"'","`":"'"}
self.__notes = [''.join(sanitization_dict.get(x,x) for x in note) for note in notes]

notes = property(get_notes, set_notes)
Expand Down
1 change: 1 addition & 0 deletions cellprofiler_core/utilities/zmq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
LockStatusRequest,
Request,
)
from ._event import PollTimeoutException

NOTIFY_SOCKET_ADDR = "inproc://BoundaryNotifications"
SD_KEY_DICT = "__keydict__"
Expand Down
4 changes: 4 additions & 0 deletions cellprofiler_core/utilities/zmq/_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class PollTimeoutException(Exception):
"""Exception issued by a timeout from polling"""

pass
51 changes: 36 additions & 15 deletions cellprofiler_core/worker/_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@
from ..constants.worker import the_zmq_context
from ..measurement import Measurements
from ..utilities.measurement import load_measurements_from_buffer
from ..utilities.zmq import PollTimeoutException
from ..pipeline import CancelledException
from ..preferences import get_awt_headless
from ..preferences import set_preferences_from_dict
from ..utilities.zmq.communicable.reply.upstream_exit import UpstreamExit
from ..workspace import Workspace

LOGGER = logging.getLogger(__name__)


class Worker:
"""An analysis worker processing work at a given address
Expand Down Expand Up @@ -124,6 +127,7 @@ def run(self):
)
t0 = time.time()
self.work_socket = the_zmq_context.socket(zmq.REQ)
self.work_socket.set_hwm(2000)
self.work_socket.connect(self.work_request_address)
# fetch a job
the_request = Work(self.current_analysis_id)
Expand Down Expand Up @@ -304,26 +308,40 @@ def do_job(self, job):
return

if worker_runs_post_group:
last_workspace.interaction_handler = self.interaction_handler
last_workspace.cancel_handler = self.cancel_handler
last_workspace.post_group_display_handler = (
self.post_group_display_handler
)
# There might be an exception in this call, but it will be
# handled elsewhere, and there's nothing we can do for it
# here.
current_pipeline.post_group(
last_workspace, current_measurements.get_grouping_keys()
)
del last_workspace
if not last_workspace is None:
last_workspace.interaction_handler = self.interaction_handler
last_workspace.cancel_handler = self.cancel_handler
last_workspace.post_group_display_handler = (
self.post_group_display_handler
)
# There might be an exception in this call, but it will be
# handled elsewhere, and there's nothing we can do for it
# here.
current_pipeline.post_group(
last_workspace, current_measurements.get_grouping_keys()
)
del last_workspace
else:
LOGGER.error("No workspace from last image set, cannot run post group")

# send measurements back to server
req = MeasurementsReport(
self.current_analysis_id,
buf=current_measurements.file_contents(),
image_set_numbers=image_set_numbers,
)
rep = self.send(req)

while True:
try:
rep = self.send(req, timeout=4000)
break
except PollTimeoutException:
LOGGER.info(f"Worker sending MeasurementsReport halted, retrying for job {str(job.image_set_numbers)}")
self.work_socket.close(linger=0)
self.work_socket = the_zmq_context.socket(zmq.REQ)
self.work_socket.set_hwm(2000)
self.work_socket.connect(self.work_request_address)
continue

except CancelledException:
# Main thread received shutdown signal
Expand Down Expand Up @@ -389,7 +407,7 @@ def omero_login_handler(self):
rep = self.send(req)
use_omero_credentials(rep.credentials)

def send(self, req, work_socket=None):
def send(self, req, work_socket=None, timeout=None):
"""Send a request and receive a reply

req - request to send
Expand All @@ -410,7 +428,10 @@ def send(self, req, work_socket=None):
req.send_only(work_socket)
response = None
while response is None:
for socket, state in poller.poll():
poll_res = poller.poll(timeout)
if len(poll_res) == 0:
raise PollTimeoutException
for socket, state in poll_res:
if socket == self.notify_socket and state == zmq.POLLIN:
notify_msg = self.notify_socket.recv()
if notify_msg == NOTIFY_STOP:
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

project = "CellProfiler-core"

release = "4.2.6"
release = "4.2.8"

templates_path = ["_templates"]
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ filterwarnings =
ignore::DeprecationWarning
ignore::FutureWarning
minversion =
4.2.6
4.2.8
testpaths =
./tests/
16 changes: 7 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,28 @@
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
extras_require={
"dev": [
"black==19.10b0",
"click>=7.1.2",
"pre-commit==2.2.0",
"sphinx==3.1.2",
"sphinx>=3.1.2",
"twine==3.1.1",
],
"test": ["pytest==5.4.1"],
"test": ["pytest~=7.4.1"],
"wx": ["wxPython==4.1.0"],
},
install_requires=[
"boto3==1.14.23",
"centrosome==1.2.2",
"centrosome==1.2.3",
"docutils==0.15.2",
"fsspec==2022.2.0",
"h5py==3.6.0", # Consider 3.2.1 if problems happen
"matplotlib==3.1.3",
"numpy==1.23.1",
"prokaryote==2.4.4",
"psutil==5.7.0",
"python-bioformats==4.0.7",
"python-javabridge==4.0.3",
"python-bioformats==4.1.0",
"python-javabridge==4.0.4",
"pyzmq==22.3.0",
"Pillow==8.3.2",
"scikit-image==0.18.3",
Expand All @@ -44,6 +42,6 @@
packages=setuptools.find_packages(exclude=["tests"]),
python_requires=">=3.8, <4",
url="https://github.com/CellProfiler/core",
version="4.2.6",
version="4.2.8",
zip_safe=False,
)