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

Create the CIs for Icy and deepImageJ using JDLL #82

Draft
wants to merge 152 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
38df8e7
start adding workflow for icy
carlosuc3m Jun 13, 2024
fb0477c
update jdll version
carlosuc3m Jun 13, 2024
298bfc1
listen to folder to trigger workflow
carlosuc3m Jun 13, 2024
0ce6e42
add class to download engines, different for Icy and DIJ
carlosuc3m Jun 13, 2024
5aeb5c4
download engines from action
carlosuc3m Jun 13, 2024
4acdc03
install first
carlosuc3m Jun 13, 2024
4dbed35
correct error in syntax
carlosuc3m Jun 13, 2024
be38fa1
remove problematic code
carlosuc3m Jun 13, 2024
f8145d1
check the directory
carlosuc3m Jun 13, 2024
cfccb6b
correct directory
carlosuc3m Jun 13, 2024
0a4b3e4
remove unnecessary classes for logging
carlosuc3m Jun 13, 2024
6ed2651
do not trigger build
carlosuc3m Jun 13, 2024
af205f6
avoid triggering it while developping
carlosuc3m Jun 13, 2024
fbc24c1
correct name of folder
carlosuc3m Jun 13, 2024
10268b9
correct dir name
carlosuc3m Jun 13, 2024
a9b76be
add useful prints
carlosuc3m Jun 13, 2024
0bf128a
ensure the change happens on every subfodler
carlosuc3m Jun 13, 2024
305374e
add job that runs models
carlosuc3m Jun 13, 2024
4bb3619
needs previous run
carlosuc3m Jun 13, 2024
41d53e3
correct where to put needs
carlosuc3m Jun 13, 2024
132dfa7
just a single job
carlosuc3m Jun 13, 2024
239b1d6
update jdll version
carlosuc3m Jun 13, 2024
d4aad65
do two directories back
carlosuc3m Jun 13, 2024
b9a57fb
check the artifacts that are produced
carlosuc3m Jun 19, 2024
ed329cc
add part to upload changesusing python (python script still missing)
carlosuc3m Jun 25, 2024
03c8b8e
start creating the python code to upload dij and icy tests
carlosuc3m Jun 26, 2024
f2877b3
keep working towards convergence of CI
carlosuc3m Jul 2, 2024
6a705db
separate the tests for icy and deepimagej
carlosuc3m Jul 2, 2024
82fd7b6
install every engine for Icy
carlosuc3m Jul 2, 2024
41c2c79
do not fail when an engine is not properly installed
carlosuc3m Jul 3, 2024
313145e
remove bioimage.io python deps
carlosuc3m Jul 3, 2024
3d332bf
correct code to make the results depend on software and version
carlosuc3m Jul 3, 2024
39a9fd3
renew the way tests are created
carlosuc3m Jul 4, 2024
9c8380d
keep improving the java part of testing
carlosuc3m Jul 4, 2024
346fbe8
stabilize java part
carlosuc3m Jul 4, 2024
8da01d5
create script to retrieve the dij and icy versions
carlosuc3m Jul 4, 2024
027e1d7
keep iterating
carlosuc3m Jul 4, 2024
2964cb6
add code to understand JDLL and java software versions tested
carlosuc3m Jul 5, 2024
950b1c9
print version so github action can use it
carlosuc3m Jul 5, 2024
632e15e
update actions to use new script retrieving version dict
carlosuc3m Jul 5, 2024
2733da6
add installation of deps
carlosuc3m Jul 5, 2024
e4a03d6
corect small details
carlosuc3m Jul 5, 2024
e1e904b
add listener to another file
carlosuc3m Jul 5, 2024
7af4a00
try to change something
carlosuc3m Jul 5, 2024
8f4139e
debug
carlosuc3m Jul 5, 2024
72f985a
debug
carlosuc3m Jul 5, 2024
a443fa1
debug
carlosuc3m Jul 5, 2024
4ce9640
try new changes
carlosuc3m Jul 5, 2024
d7fd1c1
try more changes
carlosuc3m Jul 5, 2024
df64bd6
more changes
carlosuc3m Jul 5, 2024
1344fa5
use a list of entries instead of a dict
carlosuc3m Jul 5, 2024
3d29be5
redo map
carlosuc3m Jul 5, 2024
1b016c7
stabilize version management
carlosuc3m Jul 5, 2024
f03fff9
che k the dir
carlosuc3m Jul 5, 2024
2904eb6
move to the correct dir to execute java code
carlosuc3m Jul 5, 2024
c832bab
orint jarfile
carlosuc3m Jul 5, 2024
de04824
correct paths again
carlosuc3m Jul 5, 2024
1fbc127
check if jarfile persits
carlosuc3m Jul 5, 2024
8c4b5ca
preserve jarfile name
carlosuc3m Jul 5, 2024
e333e6a
add forgotten id
carlosuc3m Jul 5, 2024
707eb22
need to jobs
carlosuc3m Jul 5, 2024
7a8892c
install deps
carlosuc3m Jul 5, 2024
8a17d95
correct version number
carlosuc3m Jul 5, 2024
4cff69f
update python code
carlosuc3m Jul 5, 2024
f397ab5
run as modules to avoid import errors
carlosuc3m Jul 9, 2024
241d6dd
check if this change eas the error
carlosuc3m Jul 9, 2024
e49dbce
improve robustness
carlosuc3m Jul 9, 2024
6be07cf
create the collection backoffice plus dependencies
carlosuc3m Jul 10, 2024
b521fe1
improving naming of the paths of test summaries
carlosuc3m Jul 10, 2024
fc4cb0d
correct installation of backoffice
carlosuc3m Jul 10, 2024
89951e4
Merge branch 'bioimage-io:main' into main
carlosuc3m Jul 10, 2024
0ff8c70
update gitignore again and remove silly print
carlosuc3m Jul 10, 2024
d700c34
provide the arguments correctly
carlosuc3m Jul 10, 2024
a64cc1d
correct error that was failing passed tests
carlosuc3m Jul 10, 2024
b90e825
fail the workflow on purpose
carlosuc3m Jul 10, 2024
8f4ea3e
fail the other workflow on purpose
carlosuc3m Jul 10, 2024
7f2c972
test fail
carlosuc3m Jul 10, 2024
7a04b2e
restore build yaml
carlosuc3m Jul 10, 2024
b5a4014
restore default
carlosuc3m Jul 10, 2024
7195192
remove intentional fail
carlosuc3m Jul 10, 2024
06da2c4
remove default path forgotten
carlosuc3m Jul 10, 2024
1ee4bcb
make the details more understandable
carlosuc3m Jul 11, 2024
0fe821e
remove intentional fail
carlosuc3m Jul 11, 2024
efd911c
also catch errors
carlosuc3m Jul 11, 2024
8924cae
at the moment only use one version per engine
carlosuc3m Jul 11, 2024
854f356
correct a couple of details of the action
carlosuc3m Jul 11, 2024
982ab00
Merge branch 'bioimage-io:main' into main
carlosuc3m Jan 27, 2025
fab556e
make CI specific to DIJ and Python using headless mode
carlosuc3m Jan 27, 2025
9643a8c
big update of the CI to be "truer"
carlosuc3m Jan 28, 2025
aac17c6
correct text format and add download
carlosuc3m Jan 28, 2025
8d77f13
correct yaml typo
carlosuc3m Jan 28, 2025
c8f84d7
another typo
carlosuc3m Jan 28, 2025
4b05ef0
use test file
carlosuc3m Jan 28, 2025
900bcd9
more typos
carlosuc3m Jan 28, 2025
3946639
typo on file name
carlosuc3m Jan 28, 2025
4277519
install dij correctly
carlosuc3m Jan 28, 2025
ca11ecf
remove not needed import
carlosuc3m Jan 28, 2025
411d1bc
install backoffice
carlosuc3m Jan 28, 2025
48479d9
reorder args that were incorrectly ordererd
carlosuc3m Jan 28, 2025
24f93aa
correct path to fiji app
carlosuc3m Jan 28, 2025
e26095e
add some prints for debugging
carlosuc3m Jan 28, 2025
df95c98
more debugging prints
carlosuc3m Jan 28, 2025
319f2a4
keep printing
carlosuc3m Jan 28, 2025
7b49eb9
keep printint
carlosuc3m Jan 28, 2025
1fbe8dd
remove space that was causing issues
carlosuc3m Jan 28, 2025
58d0e59
remove all spaces
carlosuc3m Jan 28, 2025
0dacf6a
save reports for debugging
carlosuc3m Jan 28, 2025
c9ddb4f
add prints to debug
carlosuc3m Jan 28, 2025
9ccd83b
retrieve the whole stack trace
carlosuc3m Jan 28, 2025
ca82f32
print weird error
carlosuc3m Jan 28, 2025
49cff31
change arg to fiji_executable and correct subprocess definintions
carlosuc3m Jan 28, 2025
3f30eb4
correct error
carlosuc3m Jan 28, 2025
f3d7e47
listen to every change in jython scripts
carlosuc3m Jan 28, 2025
1150060
check what is this
carlosuc3m Jan 28, 2025
ec9cd08
debug mode
carlosuc3m Jan 28, 2025
093ef0f
try if this prints something
carlosuc3m Jan 28, 2025
09544b8
cehck anything is printed
carlosuc3m Jan 28, 2025
0f6a8d8
capture the output of the subprocess
carlosuc3m Jan 28, 2025
67abf4f
mm
carlosuc3m Jan 28, 2025
b123b80
try more prints
carlosuc3m Jan 28, 2025
52f62a3
more prints
carlosuc3m Jan 28, 2025
e8cee98
more checks
carlosuc3m Jan 28, 2025
3772e10
print subprocess output
carlosuc3m Jan 28, 2025
859982e
ll
carlosuc3m Jan 28, 2025
3f9caee
correct error
carlosuc3m Jan 28, 2025
fe7a704
use full path
carlosuc3m Jan 28, 2025
eb5ee4f
use correct method
carlosuc3m Jan 28, 2025
ea504a1
print all env vars
carlosuc3m Jan 28, 2025
f454882
add env vars to the correct place
carlosuc3m Jan 28, 2025
7f0b9b2
add missing import
carlosuc3m Jan 28, 2025
180b972
try to understand why some test images where not seen
carlosuc3m Jan 28, 2025
69c934a
use abs path
carlosuc3m Jan 28, 2025
e36b640
catch errors on macro execution
carlosuc3m Jan 28, 2025
eecb81b
typo
carlosuc3m Jan 28, 2025
db55f41
add prints
carlosuc3m Jan 28, 2025
6d1a7f0
check if dij has been run by checking the outputs are there
carlosuc3m Jan 28, 2025
b6a80d6
do not use python 3 things in jython
carlosuc3m Jan 28, 2025
a2de326
remoe unnecessary print
carlosuc3m Jan 28, 2025
5fc727d
sae drafts to be faster
carlosuc3m Jan 28, 2025
688d633
identation error
carlosuc3m Jan 28, 2025
f5410af
print url to understand better
carlosuc3m Jan 28, 2025
a47614c
correct error stupid
carlosuc3m Jan 28, 2025
05929a6
correct macro run checker
carlosuc3m Jan 28, 2025
daeff06
provide more verbose exceptions
carlosuc3m Jan 28, 2025
deb26e9
more verbose
carlosuc3m Jan 28, 2025
a5241b9
remoe enumerate that was causing errors
carlosuc3m Jan 28, 2025
4c2afc8
correct small error
carlosuc3m Jan 28, 2025
178d645
error using non defined variable
carlosuc3m Jan 29, 2025
94dd165
remove processing and halo to be able to produce the expected result
carlosuc3m Jan 29, 2025
3c30726
correct the similarity threshold
carlosuc3m Jan 29, 2025
0aa71e1
update tolerance
carlosuc3m Jan 30, 2025
87fbadc
do not remove pre or post processing
carlosuc3m Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/check_compatibility_deepimagej.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
name: check compatibility deepimagej
concurrency: deepimagej
on:
push:
branches:
- main
paths:
- .github/workflows/check_compatibility_deepimagej.yaml
- scripts/check_compatibility_deepimagej.py
- scripts/deepimagej_jython_scripts/**
workflow_dispatch:
schedule:
- cron: 0 1 * * *
jobs:
run:
strategy:
fail-fast: false
matrix:
include:
- name: ubuntu
os: ubuntu-latest
url_file_name: fiji-linux64.zip
fiji_executable: ImageJ-linux64
runs-on: ${{ matrix.os }}
environment: 'production'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- name: Install backoffice
run: pip install .
- run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions_draft.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions_draft.json
- run: wget https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/all_versions.json #wget https://${{vars.S3_HOST}}/${{vars.S3_BUCKET}}/${{vars.S3_FOLDER}}/all_versions.json
- name: Set up Fiji
shell: bash
run: |
mkdir -p fiji
curl -L -o fiji.zip https://downloads.imagej.net/fiji/latest/${{ matrix.url_file_name }}
unzip fiji.zip -d fiji
- name: Install deepimageJ
run: |
fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --update add-update-site "DeepImageJ" "https://sites.imagej.net/DeepImageJ/"
fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --update update
- name: Install engines
shell: bash
run: fiji/Fiji.app/${{ matrix.fiji_executable }} --headless --console
scripts/deepimagej_jython_scripts/deepimagej_download_engines.py -engines_path
fiji/Fiji.app/engines
#- name: Run deepImageJ tests for drafts
# run: python scripts/check_compatibility_deepimagej.py all_versions_draft.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app
# env:
# JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json
# MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm
#- name: Save reports for debugging purposes for drafts
# uses: actions/upload-artifact@v4
# with:
# name: generated-reports-dij-drafts
# path: generated-reports
- name: Run deepImageJ tests for pusblished versions
run: python scripts/check_compatibility_deepimagej.py all_versions.json generated-reports fiji/Fiji.app/${{ matrix.fiji_executable }} fiji/Fiji.app
env:
JSON_OUTS_FNAME: dij_ouputs_file${{ github.run_id }}.json
MACRO_NAME: dij_macro_ci${{ github.run_id }}.ijm
- name: Save reports for debugging purposes
uses: actions/upload-artifact@v4
with:
name: generated-reports-dij
path: generated-reports
- name: Upload reports
run: python scripts/upload_reports.py generated-reports
env:
S3_HOST: ${{vars.S3_HOST}}
S3_BUCKET: ${{vars.S3_BUCKET}}
S3_FOLDER: ${{vars.S3_FOLDER}}
S3_ACCESS_KEY_ID: ${{secrets.S3_ACCESS_KEY_ID}}
S3_SECRET_ACCESS_KEY: ${{secrets.S3_SECRET_ACCESS_KEY}}
RUN_URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ __pycache__/
*.egg-info/
docs/
*.pyc
TEMP/
bioimageio-gh-pages
scripts/check_compatibility_java_software/test_summaries_null_null
scripts/check_compatibility_java_software/test_summaries_default_default
269 changes: 269 additions & 0 deletions scripts/check_compatibility_deepimagej.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
import argparse
from pathlib import Path
from typing import List, Dict, Any
import os
import re
import json

import urllib.request
import subprocess
from functools import partial
import traceback

from script_utils import CompatibilityReportDict, check_tool_compatibility, download_rdf

try:
from ruyaml import YAML
except ImportError:
from ruamel.yaml import YAML

yaml = YAML(typ="safe")


def find_expected_output(outputs_dir, name):
for ff in os.listdir(outputs_dir):
if ff.endswith("_" + name + ".tif") or ff.endswith("_" + name + ".tiff"):
return True
return False


def check_dij_macro_generated_outputs(model_dir: str):
with open(os.path.join(model_dir, os.getenv("JSON_OUTS_FNAME")), 'r') as f:
expected_outputs = json.load(f)

for output in expected_outputs:
name = output["name"]
dij_output = output["dij"]
if not os.path.exists(dij_output):
return False
if not find_expected_output(dij_output, name):
return False
return True

def remove_processing_and_halo(model_dir: str):
data = None
with open(os.path.join(model_dir, "rdf.yaml")) as stream:
data = yaml.load(stream)
for out in data["outputs"]:
if not isinstance(out["axes"][0], dict):
out.pop('halo', None)
continue
for ax in out["axes"]:
ax.pop('halo', None)
with open(os.path.join(model_dir, "rdf.yaml"), 'w') as outfile:
yaml.dump(data, outfile)



def test_model_deepimagej(rdf_url: str, fiji_executable: str, fiji_path: str):
yaml_file = os.path.abspath("rdf.yaml")
try:
urllib.request.urlretrieve(rdf_url, yaml_file)
except Exception as e:
report = CompatibilityReportDict(
status="failed",
error=f"unable to download the yaml file",
details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(),
links=["deepimagej/deepimagej"],
)
return report
try:
read_yaml = subprocess.run(
[
fiji_executable,
"--headless",
"--console",
"scripts/deepimagej_jython_scripts/deepimagej_read_yaml.py",
"-yaml_fpath",
yaml_file
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
except BaseException as e:
report = CompatibilityReportDict(
status="failed",
error=f"unable to read the yaml file",
details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(),
links=["deepimagej/deepimagej"],
)
return report
model_dir = None
try:
download_result = subprocess.run(
[
fiji_executable,
"--headless",
"--console",
"scripts/deepimagej_jython_scripts/deepimagej_download_model.py",
"-yaml_fpath",
yaml_file,
"-models_dir",
os.path.join(fiji_path, 'models')
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
model_dir = download_result.stdout.strip().splitlines()[-1]
except BaseException as e:
report = CompatibilityReportDict(
status="failed",
error=f"unable to download the model",
details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(),
links=["deepimagej/deepimagej"],
)
return report
remove_processing_and_halo(model_dir)
macro_path = os.path.join(model_dir, str(os.getenv("MACRO_NAME")))
try:
run = subprocess.run(
[
fiji_executable,
"--headless",
"--console",
"-macro",
macro_path,
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
out_str = run.stdout
if not check_dij_macro_generated_outputs(model_dir):
report = CompatibilityReportDict(
status="failed",
error=f"error running the model",
details=out_str,
links=["deepimagej/deepimagej"],
)
return report
except BaseException as e:
report = CompatibilityReportDict(
status="failed",
error=f"error running the model",
details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(),
links=["deepimagej/deepimagej"],
)
return report
try:
check_outputs = subprocess.run(
[
fiji_executable,
"--headless",
"--console",
"scripts/deepimagej_jython_scripts/deepimagej_check_outputs.py",
"-model_dir",
model_dir,
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
except BaseException as e:
report = CompatibilityReportDict(
status="failed",
error=f"error comparing expected outputs and actual outputs",
details=e.stderr + os.linesep + e.stdout if isinstance(e, subprocess.CalledProcessError) else traceback.format_exc(),
links=["deepimagej/deepimagej"],
)
return report
report = CompatibilityReportDict(
status="passed",
error=None,
details=None,
links=["deepimagej/deepimagej"],
)
return report






def check_compatibility_deepimagej_impl(
rdf_url: str,
sha256: str,
fiji_executable: str = "",
fiji_path: str = "fiji",
) -> CompatibilityReportDict:
"""Create a `CompatibilityReport` for a resource description.

Args:
rdf_url: URL to the rdf.yaml file
sha256: SHA-256 value of **rdf_url** content
"""
assert fiji_executable != "", "please provide the fiji executable path"

rdf = download_rdf(rdf_url, sha256)

if rdf["type"] != "model":
report = CompatibilityReportDict(
status="not-applicable",
error=None,
details="only 'model' resources can be used in deepimagej.",
links=["deepimagej/deepimagej"],
)

elif len(rdf["inputs"]) > 1 :#or len(rdf["outputs"]) > 1:
report = CompatibilityReportDict(
status="failed",
#error=f"deepimagej only supports single tensor input/output (found {len(rdf['inputs'])}/{len(rdf['outputs'])})",
error=f"deepimagej only supports single tensor input (found {len(rdf['inputs'])})",
details=None,
links=["deepimagej/deepimagej"],
)
else:
report = test_model_deepimagej(rdf_url, fiji_executable, fiji_path)

return report


def check_compatibility_deepimagej(
deepimagej_version: str, all_version_path: Path, output_folder: Path, fiji_executable: str, fiji_path: str,
):
partial_impl = partial(
check_compatibility_deepimagej_impl,
fiji_executable=fiji_executable,
fiji_path=fiji_path
)
check_tool_compatibility(
"deepimagej",
deepimagej_version,
all_version_path=all_version_path,
output_folder=output_folder,
check_tool_compatibility_impl=partial_impl,
applicable_types={"model"},
)

def get_dij_version(fiji_path):
plugins_path = os.path.join(fiji_path, "plugins")
pattern = re.compile(r"^deepimagej-(\d+\.\d+\.\d+(?:-snapshot)?)\.jar$")

matching_files = [
file.lower()
for file in os.listdir(plugins_path)
if pattern.match(file.lower())
]
assert len(matching_files) > 0, "No deepImageJ plugin found, review your installation"
version = pattern.search(matching_files[0]).group(1)
return version


if __name__ == "__main__":
parser = argparse.ArgumentParser()
_ = parser.add_argument("all_versions", type=Path)
_ = parser.add_argument("output_folder", type=Path)
_ = parser.add_argument("fiji_executable", type=str)
_ = parser.add_argument("fiji_path", type=str)

args = parser.parse_args()
fiji_path = os.path.abspath(args.fiji_path)
check_compatibility_deepimagej(
get_dij_version(fiji_path), args.all_versions, args.output_folder, fiji_executable=args.fiji_executable, fiji_path=fiji_path
)
Loading