Skip to content

Commit

Permalink
Allow calling script from arbitrary location
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Seitzer committed Mar 28, 2018
1 parent 64f43b2 commit b990cf0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 7 additions & 1 deletion gpu_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
# Default timeout in seconds after which remote commands are interrupted
DEFAULT_CMD_TIMEOUT = 10

# Default server file
DEFAULT_SERVER_FILE = 'servers.txt'
SERVER_FILE_PATH = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
DEFAULT_SERVER_FILE)

parser = argparse.ArgumentParser(description='Check state of GPU servers')
parser.add_argument('-v', '--verbose', action='store_true',
help='Be verbose')
Expand All @@ -37,7 +42,7 @@
parser.add_argument('--cmd-timeout', default=DEFAULT_CMD_TIMEOUT,
help=('Timeout in seconds after which nvidia-smi '
'is interrupted'))
parser.add_argument('--server-file', default='servers.txt',
parser.add_argument('--server-file', default=SERVER_FILE_PATH,
help='File with addresses of servers to check')
parser.add_argument('servers', nargs='*', default=[],
help='Servers to probe')
Expand Down Expand Up @@ -225,6 +230,7 @@ def main(argv):

if len(args.servers) == 0:
try:
debug('Using server file {}'.format(args.server_file))
with open(args.server_file, 'r') as f:
servers = (s.strip() for s in f.readlines())
args.servers = [s for s in servers if s != '']
Expand Down
1 change: 0 additions & 1 deletion servers.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

0 comments on commit b990cf0

Please sign in to comment.