Skip to content

Commit 338e7c6

Browse files
bethac07Matthew ChessUbuntu
authored
Clone and install requirements for CPPlugins (#91)
* Clone the plugins repo * Update Dockerfile * Add plugins directory to CP call * Add plugins to config * Add USE_PLUGINS * Fix -i bug in batchfiles, make plugins follow an input variable * Fix formatting of cmd lines * Space before --plugins * Rebase plugins use (#109) * Add userdata for each LaunchSpecification (#102) Co-authored-by: Ubuntu <[email protected]> * Batch files should be able to have input files too Co-authored-by: Matthew Chess <[email protected]> Co-authored-by: Ubuntu <[email protected]> Co-authored-by: Matthew Chess <[email protected]> Co-authored-by: Ubuntu <[email protected]>
1 parent 2520c42 commit 338e7c6

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@
3737
CHECK_IF_DONE_BOOL = 'True' #True or False- should it check if there are a certain number of non-empty files and delete the job if yes?
3838
EXPECTED_NUMBER_FILES = 7 #What is the number of files that trigger skipping a job?
3939
MIN_FILE_SIZE_BYTES = 1 #What is the minimal number of bytes an object should be to "count"?
40+
41+
# PLUGINS
42+
USE_PLUGINS = 'True'

fabfile.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ def generate_task_definition():
158158
{
159159
"name": "MIN_FILE_SIZE_BYTES",
160160
"value": str(MIN_FILE_SIZE_BYTES)
161+
},
162+
{
163+
"name": "USE_PLUGINS",
164+
"value": str(USE_PLUGINS)
161165
}
162166
]
163167
return task_definition

worker/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# This wraps the cellprofiler docker registry
66
#
77

8+
89
FROM cellprofiler/cellprofiler:3.1.9
910

1011
# Install S3FS
@@ -56,6 +57,12 @@ COPY instance-monitor.py .
5657
COPY run-worker.sh .
5758
RUN chmod 755 run-worker.sh
5859

60+
RUN git clone https://github.com/CellProfiler/CellProfiler-plugins.git
61+
WORKDIR /home/ubuntu/CellProfiler-plugins
62+
RUN \
63+
pip install -r requirements.txt
64+
65+
WORKDIR /home/ubuntu
5966
ENTRYPOINT ["./run-worker.sh"]
6067
CMD [""]
6168

worker/cp-worker.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
DATA_ROOT = '/home/ubuntu/bucket'
1919
LOCAL_OUTPUT = '/home/ubuntu/local_output'
20+
PLUGIN_DIR = '/home/ubuntu/CellProfiler-plugins'
2021
QUEUE_URL = os.environ['SQS_QUEUE_URL']
2122
AWS_BUCKET = os.environ['AWS_BUCKET']
2223
LOG_GROUP_NAME= os.environ['LOG_GROUP_NAME']
@@ -26,6 +27,10 @@
2627
MIN_FILE_SIZE_BYTES = 1
2728
else:
2829
MIN_FILE_SIZE_BYTES = int(os.environ['MIN_FILE_SIZE_BYTES'])
30+
if 'USE_PLUGINS' not in os.environ:
31+
USE_PLUGINS = 'False'
32+
else:
33+
USE_PLUGINS = os.environ['USE_PLUGINS']
2934

3035
#################################
3136
# CLASS TO HANDLE THE SQS QUEUE
@@ -129,7 +134,7 @@ def runCellProfiler(message):
129134
remoteOut= os.path.join(message['output'],metadataID)
130135
replaceValues = {'PL':message['pipeline'], 'OUT':localOut, 'FL':message['data_file'],
131136
'DATA': DATA_ROOT, 'Metadata': message['Metadata'], 'IN': message['input'],
132-
'MetadataID':metadataID }
137+
'MetadataID':metadataID, 'PLUGINS':PLUGIN_DIR }
133138
# See if this is a message you've already handled, if you've so chosen
134139
if CHECK_IF_DONE_BOOL.upper() == 'TRUE':
135140
try:
@@ -159,9 +164,12 @@ def runCellProfiler(message):
159164
cpDone = localOut + '/cp.is.done'
160165
if message['pipeline'][-3:]!='.h5':
161166
cmd = cmdstem + '-p %(DATA)s/%(PL)s -i %(DATA)s/%(IN)s -o %(OUT)s -d ' + cpDone
162-
cmd += ' --data-file=%(DATA)s/%(FL)s -g %(Metadata)s'
167+
cmd += ' --data-file=%(DATA)s/%(FL)s '
168+
cmd += '-g %(Metadata)s'
163169
else:
164170
cmd = cmdstem + '-p %(DATA)s/%(PL)s -i %(DATA)s/%(IN)s -o %(OUT)s -d ' + cpDone + ' --data-file=%(DATA)s/%(FL)s -g %(Metadata)s'
171+
if USE_PLUGINS == 'True':
172+
cmd += ' --plugins-directory=%(PLUGINS)s'
165173
cmd = cmd % replaceValues
166174
print('Running', cmd)
167175
logger.info(cmd)

0 commit comments

Comments
 (0)