text stringlengths 0 828 |
|---|
smrp = self._generic_exception(point, smrp, allowraise) |
# SQLAQ There are several states to deal with at this point |
# A) the datatable exists but a feed has been added |
# B) the datatable doesn't exist and needs to be created |
# C) the datatable needs to be updated for more or less feeds |
# D) the datatable_exists flag is incorrect because all edge cases |
# haven't been handled yet. |
# |
# My logic is that once Trump is more functional, I'll be able to |
# eliminate this hacky solution. But, SQLAlchemy might have |
# a more elegant answer. A check, of somekind prior to deletion? |
# if not self.datatable_exists: |
# self._init_datatable() #older version of _init_datatable |
# delete(self.datatable).execute() |
# self._init_datatable() #older version of _init_datatable |
# Is this the best way to check? |
# if engine.dialect.has_table(session.connection(), self.name): |
# delete(self.datatable).execute() |
self._refresh_datatable_schema() |
if len(data) > 0: |
data.index.name = 'indx' |
data = data.reset_index() |
datarecords = data.to_dict(orient='records') |
objs = object_session(self) |
objs.execute(self.datatable.insert(), datarecords) |
objs.commit() |
if checkvalidity: |
try: |
isvalid, reports = self.check_validity(report=True) |
for rep in reports: |
smrp.add_reportpoint(rep) |
if not isvalid: |
raise Exception('{} is not valid'.format(self.name)) |
except: |
point = ""validity_check"" |
smrp = self._generic_exception(point, smrp, allowraise) |
self._log_an_event('CACHE','COMPLETE', ""Fresh!"") |
else: |
self._log_an_event('CACHE','FRESH', ""Was still fresh"") |
return smrp" |
1861,"def check_validity(self, checks=None, report=True): |
"""""" Runs a Symbol's validity checks. |
Parameters |
---------- |
checks : str, [str,], optional |
Only run certain checks. |
report : bool, optional |
If set to False, the method will return only the result of the |
check checks (True/False). Set to True, to have a |
SymbolReport returned as well. |
Returns |
------- |
Bool, or a Tuple of the form (Bool, SymbolReport) |
"""""" |
if report: |
reportpoints = [] |
allchecks = [] |
checks_specified=False |
if isinstance(checks, (str, unicode)): |
checks = [checks] |
checks_specified = True |
elif isinstance(checks, (list, tuple)): |
checks_specified = True |
else: |
checks = [] |
for val in self.validity: |
if (val.validator in checks) or (not checks_specified): |
ValCheck = validitychecks[val.validator] |
anum = ValCheck.__init__.func_code.co_argcount - 2 |
args = [] |
for arg in SymbolValidity.argnames: |
args.append(getattr(val, arg)) |
valid = ValCheck(self.datatable_df, *args[:anum]) |
res = valid.result |
allchecks.append(res) |
rp = ReportPoint('validation', val.validator, res, str(args[:anum])) |
reportpoints.append(rp) |
if report: |
return all(allchecks), reportpoints |
else: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.