Skip to content

Commit

Permalink
hard-coded cpus to 2 to test full states report generation
Browse files Browse the repository at this point in the history
  • Loading branch information
popenc committed May 30, 2023
1 parent ec5a348 commit 46197db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion flaskr/.ipynb_checkpoints/utils-checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def p_update_geometry_bounds(day: int, year: int):
cur.execute(query)
objectids = cur.fetchall()

cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
# cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
cpus = 2
pool = mp.Pool(cpus)
logger.info("Running async, cores: {}".format(cpus))
results = {}
Expand Down
6 changes: 4 additions & 2 deletions flaskr/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ def p_set_geometry_tiles(year: int, day: int, objectid: int = None):
features, crs = get_waterbody()
images = get_images(year, day)

cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
# cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
cpus = 2
pool = mp.Pool(cpus)
logger.info("Running async, cores: {}".format(cpus))

Expand Down Expand Up @@ -818,7 +819,8 @@ def set_waterbody_details_table(input_file: str = None):

waterbody_dict = get_waterbody_fids(return_dict=True)

cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
# cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
cpus = 2
pool = mp.Pool(cpus)
fid_dict = {}
j = 500
Expand Down
9 changes: 6 additions & 3 deletions flaskr/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def generate_report(

cpus = 1
if parallel:
cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
# cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
cpus = 2
pool = mp.Pool(cpus)

if group_type == "State":
Expand Down Expand Up @@ -1138,7 +1139,8 @@ def generate_state_reports(year: int, day: int, parallel: bool = True):
# states = [["","MI"], ["","MN"], ["","ND"], ["","TX"], ["","TN"], ["","CO"]]
if parallel:
generate_all_wb_rasters(year=year, day=day, parallel=parallel)
cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
# cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
cpus = 2
pool = mp.Pool(cpus)
states1 = states
results_objects = [
Expand Down Expand Up @@ -1170,7 +1172,8 @@ def generate_alpinelake_report(year: int, day: int, parallel: bool = True):
def generate_all_wb_rasters(year: int, day: int, parallel: bool = True):
objectids = get_waterbody_objectids()
if parallel:
cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
# cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
cpus = 2
pool = mp.Pool(cpus)
results_objects = [pool.apply_async(get_report_waterbody_raster,
kwds={'year': year, 'day': day, 'report_id': "", 'objectid': oid}) for oid
Expand Down
3 changes: 2 additions & 1 deletion flaskr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def p_update_geometry_bounds(day: int, year: int):
cur.execute(query)
objectids = cur.fetchall()

cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
# cpus = mp.cpu_count() - 2 if mp.cpu_count() - 2 >= 2 else mp.cpu_count()
cpus = 2
pool = mp.Pool(cpus)
logger.info("Running async, cores: {}".format(cpus))
results = {}
Expand Down

0 comments on commit 46197db

Please sign in to comment.