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

Add on_time_limit email notification #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ cluster = SlurmCluster(
python_cmd='python3'
)

# let the cluster know where to email for a change in job status (ie: complete, fail, etc...)
cluster.notify_job_status(email='[email protected]', on_done=True, on_fail=True)
# let the cluster know where to email for a change in job status (ie: complete, fail, time limit reached, etc...)
cluster.notify_job_status(email='[email protected]', on_done=True, on_fail=True, on_time_limit=True)

# set the job options. In this instance, we'll run 20 different models
# each with its own set of hyperparameters giving each one 1 GPU (ie: taking up 20 GPUs)
Expand Down
11 changes: 6 additions & 5 deletions docs/hpc/SlurmCluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ cluster = SlurmCluster(
python_cmd='python3'
)

# let the cluster know where to email for a change in job status (ie: complete, fail, etc...)
cluster.notify_job_status(email='[email protected]', on_done=True, on_fail=True)
# let the cluster know where to email for a change in job status (ie: complete, fail, time limit reached, etc...)
cluster.notify_job_status(email='[email protected]', on_done=True, on_fail=True, on_time_limit=True)

# set the job options. In this instance, we'll run 20 different models
# each with its own set of hyperparameters giving each one 1 GPU (ie: taking up 20 GPUs)
Expand Down Expand Up @@ -254,20 +254,21 @@ cluster.load_modules([
### `notify_job_status`

``` {.python}
cluster.notify_job_status(email, on_done, on_fail)
cluster.notify_job_status(email, on_done, on_fail, on_time_limit)
```

Loads modules needed to run the job. Your Slurm documentation should have a list of available modules. You can also get those by running ```module avail```.

- ```email``` String. Email address to get notifications.
- ```on_done``` Boolean. If true, you'll get an email when the job completes.
- ```on_fail``` Boolean. If true, you'll get an email if the job fails.
- ```on_fail``` Boolean. If true, you'll get an email if the job fails.
- ```on_time_limit``` Boolean. If true, you'll get an email if the job is stopped for exceeding its time limit.

**Example**


``` {.python}
cluster.notify_job_status(email='[email protected]', on_done=True, on_fail=True)
cluster.notify_job_status(email='[email protected]', on_done=True, on_fail=True, on_time_limit=True)
```

### `optimize_parallel_cluster_gpu`
Expand Down
2 changes: 1 addition & 1 deletion examples/hpc_cpu_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def train(hparams, *args):

# Email results if your hpc supports it.
cluster.notify_job_status(
email='[email protected]', on_done=True, on_fail=True)
email='[email protected]', on_done=True, on_fail=True, on_time_limit=True)

# SLURM Module to load.
cluster.load_modules([
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch_hpc_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def train(hparams, *args):

# Email results if your hpc supports it.
cluster.notify_job_status(
email='[email protected]', on_done=True, on_fail=True)
email='[email protected]', on_done=True, on_fail=True, on_time_limit=True)

# SLURM Module to load.
cluster.load_modules([
Expand Down
6 changes: 5 additions & 1 deletion test_tube/hpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(
self.email = None
self.notify_on_end = False
self.notify_on_fail = False
self.notify_on_time_limit = False
self.job_name = None
self.python_cmd = python_cmd
self.gpu_type = None
Expand Down Expand Up @@ -96,10 +97,11 @@ def add_command(self, cmd):
def load_modules(self, modules):
self.modules = modules

def notify_job_status(self, email, on_done, on_fail):
def notify_job_status(self, email, on_done, on_fail, on_time_limit):
self.email = email
self.notify_on_end = on_done
self.notify_on_fail = on_fail
self.notify_on_time_limit = on_time_limit

def optimize_parallel_cluster(self, train_function, nb_trials, job_name):
raise NotImplementedError
Expand Down Expand Up @@ -460,6 +462,8 @@ def __build_slurm_command(self, trial, slurm_cmd_script_path, timestamp, exp_i,
mail_type.append('END')
if self.notify_on_fail:
mail_type.append('FAIL')
if self.notify_on_time_limit:
mail_type.append('TIME_LIMIT')
if len(mail_type) > 0:
mail_type_query = [
'# Have SLURM send you an email when the job ends or fails',
Expand Down