@@ -84,12 +84,11 @@ def login(self, user, pw, **q):
8484 cred = {"user" : vStr (user ), "password" : pw }
8585 r :dict = self ._send_req (json .dumps (cred ), deal_library_url )
8686 if 'token' in r :
87- console .print (f"✅ login successfully, user -> { r ['user' ]} ,group -> { r ['group' ]} " )
87+ console .print (f"✅ Login successfully, user -> { r ['user' ]} ,group -> { r ['group' ]} " )
8888 self .token = r ['token' ]
8989 else :
90- if hasattr (self , 'token' ):
91- delattr (self , 'token' )
9290 console .print (f"❌ Failed to login,{ r ['msg' ]} " )
91+ self .token = None
9392 return None
9493
9594 def ack (self ):
@@ -130,8 +129,10 @@ def query(self, k = {}, read=True):
130129 raise AbsboxError (f"❌ No token found , please call loginLibrary() to login" )
131130
132131 deal_library_url = self .url + f"/{ LibraryEndpoints .Query .value } "
133- result = self ._send_req (json .dumps ({"q" :k }), deal_library_url , headers = {"Authorization" : f"Bearer { self .token } " })
134- console .print (f"✅ query success" )
132+ result = self ._send_req (json .dumps ({"q" :k })
133+ , deal_library_url
134+ , headers = {"Authorization" : f"Bearer { self .token } " })
135+ console .print (f"✅ Query success: { k } " )
135136 if read :
136137 if 'data' in result :
137138 return pd .DataFrame (result ['data' ], columns = result ['header' ])
@@ -140,44 +141,6 @@ def query(self, k = {}, read=True):
140141 else :
141142 return result
142143
143- def add (self , d , ** p ):
144- """add deal to library"""
145-
146- if not hasattr (self , "token" ):
147- raise AbsboxError (f"❌ No token found, please call login() to login" )
148- deal_library_url = self .url + f"/{ LibraryEndpoints .Add .value } "
149-
150- data = {
151- "deal" :d
152- ,"json" : d .json
153- ,"buildVersion" : VERSION_NUM
154- ,"name" : d .name
155- ,"version" : p .get ("version" ,0 )
156- ,"period" : p .get ("period" ,0 )
157- ,"stage" : p .get ("stage" ,"draft" )
158- ,"comment" : p .get ("comment" ,"" )
159- ,"permission" : p .get ("permission" ,"700" )
160- ,"tags" : p .get ("tags" ,[])
161- ,"group" : p .get ("group" ,"" )
162- }
163-
164- bData = pickle .dumps (data )
165-
166- r = self ._send_req (bData , deal_library_url
167- , headers = {"Authorization" : f"Bearer { self .token } "
168- ,"Content-Type" :"application/octet-stream" })
169-
170- console .print (f"✅ add success with deal id={ r ['dealId' ]} , name={ r ['name' ]} " )
171-
172- def cmd (self , p ):
173- if not hasattr (self , "token" ):
174- raise AbsboxError (f"❌ No token found, please call login() to login" )
175-
176- deal_library_url = self .url + f"/{ LibraryEndpoints .Cmd .value } "
177-
178- r = self ._send_req (pickle .dumps (p ), deal_library_url ,headers = {"Authorization" : f"Bearer { self .token } " } )
179-
180- return r
181144
182145 def get (self , q ):
183146 if not hasattr (self , "token" ):
@@ -189,7 +152,7 @@ def get(self, q):
189152 ,"Content-Type" :"application/octet-stream" })
190153
191154 return r
192- console .print (f"✅ get deal success" )
155+ # console.print(f"✅ Get deal success")
193156
194157 def run (self , _id , ** p ):
195158 """send deal id with assumptions to remote server and get result back
@@ -216,7 +179,9 @@ def run(self, _id, **p):
216179
217180 runReq = {"q" : _id , "runType" : runType
218181 ,"runAssump" : runAssump , "poolAssump" : poolAssump
219- ,"engine" : p .get ("engine" ,None ) }
182+ ,"engine" : p .get ("engine" ,None )
183+ ,"tweak" : p .get ("tweak" ,None ),"stop" : p .get ("stop" ,None )
184+ }
220185
221186 bRunReq = pickle .dumps (runReq )
222187
@@ -228,7 +193,7 @@ def run(self, _id, **p):
228193 try :
229194 result = r ['result' ]
230195 runInfo = tz .dissoc (r , 'result' )
231- console .print (f"✅ run success with deal: { runInfo ['deal' ]['name' ]} |{ runInfo ['deal' ]['id' ]} " )
196+ console .print (f"✅ Run success with deal: { runInfo ['deal' ]['name' ] } | { runInfo [ 'deal' ][ 'period ' ]} |{ runInfo ['deal' ]['id' ]} " )
232197 except Exception as e :
233198 raise AbsboxError (f"❌ message from API server:\n ,{ e } " )
234199 try :
0 commit comments