Skip to content

Commit

Permalink
Read and authenticate with credentials from password file when starti…
Browse files Browse the repository at this point in the history
…ng Slurm worker manager (#4125)

* Read and authenticate with credentials from password file when starting Slurm worker manager

* clarify
  • Loading branch information
teetone authored Jun 5, 2022
1 parent ed58812 commit c0c362c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions codalab/worker_manager/slurm_batch_worker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid
import subprocess
import getpass
import os
import re
import sys
import textwrap
Expand Down Expand Up @@ -108,6 +109,18 @@ def __init__(self, args):
# A set of newly submitted job id to keep tracking worker status, as worker might not be created right away.
self.submitted_jobs = self.load_worker_jobs()

# We're using a temporary CodaLabManager for the worker and worker managers by default,
# so we don't write out the state to state.json when users log in.
# If we always read from the password file, we can both leave state.json untouched,
# and users can always start the worker manager without logging in.
if args.password_file:
logger.info(
f"--password-file specified. Reading credentials from {args.password_file}..."
)
with open(args.password_file) as f:
os.environ["CODALAB_USERNAME"] = f.readline().strip()
os.environ["CODALAB_PASSWORD"] = f.readline().strip()

def load_worker_jobs(self):
"""
Load worker jobs that are created using SlurmWorkerManager and
Expand Down

0 comments on commit c0c362c

Please sign in to comment.