Skip to content

Commit

Permalink
additional command line option for allowing some user control over mu…
Browse files Browse the repository at this point in the history
…ltiprocessing behavior

#210
  • Loading branch information
monocongo committed Nov 18, 2018
1 parent f9d11aa commit 6f98cd9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/process_grid_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from climate_indices import compute, indices

# the number of worker processes we'll use for process pools
_NUMBER_OF_WORKER_PROCESSES = multiprocessing.cpu_count()
_NUMBER_OF_WORKER_PROCESSES = multiprocessing.cpu_count() - 1

# ----------------------------------------------------------------------------------------------------------------------
# set up a basic, global _logger which will write to the console as standard error
Expand Down Expand Up @@ -1122,11 +1122,25 @@ def _prepare_file(netcdf_file, var_name):
help="Base output file path and name for the resulting output files",
required=True,
)
parser.add_argument(
"--multiprocessing",
help="Indices to compute",
choices=["single", "all_but_one", "all"],
required=False,
default="all_but_one",
)
arguments = parser.parse_args()

# validate the arguments
_validate_args(arguments)

if arguments.multiprocessing == "single":
_NUMBER_OF_WORKER_PROCESSES = 1
elif arguments.multiprocessing == "all":
_NUMBER_OF_WORKER_PROCESSES = multiprocessing.cpu_count()
else: # default ("all_but_one")
_NUMBER_OF_WORKER_PROCESSES = multiprocessing.cpu_count() - 1

# compute SPI if specified
if arguments.index in ["spi", "scaled", "all"]:

Expand Down

0 comments on commit 6f98cd9

Please sign in to comment.