From 336b504377fcd584d3d659e0327f7c780077a968 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Wed, 2 Apr 2025 13:39:12 +0100 Subject: [PATCH 1/3] Split up ruff format and lint allowing format to fail --- .gitlab-ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 04d32ccb..f873a509 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -59,11 +59,18 @@ meta-build-image: - web # Python formatting and static analysis with ruff -ruff: +ruff-lint: stage: analysis extends: .python script: - ruff check + +# Python formatting and static analysis with ruff +ruff-format: + stage: analysis + extends: .python + allow_failure: true + script: - ruff format --check # Python type checking with Mypy From 928d5ef30052571acd1506f91d3e8891fb56fd72 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Wed, 2 Apr 2025 13:52:42 +0100 Subject: [PATCH 2/3] Try pinning pydantic version as server now fails tests with error --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a7dbba09..1d8276c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ dependencies = [ "numpy ~= 1.20", "scipy ~=1.14", "piexif", + "pydantic ~= 2.10.6", ] [project.optional-dependencies] From 32f2a7ce705942088d5d077f9710f953742d7e8e Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Wed, 2 Apr 2025 14:25:22 +0100 Subject: [PATCH 3/3] Fix spurious line endings, don't allow ruff-format to fail anymore --- .gitlab-ci.yml | 1 - .../things/smart_scan.py | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f873a509..9e75a7c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,7 +69,6 @@ ruff-lint: ruff-format: stage: analysis extends: .python - allow_failure: true script: - ruff format --check diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 946907e1..474eb105 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -615,7 +615,7 @@ class SmartScanThing(Thing): logger.info( f"Generated normalisation image with shape {white_norm.shape}, " - f"max {white_norm.max(axis=(0,1))}, min {white_norm.min(axis=(0,1))}" + f"max {white_norm.max(axis=(0, 1))}, min {white_norm.min(axis=(0, 1))}" ) norm_inputs = { "luminance": lum, @@ -660,7 +660,7 @@ class SmartScanThing(Thing): ) save_time = time.time() logger.info( - f"Acquired {name} in {acquisition_time-capture_start:.1f}s then {save_time-acquisition_time:.1f}s saving to disk" + f"Acquired {name} in {acquisition_time - capture_start:.1f}s then {save_time - acquisition_time:.1f}s saving to disk" ) except Exception as e: logger.error( @@ -691,7 +691,7 @@ class SmartScanThing(Thing): # if more than 92% of the image is background, treat it as background and continue if not image_is_sample: logger.info( - f"Skipping {stage.position} as it is {round(background_detect.background_fraction(),0)}% background." + f"Skipping {stage.position} as it is {round(background_detect.background_fraction(), 0)}% background." ) else: # if not, it's sample. run an autofocus and use the updated height @@ -826,7 +826,7 @@ class SmartScanThing(Thing): except Exception as e: logger.error( f"The scan stopped because of an error: {e}", - "We will attempt to stitch and archive the images acquired " "so far.", + "We will attempt to stitch and archive the images acquired so far.", exc_info=e, ) raise e @@ -1084,7 +1084,7 @@ class SmartScanThing(Thing): "--stitching_mode", "only_correlate", "--minimum_overlap", - f"{round(overlap*0.9, 2)}", + f"{round(overlap * 0.9, 2)}", images_folder, ] ) @@ -1164,7 +1164,7 @@ class SmartScanThing(Thing): "all", f"{tiff_arg}", "--minimum_overlap", - f"{round(overlap*0.9,2)}", + f"{round(overlap * 0.9, 2)}", images_folder, ], ) @@ -1193,7 +1193,7 @@ class SmartScanThing(Thing): ) # logger.info("Creating zip archive of images (may take some time)...") - zip_fname = f'{os.path.join(scan_folder, "images")}.zip' + zip_fname = f"{os.path.join(scan_folder, 'images')}.zip" # Create an empty zip file - we don't want to autofill it with files, # as some of them should only be added at the end (as we can't overwrite)