Skip to content

Commit

Permalink
docstring for Batch (#780)
Browse files Browse the repository at this point in the history
update grid and util for sge
  • Loading branch information
jchen6727 authored Oct 19, 2023
1 parent f013bc9 commit 2b58255
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
43 changes: 38 additions & 5 deletions netpyne/batch/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,38 @@ def tupleToStr(obj):
# -------------------------------------------------------------------------------
class Batch(object):
"""
Class for/to <short description of `netpyne.batch.batch.Batch`>
Class that handles batch simulations on NetPyNE.
Relevant Attributes:
batchLabel : str
The label of the batch used for directory/file naming of batch generated files.
cfgFile : str
The path of the file containing the `netpyne.simConfig.SimConfig` object
cfg : `netpyne.simConfig.SimConfig`
The `netpyne.simConfig.SimConfig` object
N.B. either cfg or cfgFile should be specified #TODO: replace with typechecked single argument
netParamsFile : str
The path of the file containing the `netpyne.netParams.NetParams` object
netParams : `netpyne.netParams.NetParams`
The `netpyne.netParams.NetParams` object
N.B. either netParams or netParamsFile should be specified #TODO: replace with typechecked single argument
initCfg : dict
params dictionary that is used to modify the batch cfg prior to any algorithm based parameter modifications
saveFolder : str
The path of the folder where the batch will be saved (defaults to batchLabel)
method : str
The algorithm method used for batch
runCfg : dict
Keyword: Arg dictionary used to generate submission templates (see utils.py)
evolCfg : dict #TODO: replace with algoCfg? to merge with optimCfg
Keyword: Arg dictionary used to define evolutionary algorithm parameters (see evol.py)
optimCfg : dict #TODO: replace with algoCfg? to merge with evolCfg
Keyword: Arg dictionary used to define optimization algorithm parameters
(see asd_parallel.py, optuna_parallel.py, sbi_parallel.py)
params : list
Dictionary of parameters to be explored per algorithm (grid, evol, asd, optuna, sbi)
(see relevant algorithm script for details)
seed : int
Seed for random number generator for some algorithms
"""

def __init__(
Expand All @@ -88,19 +117,23 @@ def __init__(
netParams=None,
params=None,
groupedParams=None,
initCfg={},
initCfg=None,
seed=None,
):
self.batchLabel = 'batch_' + str(datetime.date.today())
self.cfgFile = cfgFile
self.cfg = cfg
self.netParams = netParams
self.initCfg = initCfg
if initCfg:
self.initCfg = initCfg
else:
self.initCfg = {}
self.netParamsFile = netParamsFile
self.saveFolder = '/' + self.batchLabel
self.method = 'grid'
self.runCfg = {}
self.evolCfg = {}
self.optimCfg = {}
self.params = []
self.seed = seed
if params:
Expand Down
4 changes: 2 additions & 2 deletions netpyne/batch/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def gridSubmit(batch, pc, netParamsSavePath, jobName, simLabel, processes, proce
'walltime': walltime,
'vmem': '32G',
'queueName': 'cpu.q',
'cores': 1,
'cores': 2,
'pre': '', 'post': '',
'mpiCommand': 'mpiexec',
#'log': "~/qsub/{}".format(jobName)
Expand All @@ -350,7 +350,7 @@ def gridSubmit(batch, pc, netParamsSavePath, jobName, simLabel, processes, proce
sge_args.update(batch.runCfg)

#(batch, pc, netParamsSavePath, jobName, simLabel, processes, processFiles):
sge_args['command'] = '%s -n $NSLOTS nrniv -python -mpi %s simConfig=%s netParams=%s' % (
sge_args['command'] = '%s -n $NSLOTS -hosts $(hostname) nrniv -python -mpi %s simConfig=%s netParams=%s' % (
sge_args['mpiCommand'],
script,
cfgSavePath,
Expand Down
2 changes: 2 additions & 0 deletions netpyne/batch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ def jobPathAndNameForCand(index):
elif type == 'hpc_sge':
executer = 'qsub'
queueName = args.get('queueName', 'default')
command = '%s -n $NSLOTS -hosts $(hostname) %s -python -mpi %s simConfig=%s netParams=%s' % (
mpiCommand, nrnCommand, script, cfgSavePath, netParamsSavePath)
jobString = jobStringHPCSGE(
jobName, walltime, queueName, nodes, coresPerNode, jobPath, custom, command
)
Expand Down

0 comments on commit 2b58255

Please sign in to comment.