Skip to content

Commit

Permalink
Merge pull request #8 from LCOGT/update/change-operation-args
Browse files Browse the repository at this point in the history
operation args and percentage complete tweak
  • Loading branch information
LTDakin authored Apr 23, 2024
2 parents c273610 + f1bca1c commit befb4aa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion datalab/datalab_session/data_operations/data_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def wizard_description():
"""

@abstractmethod
def operate(self, cache_key, input_files):
def operate(self):
""" The method that performs the data operation.
It should periodically update the percent completion during its operation.
It should set the output and status into the cache when done.
Expand Down
2 changes: 1 addition & 1 deletion datalab/datalab_session/data_operations/long.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def wizard_description():
}
}

def operate(self, cache_key, input_files):
def operate(self):
num_files = len(self.input_data.get('input_files', []))
per_image_timeout = ceil(float(self.input_data.get('duration', 60.0)) / num_files)
for i, file in enumerate(self.input_data.get('input_files', [])):
Expand Down
14 changes: 8 additions & 6 deletions datalab/datalab_session/data_operations/median.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,25 @@ def wizard_description():
}
}

def operate(self, cache_key, input_files):
def operate(self):

log.info(f'Executing median operation on {len(input_files)} files')
input = self.input_data.get('input_files', [])

image_data_list = self.get_fits_npdata(input_files, percent=40.0, cur_percent=0.0)
log.info(f'Executing median operation on {len(input)} files')

image_data_list = self.get_fits_npdata(input, percent=0.4, cur_percent=0.0)

stacked_data = stack_arrays(image_data_list)

# using the numpy library's median method
median = np.median(stacked_data, axis=2)

hdu_list = create_fits(cache_key, median)
hdu_list = create_fits(self.cache_key, median)

output = self.create_and_store_fits(hdu_list, percent=60.0, cur_percent=40.0)
output = self.create_and_store_fits(hdu_list, percent=0.6, cur_percent=0.4)

output = {'output_files': output}

log.info(f'Median operation output: {output}')
self.set_percent_completion(1)
self.set_percent_completion(1.0)
self.set_output(output)
2 changes: 1 addition & 1 deletion datalab/datalab_session/data_operations/noop.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def wizard_description():
}
}

def operate(self, cache_key, input_files):
def operate(self):
print("No-op triggered!")
output = {
'output_files': self.input_data.get('input_files', [])
Expand Down
5 changes: 1 addition & 4 deletions datalab/datalab_session/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ def execute_data_operation(data_operation_name: str, input_data: dict):
if operation_class is None:
raise NotImplementedError("Operation not implemented!")
else:
operation = operation_class(input_data)
cache_key = operation.generate_cache_key()

operation.operate(cache_key, input_data.get('input_files', []))
operation_class(input_data).operate()

0 comments on commit befb4aa

Please sign in to comment.