Skip to content

Commit 3a431fd

Browse files
update cellprofiler-plugins organization (#172)
* update cellprofiler-plugins organization * more granular,updated plugins options * proper truthiness * make old new, make new old --------- Co-authored-by: Beth Cimini <bethac07@users.noreply.github.com>
1 parent 707b3cd commit 3a431fd

File tree

5 files changed

+57
-18
lines changed

5 files changed

+57
-18
lines changed

config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
ALWAYS_CONTINUE = 'False' # Whether or not to run CellProfiler with the --always-continue flag, which will keep CellProfiler from crashing if it errors
5555

5656
# PLUGINS
57-
USE_PLUGINS = 'False' # True to use any plugin from CellProfiler-plugins repo
58-
UPDATE_PLUGINS = 'False' # True to download updates from CellProfiler-plugins repo
59-
PLUGINS_COMMIT = '' # What commit or version tag do you want to check out?
60-
INSTALL_REQUIREMENTS = 'False' # True to install REQUIREMENTS_FILE defined below. Requirements should have all plugin dependencies.
61-
REQUIREMENTS_FILE = '' # Path within the CellProfiler-plugins repo to a requirements file
57+
USE_PLUGINS = 'False' # True to use any plugin from CellProfiler-plugins repo
58+
UPDATE_PLUGINS = 'False' # True to download updates from CellProfiler-plugins repo
59+
PLUGINS_COMMIT = 'False' # What commit or version tag do you want to check out? If not, set to False.
60+
INSTALL_REQUIREMENTS = 'False' # True to install REQUIREMENTS defined below. Requirements should have all plugin dependencies.
61+
REQUIREMENTS = '' # Flag to use with install (current) or path within the CellProfiler-plugins repo to a requirements file (deprecated).

documentation/DCP-documentation/step_1_configuration.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,27 @@ We suggest using this setting in conjunction with a small number of JOB_RETRIES.
121121

122122
### PLUGINS
123123
* **USE_PLUGINS:** Whether or not you will be using external plugins from the CellProfiler-plugins repository.
124+
When True, passes the `--plugins-directory` flag to CellProfiler.
125+
Defaults to the current v1.0 `CellProfiler-plugins/active_plugins` location for plugins but will revert to the historical location of plugins in the `CellProfiler-plugins` root directory if the `active_plugins` folder is not present.
124126
* **UPDATE_PLUGINS:** Whether or not to update the plugins repository before use.
125127
(i.e. run `git fetch --all` on CellProfiler-plugins)
126-
* **PLUGINS_COMMIT:** What commit or version tag to check out.
128+
* **PLUGINS_COMMIT:** If desired, what commit or version tag to check out.
127129
Used in the `git checkout PLUGINS_COMMIT` command in CellProfiler-plugins.
130+
If you do not want to checkout a specific commit, set to False.
128131
* **INSTALL_REQUIREMENTS:** Whether or not to install requirements associate with plugins.
129-
* **REQUIREMENTS_FILE:** A path within the CellProfiler-plugins repository to the requirements file you would like to install.
130-
Used in the `pip install -r REQUIREMENTS_FILE` command.
132+
Not all plugins require additional requirement installation.
133+
See [CellProfiler-plugins Documentation](https://plugins.cellprofiler.org/using_plugins.html) for more information on requirements.
134+
* **REQUIREMENTS:** For current v1.0 CellProfiler-plugins, a flag that will be passed to the install command (e.g. `cellpose`).
135+
See [CellProfiler-plugins Documentation](https://plugins.cellprofiler.org/using_plugins.html) for more information on supported flags.
136+
For deprecated versions of CellProfiler-plugins before v1.0, pass a path within the CellProfiler-plugins repository to the requirements file you would like to install that will be used in the `pip install -r REQUIREMENTS_FILE` command.
137+
138+
The [CellProfiler/Distributed-CellProfiler Docker](https://hub.docker.com/r/cellprofiler/distributed-cellprofiler/tags) 2.0.0_4.2.4 and older have a clone of the CellProfiler-plugins repository with deprecated organization in them.
139+
If you would like to continue using this clone, set `USE_PLUGINS = 'True'` and `UPDATE_PLUGINS = 'False'`.
140+
Note that if you do need to install requirements with the deprecated organization, pass the path to the requirements file within the CellProfiler-plugins repository as `REQUIREMENTS`.
141+
If you would like to update the CellProfiler-plugins repository with up-to-date plugins and new structure while using the CellProfiler/Distributed-CellProfiler Docker 2.0.0_4.2.4 and older, set `UPDATE_PLUGINS = 'True'`.
142+
143+
[CellProfiler/Distributed-CellProfiler Dockers](https://hub.docker.com/r/cellprofiler/distributed-cellprofiler/tags) newer than 2.0.0_4.2.4 have current CellProfiler-plugins repository organization.
144+
If you need to use deprecated plugin organization you can access previous commits or version tags by passing them as `PLUGINS_COMMIT`.
131145

132146
***
133147

run.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
CREATE_DASHBOARD = 'False'
1919
CLEAN_DASHBOARD = 'False'
2020
AUTO_MONITOR = 'False'
21+
REQUIREMENTS_FILE = False
2122
ALWAYS_CONTINUE = 'False'
2223
JOB_RETRIES = 10
2324

@@ -26,6 +27,8 @@
2627
# Back compatability with old config requirements
2728
if ':' in SQS_DEAD_LETTER_QUEUE:
2829
SQS_DEAD_LETTER_QUEUE = SQS_DEAD_LETTER_QUEUE.rsplit(':',1)[1]
30+
if REQUIREMENTS_FILE:
31+
REQUIREMENTS = REQUIREMENTS_FILE
2932

3033
WAIT_TIME = 60
3134
MONITOR_TIME = 60
@@ -151,12 +154,12 @@ def generate_task_definition(AWS_PROFILE):
151154
'name': 'UPLOAD_FLAGS',
152155
'value': UPLOAD_FLAGS
153156
}]
154-
if UPDATE_PLUGINS.lower()=='true':
157+
if USE_PLUGINS.lower()=='true':
155158
task_definition["containerDefinitions"][0]["environment"] += [
156159
{"name": "UPDATE_PLUGINS", "value": str(UPDATE_PLUGINS)},
157160
{"name": "PLUGINS_COMMIT", "value": str(PLUGINS_COMMIT)},
158161
{"name": "INSTALL_REQUIREMENTS", "value": str(INSTALL_REQUIREMENTS)},
159-
{"name": "REQUIREMENTS_FILE", "value": str(REQUIREMENTS_FILE)},
162+
{"name": "REQUIREMENTS", "value": str(REQUIREMENTS)},
160163
]
161164
return task_definition, taskRoleArn
162165

worker/cp-worker.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
DATA_ROOT = '/home/ubuntu/bucket'
1414
LOCAL_OUTPUT = '/home/ubuntu/local_output'
15-
PLUGIN_DIR = '/home/ubuntu/CellProfiler-plugins'
15+
PLUGIN_DIR = '/home/ubuntu/CellProfiler-plugins/active_plugins'
1616
QUEUE_URL = os.environ['SQS_QUEUE_URL']
1717
AWS_BUCKET = os.environ['AWS_BUCKET']
1818
if 'SOURCE_BUCKET' not in os.environ:
@@ -279,7 +279,11 @@ def runCellProfiler(message):
279279
else:
280280
printandlog("Didn't recognize input file",logger)
281281
if USE_PLUGINS.lower() == 'true':
282-
cmd += f' --plugins-directory={PLUGIN_DIR}'
282+
if os.path.isdir(PLUGIN_DIR):
283+
cmd += f' --plugins-directory={PLUGIN_DIR}'
284+
else:
285+
printandlog("Can't find current 'active_plugins' folder, defaulting to plugins root directory.",logger)
286+
cmd += " --plugins-directory='/home/ubuntu/CellProfiler-plugins/'"
283287
if ALWAYS_CONTINUE.lower() == 'true':
284288
cmd +=' --always-continue'
285289
print(f'Running {cmd}')

worker/run-worker.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,35 @@ aws cloudwatch put-metric-alarm --alarm-name ${APP_NAME}_${MY_INSTANCE_ID} --ala
3636
python3.8 instance-monitor.py &
3737

3838
# 5. UPDATE AND/OR INSTALL PLUGINS
39-
if [[ ${UPDATE_PLUGINS} == 'True' ]]; then
39+
if [[ ${USE_PLUGINS} == 'True' ]]; then
40+
if [[ ${UPDATE_PLUGINS} == 'True' ]]; then
41+
echo "Updating CellProfiler-plugins."
4042
cd CellProfiler-plugins
4143
git fetch --all
42-
git checkout ${PLUGINS_COMMIT} || echo "No such commit, branch, or version; failing here." & exit 1
4344
cd ..
44-
fi
45-
if [[ ${INSTALL_REQUIREMENTS} == 'True' ]]; then
45+
fi
46+
if [[ ${PLUGINS_COMMIT} != 'False' ]]; then
47+
echo "Checking out specific CellProfiler-plugins commit."
4648
cd CellProfiler-plugins
47-
pip install -r ${REQUIREMENTS_FILE} || echo "Requirements file not present or install failed; failing here." & exit 1
49+
git checkout ${PLUGINS_COMMIT} || echo "No such commit, branch, or version; failing here." & exit 1
4850
cd ..
49-
fi
51+
fi
52+
if [[ ${INSTALL_REQUIREMENTS} == 'True' ]]; then
53+
cd CellProfiler-plugins
54+
if [[ -z "$REQUIREMENTS" ]]; then
55+
REQUIREMENTS = $REQUIREMENTS_FILE
56+
fi
57+
if [[ -d "active_plugins" ]]; then
58+
echo "Installing CellProfiler-plugins requirements."
59+
pip install -e . ${REQUIREMENTS} || echo "Requirements install failed." & exit 1
60+
cd ..
61+
else
62+
echo "Detected deprecated CellProfiler-plugins repo organization. Installing requirements."
63+
pip install -r ${REQUIREMENTS} || echo "Requirements file not present or install failed; failing here." & exit 1
64+
cd ..
65+
fi
66+
fi
67+
fi
5068

5169
# 6. RUN CP WORKERS
5270
for((k=0; k<$DOCKER_CORES; k++)); do

0 commit comments

Comments
 (0)