File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929 "required" : true
3030 }
3131 ],
32+ "triggers" : [
33+ {
34+ "name" : " read_now" ,
35+ "label" : " Read data now" ,
36+ "description" : " Manually read and emit the data without waiting." ,
37+ "mode" : " single"
38+ }
39+ ],
3240 "parallel_config" : {
3341 "type" : " none"
3442 }
Original file line number Diff line number Diff line change 1515
1616@operator
1717def read_data_ncempy (
18- inputs : BytesMessage | None , parameters : dict [str , Any ]
18+ inputs : BytesMessage | None , parameters : dict [str , Any ], trigger = None
1919) -> BytesMessage | None :
20- """This reads data from disk and sends it on ."""
21-
22- # This operator does not require inputs
20+ """Read and emit TEM data from a specified file when triggered ."""
21+ if trigger is None :
22+ return None
2323
2424 # Extract parameters
2525 directory = parameters .get ("raw_data_dir" , "/test_data" )
@@ -40,11 +40,14 @@ def read_data_ncempy(
4040 except Exception as e :
4141 logger .info (f"Problem loading file. Error: { e } " )
4242 return None
43- finally :
44- # TODO: Use trigger instead of time.sleep to control when data is sent
45- time .sleep (3.0 ) # wait to read it again.
4643
4744 # Process and return result if the data was loaded successfully
4845 data_bytes = data .tobytes ()
49- header = MessageHeader (subject = MessageSubject .BYTES , meta = {'shape' : data .shape , 'dtype' : str (data .dtype )})
46+ header = MessageHeader (
47+ subject = MessageSubject .BYTES ,
48+ meta = {
49+ "shape" : data .shape ,
50+ "dtype" : str (data .dtype ),
51+ },
52+ )
5053 return BytesMessage (header = header , data = data_bytes )
You can’t perform that action at this time.
0 commit comments