##// END OF EJS Templates
checking misspelled kwargs in operations/processing units
José Chávez -
r929:136584fbb1e2
parent child
Show More
@@ -1,7 +1,7
1 1 import os
2 2 import datetime
3 3 import numpy
4
4 import inspect
5 5 from figure import Figure, isRealtime, isTimeInHourRange
6 6 from plotting_codes import *
7 7
@@ -642,7 +642,6 class ParametersPlot(Figure):
642 642 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
643 643 server=None, folder=None, username=None, password=None,
644 644 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
645
646 645 """
647 646
648 647 Input:
@@ -792,7 +791,7 class Parameters1Plot(Figure):
792 791 self.__nsubplots = 1
793 792
794 793 self.WIDTH = 800
795 self.HEIGHT = 150
794 self.HEIGHT = 180
796 795 self.WIDTHPROF = 120
797 796 self.HEIGHTPROF = 0
798 797 self.counter_imagwr = 0
@@ -857,7 +856,7 class Parameters1Plot(Figure):
857 856 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
858 857 server=None, folder=None, username=None, password=None,
859 858 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
860
859 #print inspect.getargspec(self.run).args
861 860 """
862 861
863 862 Input:
@@ -3,6 +3,30
3 3 $Author: murco $
4 4 $Id: jroproc_base.py 1 2012-11-12 18:56:07Z murco $
5 5 '''
6 import inspect
7 from fuzzywuzzy import process
8
9 def checkKwargs(method, kwargs):
10 currentKwargs = kwargs
11 choices = inspect.getargspec(method).args
12 try:
13 choices.remove('self')
14 except Exception as e:
15 pass
16
17 try:
18 choices.remove('dataOut')
19 except Exception as e:
20 pass
21
22 for kwarg in kwargs:
23 fuzz = process.extractOne(kwarg, choices)
24 print fuzz
25 if fuzz is None:
26 continue
27 if fuzz[1] < 100:
28 raise Exception('\x1b[2;30;43mDid you mean {} instead of {} in {}? \x1b[0m'.
29 format(fuzz[0], kwarg, method.__self__.__class__.__name__))
6 30
7 31 class ProcessingUnit(object):
8 32
@@ -41,14 +65,18 class ProcessingUnit(object):
41 65
42 66 self.args = args
43 67 self.kwargs = kwargs
68 checkKwargs(self.run, kwargs)
69
70 def getAllowedArgs(self):
71 return inspect.getargspec(self.run).args
44 72
45 73 def addOperationKwargs(self, objId, **kwargs):
46 74 '''
47 75 '''
48
76
49 77 self.operationKwargs[objId] = kwargs
50
51
78
79
52 80 def addOperation(self, opObj, objId):
53 81
54 82 """
@@ -117,16 +145,16 class ProcessingUnit(object):
117 145 #Executing the self method
118 146
119 147 if hasattr(self, 'mp'):
120 if name=='run':
121 if self.mp is False:
148 if name=='run':
149 if self.mp is False:
122 150 self.mp = True
123 151 self.start()
124 else:
125 methodToCall(**self.operationKwargs[opId])
152 else:
153 methodToCall(**self.operationKwargs[opId])
126 154 else:
127 if name=='run':
155 if name=='run':
128 156 methodToCall(**self.kwargs)
129 else:
157 else:
130 158 methodToCall(**self.operationKwargs[opId])
131 159
132 160 if self.dataOut is None:
@@ -280,6 +308,10 class Operation(object):
280 308 self.__buffer = None
281 309 self.isConfig = False
282 310 self.kwargs = kwargs
311 checkKwargs(self.run, kwargs)
312
313 def getAllowedArgs(self):
314 return inspect.getargspec(self.run).args
283 315
284 316 def setup(self):
285 317
@@ -11,11 +11,11 def fiber(cursor, skip, q, dt):
11 11 controllerObj.setup(id='191', name='test01', description=desc)
12 12
13 13 readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader',
14 path='/home/nanosat/data/hysell_data20/pdata',
14 path='/home/nanosat/data/julia',
15 15 startDate=dt,
16 16 endDate=dt,
17 17 startTime="00:00:00",
18 endTime="23:59:59",
18 endTie="23:59:59",
19 19 online=0,
20 20 #set=1426485881,
21 21 delay=10,
@@ -29,8 +29,8 def fiber(cursor, skip, q, dt):
29 29 # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
30 30 #
31 31 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
32 # opObj11 = procUnitConfObj2.addParameter(name='pairsList', value='(0,1)', format='pairslist')
33 #
32 # procUnitConfObj2.addParameter(name='nipp', value='5', format='int')
33
34 34 procUnitConfObj3 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId())
35 35 opObj11 = procUnitConfObj3.addOperation(name='SpectralMoments', optype='other')
36 36
@@ -44,10 +44,19 def fiber(cursor, skip, q, dt):
44 44 # opObj11.addParameter(name='save', value='1', format='int')
45 45 # opObj11.addParameter(name='figpath', value=figpath, format='str')
46 46
47 # opObj11 = procUnitConfObj2.addOperation(name='RTIPlot', optype='other')
48 # opObj11.addParameter(name='id', value='2000', format='int')
49 # opObj11.addParameter(name='wintitzmaxle', value='HF_Jicamarca', format='str')
50 # opObj11.addParameter(name='showprofile', value='0', format='int')
47 opObj11 = procUnitConfObj3.addOperation(name='Parameters1Plot', optype='other')
48 opObj11.addParameter(name='channelList', value='0', format='intList')
49
50 opObj11.addParameter(name='id', value='2000', format='int')
51 # opObj11.addParameter(name='colormap', value='0', format='bool')
52 opObj11.addParameter(name='onlySNR', value='1', format='bool')
53 opObj11.addParameter(name='DOP', value='0', format='bool')
54 # opObj11.addParameter(name='showSNR', value='1', format='bool')
55 # opObj11.addParameter(name='SNRthresh', value='0', format='int')
56 # opObj11.addParameter(name='SNRmin', value='-10', format='int')
57 # opObj11.addParameter(name='SNRmax', value='30', format='int')
58
59 # opObj11.addParameter(name='showSNR', value='1', format='int')
51 60 # # opObj11.addParameter(name='channelList', value='0', format='intlist')
52 61 # # opObj11.addParameter(name='xmin', value='0', format='float')
53 62 # opObj11.addParameter(name='xmin', value='0', format='float')
@@ -1,1 +1,1
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/data/hysell_data20/pdata" /><Parameter format="date" id="191113" name="startDate" value="2015/09/26" /><Parameter format="date" id="191114" name="endDate" value="2015/09/26" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="2" /><Parameter format="int" id="191119" name="skip" value="720" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="PublishData" priority="3" type="other"><Parameter format="int" id="191331" name="zeromq" value="1" /><Parameter format="int" id="191332" name="delay" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /></ProcUnit></Project> No newline at end of file
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/data/julia" /><Parameter format="date" id="191113" name="startDate" value="2015/09/26" /><Parameter format="date" id="191114" name="endDate" value="2015/09/26" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="0" /><Parameter format="int" id="191119" name="skip" value="0" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="Parameters1Plot" priority="3" type="other"><Parameter format="intlist" id="191331" name="channelList" value="0" /><Parameter format="int" id="191332" name="id" value="2000" /><Parameter format="bool" id="191333" name="olySNR" value="1" /><Parameter format="bool" id="191334" name="DOP" value="0" /></Operation><Operation id="19134" name="PublishData" priority="4" type="other"><Parameter format="int" id="191341" name="zeromq" value="1" /><Parameter format="int" id="191342" name="delay" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /></ProcUnit></Project> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now