Skip to content

Commit 34a4ebd

Browse files
committed
Configure and rename collate-worker
1 parent abc3f2d commit 34a4ebd

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

‎worker/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN pip install awscli boto3 watchtower
3838
# SETUP NEW ENTRYPOINT
3939

4040
WORKDIR /workspace/software/pycytominer
41-
COPY generic-worker.py .
41+
COPY collate-worker.py .
4242
COPY instance-monitor.py .
4343
COPY run-worker.sh .
4444
RUN chmod 755 run-worker.sh
Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
else:
4646
DOWNLOAD_FILES = os.environ['DOWNLOAD_FILES']
4747

48-
localIn = '/home/ubuntu/local_input'
49-
5048

5149
#################################
5250
# CLASS TO HANDLE THE SQS QUEUE
@@ -97,6 +95,8 @@ def printandlog(text,logger):
9795
# RUN SOME PROCESS
9896
#################################
9997

98+
localIn = '/workspace'
99+
100100
def runSomething(message):
101101
#List the directories in the bucket- this prevents a strange s3fs error
102102
rootlist=os.listdir(DATA_ROOT)
@@ -110,19 +110,21 @@ def runSomething(message):
110110

111111
# Parse your message somehow to pull out a name variable that's going to make sense to you when you want to look at the logs later
112112
# What's commented out below will work, otherwise, create your own
113-
#group_to_run = message["group"]
114-
#groupkeys = list(group_to_run.keys())
115-
#groupkeys.sort()
116-
#metadataID = '-'.join(groupkeys)
113+
group_to_run = message["group"]
114+
groupkeys = list(group_to_run.keys())
115+
groupkeys.sort()
116+
metadataID = '-'.join(groupkeys)
117117

118118
# Add a handler with
119-
# watchtowerlogger=watchtower.CloudWatchLogHandler(log_group=LOG_GROUP_NAME, stream_name=str(metadataID),create_log_group=False)
120-
# logger.addHandler(watchtowerlogger)
119+
watchtowerlogger=watchtower.CloudWatchLogHandler(log_group=LOG_GROUP_NAME, stream_name=str(metadataID),create_log_group=False)
120+
logger.addHandler(watchtowerlogger)
121121

122122
# See if this is a message you've already handled, if you've so chosen
123123
# First, build a variable called remoteOut that equals your unique prefix of where your output should be
124124
# Then check if there are too many files
125125

126+
remoteOut = f"{message['aws_remote']}/backend/{message['batch']}/{message['group']}"
127+
126128
if CHECK_IF_DONE_BOOL.upper() == 'TRUE':
127129
try:
128130
s3client=boto3.client('s3')
@@ -140,17 +142,34 @@ def runSomething(message):
140142
pass
141143

142144
# Build and run your program's command
143-
# ie cmd = my-program --my-flag-1 True --my-flag-2 VARIABLE
145+
cmd = f"python pycytominer/cyto_utils/collate_cmd.py {message['batch']} \
146+
{message['config']} {message['group']} --tmp-dir {message['tmp_dir']} \
147+
--base {message['base_directory']} --column {message['column']}\
148+
--munge {message['munge']} --csv-dir {message['csv_dir']} \
149+
--aws-remote {message['aws_remote']} --image-feature-categories {message['image_feature_categories']} "
150+
if message["aggregate_only"].lower() == "true":
151+
cmd += " --aggregate-only"
152+
if message["overwrite"].lower() == "true":
153+
cmd += " --overwrite"
154+
if message["add_image_features"].lower() == "false":
155+
cmd += " --dont-add-image-features"
156+
if message["printtoscreen"].lower() == "false":
157+
cmd += " --printtoscreen"
144158
# you should assign the variable "localOut" to the output location where you expect your program to put files
145159

146160
print('Running', cmd)
147161
logger.info(cmd)
148162
subp = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
149163
monitorAndLog(subp,logger)
150164

165+
localOut = f"/workspace/backend/{message['batch']}/{message['group']}"
166+
151167
# Figure out a done condition - a number of files being created, a particular file being created, an exit code, etc.
152168
# If done, get the outputs and move them to S3
153-
if [ENTER DONE CONDITION HERE]:
169+
170+
done = True
171+
172+
if done:
154173
time.sleep(30)
155174
mvtries=0
156175
while mvtries <3:

‎worker/run-worker.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ python3.8 instance-monitor.py &
3131

3232
# 5. RUN CP WORKERS
3333
for((k=0; k<$DOCKER_CORES; k++)); do
34-
python3.8 generic-worker.py |& tee $k.out &
34+
python3.8 collate-worker.py |& tee $k.out &
3535
sleep $SECONDS_TO_START
3636
done
3737
wait

0 commit comments

Comments
 (0)