Make loadData uses factory pattern instead of instantiating data object directly
2 unresolved threads
Implement the factory pattern for data loading.
Currently, loadData instantiates either RT130 or MSeed to create the object that stores loaded data. Because the constructor for these two classes takes only *args and **kwargs as arguments, there is no way to use static analysis on them. As a workaround, we create a factory method that takes explicit arguments to handle the creation of the data object. Seeing as this method has named arguments, we can use type hints to do static analysis on it.
Merge request reports
Activity
Filter activity
added For: Software PriorityHigh StatusFeedback Needed Type: Enhancement labels
removed StatusFeedback Needed label
added StatusOn Hold label
requested review from @ohosseini
34 34 dataObject = None 35 35 for d in listOfDir: 36 36 if dataObject is None: 37 if dataType == 'RT130': 38 dataObject = RT130( 39 tracking_box, d, 37 try: 38 dataObject = DataTypeModel.create_data_object( 39 dataType, tracking_box, d, 40 40 reqWFChans=reqWFChans, reqSOHChans=reqSOHChans, 39 dataType, tracking_box, d, 40 40 reqWFChans=reqWFChans, reqSOHChans=reqSOHChans, 41 41 readStart=readStart, readEnd=readEnd) 42 else: 43 try: 44 dataObject = MSeed( 45 tracking_box, d, reqWFChans=reqWFChans, 46 reqSOHChans=reqSOHChans, 47 readStart=readStart, readEnd=readEnd) 48 except Exception as e: 49 msg = f"Dir {d} can't be read due to error: {str(e)}" 50 displayTrackingInfo(tracking_box, msg, "Warning") 51 pass 42 except Exception as e: 43 msg = f"Dir {d} can't be read due to error: {str(e)}" 44 displayTrackingInfo(tracking_box, msg, "Warning") added 14 commits
-
03409fd3...dba1cedd - 10 commits from branch
master
- 2aef4cfb - Implemented factory method for DataTypeModel
- 3cc72385 - Switch to factory method in loadData
- f7f4631e - Update tests
- 013f0f20 - Remove unneeded import
Toggle commit list-
03409fd3...dba1cedd - 10 commits from branch
mentioned in commit 2c148722