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

Cellprofiler Web API tool: images API #3313

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e5ab918
Cellprofiler Web API tool - create images API
ekazachkova Jun 28, 2023
18beeba
Cellprofiler Web API tool - create images API (input data fix)
ekazachkova Jun 28, 2023
9801a4d
Cellprofiler Web API tool - create images API (z-plane projection)
ekazachkova Jun 30, 2023
5453201
Cellprofiler Web API tool - create images API (z-plane projection)
ekazachkova Jun 30, 2023
0550f18
Cellprofiler Web API tool - create images API (approaches merged)
ekazachkova Jun 30, 2023
98d2f4a
Cellprofiler Web API tool - create images API (remove unused method)
ekazachkova Jun 30, 2023
398cf0d
Cellprofiler Web API tool - create images API (async images generation)
ekazachkova Jul 4, 2023
03e858c
Cellprofiler Web API tool - create images API (async images generation)
ekazachkova Jul 4, 2023
1dd9d79
Cellprofiler Web API tool - create images API (ome tiff support for o…
ekazachkova Jul 6, 2023
40fe012
Cellprofiler Web API tool - create images API (ome tiff support for i…
ekazachkova Jul 7, 2023
cbf07f0
Cellprofiler Web API tool - create images API (ome tiff support for i…
ekazachkova Jul 10, 2023
0cb7beb
Cellprofiler Web API tool - create images API (ome tiff support for D…
ekazachkova Jul 10, 2023
ef4b334
Cellprofiler Web API tool - create images API (ome tiff support)
ekazachkova Jul 11, 2023
bce019a
Cellprofiler Web API tool - create images API (ome tiff fixes)
ekazachkova Jul 11, 2023
9be6f37
Cellprofiler Web API tool - create images API (cleanups)
ekazachkova Jul 11, 2023
1eb4555
Cellprofiler Web API tool - create images API (fix for script)
ekazachkova Jul 12, 2023
f8ae349
Cellprofiler Web API tool - create images API (fixes)
ekazachkova Jul 12, 2023
4fd24b1
Cellprofiler Web API tool - create images API (well shall not be mand…
ekazachkova Jul 13, 2023
bce7c22
Cellprofiler Web API tool - create images API (remove tmp data)
ekazachkova Jul 17, 2023
bb9bf96
Cellprofiler Web API tool - create images API (update biofirmats2raw …
ekazachkova Jul 25, 2023
f12f330
Cellprofiler Web API tool - create images API (remove redundant scrip…
ekazachkova Jul 25, 2023
b10a283
centrosome fix
Jul 26, 2023
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
57 changes: 53 additions & 4 deletions deploy/docker/cp-tools/research/cellprofiler-web-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2022 EPAM Systems, Inc. (https://www.epam.com/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM library/centos:7.7.1908

RUN yum install -y wget bzip2 \
Expand Down Expand Up @@ -52,10 +66,45 @@ ARG NUMPY_VERSION=1.23.1
ARG CYTHON_VERSION=0.29.30

COPY requirements.txt $CELLPROFILER_API_HOME/
RUN python3.8 -m pip install wheel numpy==$NUMPY_VERSION \
Cython==$CYTHON_VERSION && \
python3.8 -m pip install cellprofiler==$CELL_PROFILER_VERSION && \
python3.8 -m pip install -r $CELLPROFILER_API_HOME/requirements.txt
RUN python3.8 -m pip install wheel && \
wget "https://files.pythonhosted.org/packages/61/c7/e1a31b6a092a5b91952fe96801b2d3167fcb3bad8386c023dd83de4c4ab8/centrosome-1.2.0.tar.gz" -O /tmp/centrosome.tar.gz && \
cd /tmp && \
tar -zxf centrosome.tar.gz && \
cd centrosome* && \
sed -i "s/setup_requires=\[\"cython\", \"numpy\", \"pytest\",\],/setup_requires=\[\"cython==$CYTHON_VERSION\", \"numpy==$NUMPY_VERSION\", \"pytest\",\],/g" setup.py && \
python3.8 -m pip install . && \
rm -rf /tmp/centrosome*
RUN python3.8 -m pip install -r $CELLPROFILER_API_HOME/requirements.txt

RUN yum install -y \
blosc \
ImageMagick

ARG GENERATE_OFFSETS_VERSION=0.1.7
RUN python3.8 -m pip install generate-tiff-offsets==$GENERATE_OFFSETS_VERSION

ARG BIOFORMATS_TO_RAW_VERSION=0.7.0
ARG BIOFORMATS_TO_RAW_DISTR_URL="https://cloud-pipeline-oss-builds.s3.amazonaws.com/tools/bioformats2raw/bioformats2raw-$BIOFORMATS_TO_RAW_VERSION.zip"

ARG RAW_TO_OMETIFF_VERSION=0.4.1
ARG RAW_TO_OMETIFF_DISTR_URL="https://cloud-pipeline-oss-builds.s3.amazonaws.com/tools/raw2ometiff/raw2ometiff-$RAW_TO_OMETIFF_VERSION.zip"

ENV HCS_TOOLS_HOME="$CELLPROFILER_API_HOME/hcs-tools"

RUN mkdir -p "$HCS_TOOLS_HOME" && \
wget -q "$BIOFORMATS_TO_RAW_DISTR_URL" -O "$HCS_TOOLS_HOME/bioformats2raw.zip" && \
unzip "$HCS_TOOLS_HOME/bioformats2raw.zip" -d "$HCS_TOOLS_HOME/bioformats2raw" && \
rm -f "$HCS_TOOLS_HOME/bioformats2raw.zip" && \
chmod +x "$HCS_TOOLS_HOME/bioformats2raw/bioformats2raw-$BIOFORMATS_TO_RAW_VERSION/bin/bioformats2raw" && \
wget -q "$RAW_TO_OMETIFF_DISTR_URL" -O "$HCS_TOOLS_HOME/raw2ometiff.zip" && \
unzip "$HCS_TOOLS_HOME/raw2ometiff.zip" -d "$HCS_TOOLS_HOME/raw2ometiff" && \
rm -f "$HCS_TOOLS_HOME/raw2ometiff.zip" && \
chmod +x "$HCS_TOOLS_HOME/raw2ometiff/raw2ometiff-$RAW_TO_OMETIFF_VERSION/bin/raw2ometiff"

ENV PATH="$HCS_TOOLS_HOME/bioformats2raw/bioformats2raw-$BIOFORMATS_TO_RAW_VERSION/bin:$HCS_TOOLS_HOME/raw2ometiff/raw2ometiff-$RAW_TO_OMETIFF_VERSION/bin:$PATH"

COPY convert_to_ome_tiff.sh "$HCS_TOOLS_HOME/convert_to_ome_tiff.sh"
RUN chmod +x $HCS_TOOLS_HOME/convert_to_ome_tiff.sh

COPY app/ $CELLPROFILER_API_HOME/
COPY start.sh $CELLPROFILER_API_HOME/
Expand Down
61 changes: 48 additions & 13 deletions deploy/docker/cp-tools/research/cellprofiler-web-api/app/hcs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 EPAM Systems, Inc. (https://www.epam.com/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import sys
import os
Expand All @@ -7,8 +21,7 @@
from flask import Flask, jsonify, request

from src.hcs_manager import HCSManager
from src.hcs_clip import create_clip

from src.hcs_clip import create_clip, HCSImagesManager

if getattr(sys, 'frozen', False):
static_folder = os.path.join(sys._MEIPASS, 'hcs', 'static')
Expand Down Expand Up @@ -50,7 +63,7 @@ def create_pipeline():
pipeline_id = manager.create_pipeline(measurement_uuid)
return jsonify(success({"pipelineId": pipeline_id}))
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -64,7 +77,7 @@ def get_pipeline():
pipeline_id = manager.get_pipeline(pipeline_id)
return jsonify(success({"pipelineId": pipeline_id}))
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -79,7 +92,7 @@ def add_files():
manager.add_files(pipeline_id, files_data)
return jsonify({"status": "OK"})
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -94,7 +107,7 @@ def create_module():
manager.create_module(pipeline_id, module_data)
return jsonify({"status": "OK"})
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -114,7 +127,7 @@ def move_module():
manager.move_module(pipeline_id, module_id, direction)
return jsonify({"status": "OK"})
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -132,7 +145,7 @@ def update_module():
manager.update_module(pipeline_id, module_id, module_data)
return jsonify({"status": "OK"})
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -149,7 +162,7 @@ def delete_module():
manager.delete_module(pipeline_id, module_id)
return jsonify({"status": "OK"})
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -163,7 +176,7 @@ def run_pipeline():
manager.launch_pipeline(pipeline_id)
return jsonify({"status": "OK"})
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -180,7 +193,7 @@ def run_module():
manager.run_module(pipeline_id, module_id)
return jsonify({"status": "OK"})
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -195,7 +208,7 @@ def get_status():
response = manager.get_status(pipeline_id, module_id)
return jsonify(success(response))
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -206,7 +219,27 @@ def get_movie():
clip_full_path, total_time = create_clip(params)
return jsonify(success({"path": clip_full_path, "time": total_time}))
except Exception as e:
print(traceback.format_exc())
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


@app.route('/hcs/images', methods=['GET'])
def get_image():
manager = app.config['images']
try:
return jsonify(success({'uuid': manager.generate_image(flask.request.args)}))
except Exception as e:
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


@app.route('/hcs/images/statuses', methods=['GET'])
def get_image_processing_results():
manager = app.config['images']
try:
return jsonify(success(manager.get_results(flask.request.args.get('uuid'))))
except Exception as e:
print(traceback.format_exc(), flush=True)
return jsonify(error(e.__str__()))


Expand All @@ -218,8 +251,10 @@ def main():
args = parser.parse_args()

pipelines = {}
image_tasks = {}

app.config['hcs'] = HCSManager(pipelines)
app.config['images'] = HCSImagesManager(image_tasks)

app.run(host=args.host, port=args.port)

Expand Down
Loading