This commit is contained in:
Steve Nyemba 2022-04-12 14:00:03 -05:00
parent 260f102186
commit d6fd7bceba
1 changed files with 14 additions and 5 deletions

View File

@ -214,7 +214,7 @@ class Learner(Process):
self.logger = transport.factory.instance(_args['logger']) if 'logger' in self.store else transport.factory.instance(provider='console',context='write',lock=True) self.logger = transport.factory.instance(_args['logger']) if 'logger' in self.store else transport.factory.instance(provider='console',context='write',lock=True)
if 'network_args' not in _args : if 'network_args' not in _args :
self.network_args ={ self.network_args ={
'context':_args['context'] if 'context' in _args else 'GENERAL', 'context':self.info['context'] ,
'logs':_args['logpath'] if 'logpath' in _args else 'logs', 'logs':_args['logpath'] if 'logpath' in _args else 'logs',
'max_epochs':int(_args['epochs']) if 'epochs' in _args else 2, 'max_epochs':int(_args['epochs']) if 'epochs' in _args else 2,
'batch_size':int (_args['batch']) if 'batch' in _args else 2000 'batch_size':int (_args['batch']) if 'batch' in _args else 2000
@ -363,7 +363,13 @@ class Generator (Learner):
#-- synthetic date #-- synthetic date
_date = datetime(year=year,month=month,day=day) _date = datetime(year=year,month=month,day=day)
FORMAT = _args['format'] if 'format' in _args else '%Y-%m-%d' FORMAT = '%Y-%m-%d'
if 'format' in self.info and 'field' in _args and _args['field'] in self.info['format']:
_name = _args['field']
FORMAT = self.info['format'][_name]
r = [] r = []
if offset : if offset :
r = [_date.strftime(FORMAT)] r = [_date.strftime(FORMAT)]
@ -382,6 +388,8 @@ class Generator (Learner):
_store = self.store['target'] if 'target' in self.store else {'provider':'console'} _store = self.store['target'] if 'target' in self.store else {'provider':'console'}
_store['lock'] = True _store['lock'] = True
_store['context'] = 'write' #-- Just in case _store['context'] = 'write' #-- Just in case
if 'table' not in _store :
_store['table'] = self.info['from']
writer = transport.factory.instance(**_store) writer = transport.factory.instance(**_store)
for _iodf in _candidates : for _iodf in _candidates :
@ -398,11 +406,12 @@ class Generator (Learner):
iname = self.info['make_date'][name] iname = self.info['make_date'][name]
years = _df[iname] years = _df[iname]
_dates = [self.make_date(year=year) for year in years] _dates = [self.make_date(year=year,field=name) for year in years]
if _dates : if _dates :
_df[name] = _dates _df[name] = _dates
_schema = self.get_schema()
writer.write(_df[['birth_datetime']+self.columns],schema=self.get_schema()) _schema = [{'name':_item.name,'type':_item.field_type} for _item in _schema]
writer.write(_df[['birth_datetime']+self.columns],schema=_schema)
pass pass
class factory : class factory :
_infocache = {} _infocache = {}