Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
24 changes: 24 additions & 0 deletions python/ray/tune/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
except subprocess.CalledProcessError:
TERM_HEIGHT, TERM_WIDTH = 100, 100

EDITOR = os.getenv('EDITOR', 'vim')


def _check_tabulate():
"""Checks whether tabulate is installed."""
Expand Down Expand Up @@ -230,3 +232,25 @@ def list_experiments(project_path,
info_df = info_df.sort_values(by=sort)

print_format_output(info_df)


def add_note(path, filename="note.txt"):
"""Opens a txt file at the given path where user can add and save notes.

Args:
path (str): Directory where note will be saved.
filename (str): Name of note. Defaults to "note.txt"
"""
path = os.path.expanduser(path)
if not os.path.isdir(path):
print("{} is not a valid directory.".format(path))
sys.exit(0)

filepath = os.path.join(path, filename)
exists = os.path.isfile(filepath)

subprocess.call([EDITOR, filepath])
if exists:
print("Note updated at:", filepath)
else:
print("Note created at:", filepath)
13 changes: 13 additions & 0 deletions python/ray/tune/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,23 @@ def list_experiments(project_path, sort):
commands.list_experiments(project_path, sort)


@cli.command()
@click.argument("path", required=True, type=str)
@click.option(
'--filename',
Comment thread
andrewztan marked this conversation as resolved.
Outdated
default="note.txt",
type=str,
help='Specify filename for note.')
def add_note(path, filename):
"""Adds user notes as a text file at the given path."""
commands.add_note(path, filename)


cli.add_command(list_trials, name="ls")
cli.add_command(list_trials, name="list-trials")
cli.add_command(list_experiments, name="lsx")
cli.add_command(list_experiments, name="list-experiments")
cli.add_command(add_note, name="add-note")


def main():
Expand Down