Skip to content

Commit befb4aa

Browse files
authored
Merge pull request #8 from LCOGT/update/change-operation-args
operation args and percentage complete tweak
2 parents c273610 + f1bca1c commit befb4aa

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

datalab/datalab_session/data_operations/data_operation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def wizard_description():
5050
"""
5151

5252
@abstractmethod
53-
def operate(self, cache_key, input_files):
53+
def operate(self):
5454
""" The method that performs the data operation.
5555
It should periodically update the percent completion during its operation.
5656
It should set the output and status into the cache when done.

datalab/datalab_session/data_operations/long.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def wizard_description():
3636
}
3737
}
3838

39-
def operate(self, cache_key, input_files):
39+
def operate(self):
4040
num_files = len(self.input_data.get('input_files', []))
4141
per_image_timeout = ceil(float(self.input_data.get('duration', 60.0)) / num_files)
4242
for i, file in enumerate(self.input_data.get('input_files', [])):

datalab/datalab_session/data_operations/median.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,25 @@ def wizard_description():
3838
}
3939
}
4040

41-
def operate(self, cache_key, input_files):
41+
def operate(self):
4242

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

45-
image_data_list = self.get_fits_npdata(input_files, percent=40.0, cur_percent=0.0)
45+
log.info(f'Executing median operation on {len(input)} files')
46+
47+
image_data_list = self.get_fits_npdata(input, percent=0.4, cur_percent=0.0)
4648

4749
stacked_data = stack_arrays(image_data_list)
4850

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

52-
hdu_list = create_fits(cache_key, median)
54+
hdu_list = create_fits(self.cache_key, median)
5355

54-
output = self.create_and_store_fits(hdu_list, percent=60.0, cur_percent=40.0)
56+
output = self.create_and_store_fits(hdu_list, percent=0.6, cur_percent=0.4)
5557

5658
output = {'output_files': output}
5759

5860
log.info(f'Median operation output: {output}')
59-
self.set_percent_completion(1)
61+
self.set_percent_completion(1.0)
6062
self.set_output(output)

datalab/datalab_session/data_operations/noop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def wizard_description():
4040
}
4141
}
4242

43-
def operate(self, cache_key, input_files):
43+
def operate(self):
4444
print("No-op triggered!")
4545
output = {
4646
'output_files': self.input_data.get('input_files', [])

datalab/datalab_session/tasks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,4 @@ def execute_data_operation(data_operation_name: str, input_data: dict):
1616
if operation_class is None:
1717
raise NotImplementedError("Operation not implemented!")
1818
else:
19-
operation = operation_class(input_data)
20-
cache_key = operation.generate_cache_key()
21-
22-
operation.operate(cache_key, input_data.get('input_files', []))
19+
operation_class(input_data).operate()

0 commit comments

Comments
 (0)