From 78882ab4c5747049d4b10ef3b9b9001b22a0def0 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 20 May 2019 10:06:15 +0100 Subject: [PATCH 1/5] Removed debug print --- openflexure_microscope/api/app.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openflexure_microscope/api/app.py b/openflexure_microscope/api/app.py index d4d64cf7..665faf80 100644 --- a/openflexure_microscope/api/app.py +++ b/openflexure_microscope/api/app.py @@ -29,7 +29,6 @@ import sys, os is_gunicorn = "gunicorn" in os.environ.get("SERVER_SOFTWARE", "") DEFAULT_LOGFILE = os.path.join(USER_CONFIG_DIR, 'openflexure_microscope.log') -print(DEFAULT_LOGFILE) if (__name__ == "__main__") or (not is_gunicorn): # If imported, but not by gunicorn From 1fe8ea18d879321ab08ae02391c96c5b01fd3d3d Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 20 May 2019 10:06:42 +0100 Subject: [PATCH 2/5] Default capture resolution to MAX_RESOLUTION --- openflexure_microscope/camera/pi.py | 9 +++++++-- openflexure_microscope/microscoperc.default.yaml | 5 ----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openflexure_microscope/camera/pi.py b/openflexure_microscope/camera/pi.py index eed43cce..68e8a837 100644 --- a/openflexure_microscope/camera/pi.py +++ b/openflexure_microscope/camera/pi.py @@ -41,8 +41,8 @@ from .set_picamera_gain import set_analog_gain, set_digital_gain # Handle config and picamera settings CONFIG_KEYS = { - 'video_resolution': (832, 624), - 'image_resolution': (2592, 1944), + 'video_resolution': (1640, 1232), + 'image_resolution': (2592, 1944), # Default for PiCamera v1. Overridden in __init__ 'numpy_resolution': (1312, 976), 'jpeg_quality': 75, 'picamera_settings': { @@ -86,6 +86,11 @@ class StreamingCamera(BaseCamera): # Populate config and settings with all available keys self.config.update(CONFIG_KEYS) + # Update config based on PiCamera parameters + self.config.update({ + 'image_resolution': tuple(self.camera.MAX_RESOLUTION) + }) + # Load config dictionary if passed if config: self.apply_config(config) diff --git a/openflexure_microscope/microscoperc.default.yaml b/openflexure_microscope/microscoperc.default.yaml index f1769970..0692a884 100644 --- a/openflexure_microscope/microscoperc.default.yaml +++ b/openflexure_microscope/microscoperc.default.yaml @@ -1,8 +1,3 @@ -# Resolutions for streaming and capture -video_resolution: [832, 624] -image_resolution: [2592, 1944] -numpy_resolution: [1312, 976] - # Field of view, in stage steps fov: [4100, 3146] From 9fc4dfc62840433e51b224411902106a9aeb2501 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 20 May 2019 10:09:01 +0100 Subject: [PATCH 3/5] Moved microscoperc.yaml to microscope_settings.yaml --- docs/source/config.rst | 4 ++-- docs/source/plugins/introduction.rst | 4 ++-- openflexure_microscope/config.py | 4 ++-- openflexure_microscope/microscope.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/config.rst b/docs/source/config.rst index 72a6afc7..6af120d1 100644 --- a/docs/source/config.rst +++ b/docs/source/config.rst @@ -11,13 +11,13 @@ Microscope RC file ------------------ Microscope configuration is made persistent via a microscope runtime-config (RC) file. By default, this -file exists at ``~/.openflexure/microscoperc.yaml``, and contains basic parameters to set up the microscope. +file exists at ``~/.openflexure/microscope_settings.yaml``, and contains basic parameters to set up the microscope. Additionally, by default, configurations for specific pieces of hardware (i.e. the Pi camera) are located in separate "auxillary" config files, and are linked together by adding the config file's path to your main microscope RC file. This is set up by default, as shown below: -Default microscoperc.yaml +Default microscope_settings.yaml +++++++++++++++++++++++++ .. code-block:: yaml diff --git a/docs/source/plugins/introduction.rst b/docs/source/plugins/introduction.rst index e2b50a03..36b8e54d 100644 --- a/docs/source/plugins/introduction.rst +++ b/docs/source/plugins/introduction.rst @@ -25,11 +25,11 @@ Generally, for adding anything other than very simple functionality, plugins sho The main restriction is that the plugin package must be importable using an absolute import from within the Python environment being used to load your microscope. -Loading plugins with microscoperc.yaml +Loading plugins with microscope_settings.yaml -------------------------------------- Both types of plugin are loaded by specifying the plugin class in your :ref:`MicroscopeRC`. In the case of a single-file plugin, specify the path to the plugin file, followed by the name of your :py:class:`openflexure_microscope.plugins.MicroscopePlugin` child class, separated by a colon. For packaged plugins, specify the absolute module name in place of the path. -For example, the plugins section of your microscoperc.yaml file may look like: +For example, the plugins section of your microscope_settings.yaml file may look like: .. code-block:: yaml diff --git a/openflexure_microscope/config.py b/openflexure_microscope/config.py index de25b665..d06a3686 100644 --- a/openflexure_microscope/config.py +++ b/openflexure_microscope/config.py @@ -10,10 +10,10 @@ from collections import abc # HANDLE THE DEFAULT CONFIGURATION FILE HERE = os.path.abspath(os.path.dirname(__file__)) -DEFAULT_CONFIG_PATH = os.path.join(HERE, 'microscoperc.default.yaml') +DEFAULT_CONFIG_PATH = os.path.join(HERE, 'microscope_settings.default.yaml') USER_CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".openflexure") #: str: Default path of the user-config directory, containing runtime-config and calibration files. Obtained from ``os.path.join(os.path.expanduser("~"), ".openflexure")``. -USER_CONFIG_FILE = os.path.join(USER_CONFIG_DIR, "microscoperc.yaml") #: str: Default path of the user microscoperc.yaml runtime-config file. Obtained from ``os.path.join(USER_CONFIG_DIR, "microscoperc.yaml")`` +USER_CONFIG_FILE = os.path.join(USER_CONFIG_DIR, "microscope_settings.yaml") #: str: Default path of the user microscope_settings.yaml runtime-config file. Obtained from ``os.path.join(USER_CONFIG_DIR, "microscope_settings.yaml")`` with open(DEFAULT_CONFIG_PATH, 'r') as default_rc: DEFAULT_CONFIG = default_rc.read() diff --git a/openflexure_microscope/microscope.py b/openflexure_microscope/microscope.py index d50131cc..5b684b7c 100644 --- a/openflexure_microscope/microscope.py +++ b/openflexure_microscope/microscope.py @@ -143,7 +143,7 @@ class Microscope(object): if 'plugins' in self.rc.config: self.attach_plugin_maps(self.rc.config['plugins']) else: - logging.warning("No plugins specified in microscoperc.yaml. Skipping.") + logging.warning("No plugins specified in microscope_settings.yaml. Skipping.") def reload_plugins(self): """ From b0e724a706cd765c6bf492556385b278da8f7516 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 20 May 2019 10:14:55 +0100 Subject: [PATCH 4/5] Fixed naming of default config placeholder --- ...microscoperc.default.yaml => microscope_settings.default.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename openflexure_microscope/{microscoperc.default.yaml => microscope_settings.default.yaml} (100%) diff --git a/openflexure_microscope/microscoperc.default.yaml b/openflexure_microscope/microscope_settings.default.yaml similarity index 100% rename from openflexure_microscope/microscoperc.default.yaml rename to openflexure_microscope/microscope_settings.default.yaml From 8c3cd48f4d6df4ee0bf1f228e4dabe7b3c401768 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 20 May 2019 10:24:50 +0100 Subject: [PATCH 5/5] Automatically move old config file to new config file --- openflexure_microscope/config.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openflexure_microscope/config.py b/openflexure_microscope/config.py index d06a3686..928882c1 100644 --- a/openflexure_microscope/config.py +++ b/openflexure_microscope/config.py @@ -15,11 +15,19 @@ DEFAULT_CONFIG_PATH = os.path.join(HERE, 'microscope_settings.default.yaml') USER_CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".openflexure") #: str: Default path of the user-config directory, containing runtime-config and calibration files. Obtained from ``os.path.join(os.path.expanduser("~"), ".openflexure")``. USER_CONFIG_FILE = os.path.join(USER_CONFIG_DIR, "microscope_settings.yaml") #: str: Default path of the user microscope_settings.yaml runtime-config file. Obtained from ``os.path.join(USER_CONFIG_DIR, "microscope_settings.yaml")`` +USER_CONFIG_FILE_OLD = os.path.join(USER_CONFIG_DIR, "microscoperc.yaml") + +# Load the default config with open(DEFAULT_CONFIG_PATH, 'r') as default_rc: DEFAULT_CONFIG = default_rc.read() -# HANDLE CUSTOM YAML PARSING +# Run a one-time conversion of the old microscoperc.yaml into the new microscope_settings.yaml +# TODO: Should be removed in >1.0.1? +if (not os.path.isfile(USER_CONFIG_FILE)) and (os.path.isfile(USER_CONFIG_FILE_OLD)): + os.rename(USER_CONFIG_FILE_OLD, USER_CONFIG_FILE) + +# HANDLE CUSTOM YAML PARSING def construct_yaml_bool(self, node): """ Override PyYAML constructors handling of bools. @@ -162,8 +170,8 @@ def initialise_file(config_path, populate: str = ""): with open(config_path, 'w') as outfile: outfile.write(populate) -# MAIN CONFIG CLASS +# MAIN CONFIG CLASS class OpenflexureConfig: """ An object to handle expansion, conversion, and saving of the microscope configuration.