Commit 707e800e authored by M. Huang's avatar M. Huang
Browse files

pre-1.0 y2p minor improvement

parent 2ee683cd
......@@ -5,6 +5,10 @@ Change Log
BETA0
=====
1.0 2021-01-17
-----------------
TableDataset numeric indexing, slicing, vLookUp. Basic performance enhancing. Parameter.split()
1.0rc9 2020-12-27
-----------------
YAML schema v1.4; ClassID->_STID; pInfo->zInfo; product subclassing sorted. MapContext sorted. y2p handles parents better. Context rule.
......
......@@ -38,13 +38,13 @@ runpoolserver:
INSOPT =
install:
pip3 install $(INSOPT) -e . $(I)
python3 -m pip install $(INSOPT) -e . $(I)
install_with_DOC:
pip3 install $(INSOPT) -e .[DOC] $(I)
python3 -m pip install $(INSOPT) -e .[DOC] $(I)
uninstall:
pip3 uninstall $(INSOPT) fdi $(I)
python3 -m pip uninstall $(INSOPT) fdi $(I)
PNSDIR=~/pns
installpns:
......
__version_info__ = (1, 0, 'rc9')
__version_info__ = (1, 0, 'pre')
__version__ = '.'.join(map(str, __version_info__))
......@@ -252,7 +252,6 @@ def readyaml(ypath, ver=None):
d['datasets'] = {}
if float(d['schema']) >= 1.0:
pass
print('Read %s from %s' % (d['schema'], fin))
if float(d['schema']) > 0.6:
attrs = OrderedDict(d['metadata'])
datasets = OrderedDict()
......@@ -263,9 +262,9 @@ def readyaml(ypath, ver=None):
del attrs['TABLE']
if 'datasets' in d:
datasets.update(d['datasets'])
print('Read from %s:\n%s' %
(fin, ''.join([k + '=' + str(v) + '\n'
for k, v in d.items() if k not in ['metadata', 'datasets']])))
print('Pre-emble:\n%s' %
(''.join([k + '=' + str(v) + '\n'
for k, v in d.items() if k not in ['metadata', 'datasets']])))
logger.debug('Find attributes:\n%s' %
''.join(('%20s' % (k+'=' + str(v['default'])
......@@ -351,6 +350,48 @@ def yamlupgrade(descriptors, fins, ypath, version, verbose):
output(nm, d, fins, version, verbose)
def dependency_sort(descriptors):
""" sort the descriptors so that everyone's parents are to his right.
"""
ret = []
working_list = list(descriptors.keys())
while len(working_list):
# must use index to loop
for i in range(len(working_list)):
nm = working_list[i]
p = descriptors[nm][0]['parents']
nm_found_parent = False
if len(p) == 0:
continue
found = set(working_list) & set(p)
# for x in working_list:
# if x == nm:
# continue
# if x in p:
if len(found):
# parent is in working_list
working_list.remove(nm)
working_list.append(nm)
nm_found_parent = True
break
else:
# no one in the list is nm's superclass
# TODO: only immediate parenthood tested
ret.append(nm)
working_list.remove(nm)
break
if nm_found_parent:
break
else:
# no one in the list is free from deendency to others
if len(working_list):
msg = 'Cyclic dependency among ' + str(working_list)
logger.error(msg)
sys.exit(-5)
return ret
def removeParent(a, b):
""" Returns the one who is the other one's parent.
"""
......@@ -467,43 +508,8 @@ if __name__ == '__main__':
exclude=importexclude, verbose=verbose)
glb = Classes.updateMapping(
c=pcl, rerun=True, exclude=importexclude, verbose=verbose)
# sort the descriptors so that everyone's parents are to his right
working_list = list(descriptors.keys())
sorted_list = []
while len(working_list):
# must use index to loop
for i in range(len(working_list)):
nm = working_list[i]
p = descriptors[nm][0]['parents']
nm_found_parent = False
if len(p) == 0:
continue
found = set(working_list) & set(p)
# for x in working_list:
# if x == nm:
# continue
# if x in p:
if len(found):
# parent is in working_list
working_list.remove(nm)
working_list.append(nm)
nm_found_parent = True
break
else:
# no one in the list is nm's superclass
# TODO: only immediate parenthood tested
sorted_list.append(nm)
working_list.remove(nm)
break
if nm_found_parent:
break
else:
# no one in the list is free from deendency to others
if len(working_list):
msg = 'Cyclic dependency among ' + str(working_list)
logger.error(msg)
sys.exit(-5)
# make a list whose members do not depend members behind
sorted_list = dependency_sort(descriptors)
for nm in sorted_list:
d, attrs, datasets, fin = descriptors[nm]
print('************** Processing ' + nm + '***********')
......@@ -538,7 +544,7 @@ if __name__ == '__main__':
all_attrs = attrs
prodname = d['name']
# module/output-file name is YAML input file "name" with lowercase
# module/output file name is YAML input file "name" with lowercase
modulename = nm.lower()
# make output filename, lowercase modulename + .py
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment