Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comp.py: add csv output + replace digest with hexdigest #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions src/comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import h5py
import getopt
import sys
import csv
import hashlib
try:
from mpi4py import MPI
Expand Down Expand Up @@ -237,7 +238,7 @@ def __call__(self, tpl):

with h5py.File(output_filename, 'w') as output:

digest = hashlib.sha256(open(filename, 'rb').read()).digest()
digest = str(hashlib.sha256(open(filename, 'rb').read()).hexdigest())

create_attrs_in_comp_file(output,precision,utimeout,os.uname()[1],measure_name)

Expand Down Expand Up @@ -289,6 +290,15 @@ def __call__(self, tpl):
with open('report.txt', "a") as report_file:
print (list_print, file=report_file)

with open('report.csv', 'a', newline='') as csv_f:
fieldnames = ['solver']
fieldnames.extend(attrs.keys())
writer = csv.DictWriter(csv_f, fieldnames=fieldnames)
if csv_f.tell() == 0:
writer.writeheader()
d = attrs
d['solver'] = solver.name()
writer.writerow(d)

@timeout(utimeout)
def _internal_call(self, solver, problem, filename, pfilename, output_filename):
Expand Down Expand Up @@ -316,7 +326,7 @@ def _internal_call(self, solver, problem, filename, pfilename, output_filename):
flpops = None
mflops = None

digest = hashlib.sha256(open(filename, 'rb').read()).digest()
digest = str(hashlib.sha256(open(filename, 'rb').read()).hexdigest())

if psize is not None:
solver_problem_data.create_dataset(np.string_('reactions'),
Expand Down Expand Up @@ -469,11 +479,7 @@ def pffff(r, v, e):
attrs.create('nc', numberOfDegreeofFreedomContacts(filename))
attrs.create('nds', numberOfDegreeofFreedom(filename))
attrs.create('cond_nc', cond_problem(filename))
if b'\x00' in digest:
print('null character x00 in digest ' , digest)
print('Warning: the attribute is not created')
else:
attrs.create('digest', digest)
attrs.create('digest', digest)
attrs.create('info', info)
attrs.create('iter', iter)
attrs.create('err', err)
Expand Down Expand Up @@ -517,6 +523,15 @@ def pffff(r, v, e):
with open('report.txt', "a") as report_file:
print (list_print, file=report_file)

with open('report.csv', 'a', newline='') as csv_f:
fieldnames = ['solver']
fieldnames.extend(attrs.keys())
writer = csv.DictWriter(csv_f, fieldnames=fieldnames)
if csv_f.tell() == 0:
writer.writeheader()
d = attrs
d['solver'] = solver.name()
writer.writerow(d)



Expand Down