Skip to content

Commit

Permalink
write results in json file and add prints
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Fievet committed Sep 3, 2024
1 parent 00bb75f commit 7bc4a4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/identify_target_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
id: new_version_number
env:
BOINC_APP_DESCRIPTION: ${{ inputs.boinc_app_description }}
SPECIFIED_VERSION: '1.29'
SPECIFIED_VERSION: '1.30'
run: |
echo "BOINC_APP_DESCRIPTION: $BOINC_APP_DESCRIPTION"
echo "SPECIFIED_VERSION: $SPECIFIED_VERSION"
Expand Down
11 changes: 11 additions & 0 deletions LIReC/jobs/job_poly_pslq_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
If present, no anti-relation logging can happen. Currently supported:
'PcfCanonical': 'balanced_only' filters to only PCFs of balanced degrees if set to True.
'''
import json
import mpmath as mp
import os
from itertools import combinations, product
Expand Down Expand Up @@ -84,6 +85,10 @@ def setup_logging():

logger = setup_logging()

def write_results_to_file(results, filename):
"""Writes results to a JSON file."""
with open(filename, 'w') as f:
json.dump(results, f, indent=4)

def get_filters(filters, const_type):
filter_list = list(FILTERS) # copy!
Expand Down Expand Up @@ -152,6 +157,7 @@ def run_query(filters=None, degree=None, order=None, bulk=None):
return results

def execute_job(query_data, filters=None, degree=None, order=None, bulk=None, manual=False):
results = []
try: # whole thing must be wrapped so it gets logged
#configure_logger('analyze_pcfs' if manual else f'pslq_const_worker_{getpid()}')
i, total_cores, query_data = query_data # SEND_INDEX = True guarantees this
Expand Down Expand Up @@ -224,15 +230,19 @@ def execute_job(query_data, filters=None, degree=None, order=None, bulk=None, ma
if not combination_is_old(consts, degree, order, old_relations):
# some leeway with the extra 10 precision
new_relations = [r for r in check_consts(consts, degree, order, test_prec) if r.precision > PRECISION_RATIO * min(c.precision for c in r.constants) - 10]
logger.info(f'Found new relation(s) on constants {[c.orig.const_id for c in consts]} with details: {new_relations}')

if new_relations:
logging.info(f'Found relation(s) on constants {[c.orig.const_id for c in consts]}!')
logger.info(f'Found relation(s) on constants {[c.orig.const_id for c in consts]}!')
try_count = 1
results.extend(new_relations) #1
while try_count < 3:
try:
db.session.add_all([to_db_format(r) for r in new_relations])
db.session.commit()
old_relations += new_relations
#results.extend(new_relations) #2 ask itay when to add results to json
break
except:
db.session.rollback()
Expand All @@ -250,6 +260,7 @@ def execute_job(query_data, filters=None, degree=None, order=None, bulk=None, ma
# cf.scanned_algo = dict()
# cf.scanned_algo[ALGORITHM_NAME] = int(time())
#db.session.add_all(consts)
write_results_to_file(results, 'output.json')
logging.info(f'finished - found {len(old_relations) - orig_size} results')
logger.info(f'finished - found {len(old_relations) - orig_size} results')
db.session.close()
Expand Down
6 changes: 3 additions & 3 deletions LIReC/jobs/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def main() -> None:


# Read from stdin if any data is present
stdin_data = sys.stdin.readline().strip()
if stdin_data:
logger.info(f"Received via stdin: {stdin_data}")
# stdin_data = sys.stdin.readline().strip()
# if stdin_data:
# logger.info(f"Received via stdin: {stdin_data}")

# Log to both file and stderr
logger.info("logger.info Running run.main()")
Expand Down

0 comments on commit 7bc4a4a

Please sign in to comment.