Skip to content

Commit

Permalink
[tune] Add documentation to --output flag (ray-project#4518)
Browse files Browse the repository at this point in the history
## What do these changes do?

Add documentation for the `--output` flag for ls / lsx in the Tune CLI.

## Related issue number

Closes ray-project#4511 

## Linter

- [x] I've run `scripts/format.sh` to lint the changes in this PR.
  • Loading branch information
andrewztan authored and richardliaw committed Apr 5, 2019
1 parent 50b2aa0 commit bfd0af5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
14 changes: 10 additions & 4 deletions doc/source/tune-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,11 @@ Tune CLI (Experimental)
Here are a few examples of command line calls.

- ``tune list-trials``: List tabular information about trials within an experiment. Add the ``--sort`` flag to sort the output by specific columns. Add the ``--filter`` flag to filter the output in the format ``"<column> <operator> <value>"``.
- ``tune list-trials``: List tabular information about trials within an experiment. Empty columns will be dropped by default. Add the ``--sort`` flag to sort the output by specific columns. Add the ``--filter`` flag to filter the output in the format ``"<column> <operator> <value>"``. Add the ``--output`` flag to write the trial information to a specific file (CSV or Pickle).

.. code-block:: bash
$ tune list-trials [EXPERIMENT_DIR]
$ tune list-trials [EXPERIMENT_DIR] --output note.csv
+------------------+-----------------------+------------+
| trainable_name | experiment_tag | trial_id |
Expand All @@ -481,6 +481,8 @@ Here are a few examples of command line calls.
| MyTrainableClass | 4_height=90,width=69 | ae4e02fb |
+------------------+-----------------------+------------+
Dropped columns: ['status', 'last_update_time']
Please increase your terminal size to view remaining columns.
Output saved at: note.csv
$ tune list-trials [EXPERIMENT_DIR] --filter "trial_id == 7b99a28a"
Expand All @@ -490,12 +492,13 @@ Here are a few examples of command line calls.
| MyTrainableClass | 3_height=54,width=21 | 7b99a28a |
+------------------+-----------------------+------------+
Dropped columns: ['status', 'last_update_time']
Please increase your terminal size to view remaining columns.
- ``tune list-experiments``: List tabular information about experiments within a project. Add the ``--sort`` flag to sort the output by specific columns. Add the ``--filter`` flag to filter the output in the format ``"<column> <operator> <value>"``.
- ``tune list-experiments``: List tabular information about experiments within a project. Empty columns will be dropped by default. Add the ``--sort`` flag to sort the output by specific columns. Add the ``--filter`` flag to filter the output in the format ``"<column> <operator> <value>"``. Add the ``--output`` flag to write the trial information to a specific file (CSV or Pickle).

.. code-block:: bash
$ tune list-experiments [PROJECT_DIR]
$ tune list-experiments [PROJECT_DIR] --output note.csv
+----------------------+----------------+------------------+---------------------+
| name | total_trials | running_trials | terminated_trials |
Expand All @@ -505,6 +508,8 @@ Here are a few examples of command line calls.
| hyperband_test | 1 | 0 | 1 |
+----------------------+----------------+------------------+---------------------+
Dropped columns: ['error_trials', 'last_updated']
Please increase your terminal size to view remaining columns.
Output saved at: note.csv
$ tune list-experiments [PROJECT_DIR] --filter "total_trials <= 1" --sort name
Expand All @@ -515,6 +520,7 @@ Here are a few examples of command line calls.
| test | 1 | 0 | 0 |
+----------------------+----------------+------------------+---------------------+
Dropped columns: ['error_trials', 'last_updated']
Please increase your terminal size to view remaining columns.
Further Questions or Issues?
Expand Down
15 changes: 6 additions & 9 deletions python/ray/tune/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,14 @@ def list_trials(experiment_path,
print_format_output(checkpoints_df)

if output:
experiment_path = os.path.expanduser(experiment_path)
output_path = os.path.join(experiment_path, output)
file_extension = os.path.splitext(output)[1].lower()
if file_extension in (".p", ".pkl", ".pickle"):
checkpoints_df.to_pickle(output_path)
checkpoints_df.to_pickle(output)
elif file_extension == ".csv":
checkpoints_df.to_csv(output_path, index=False)
checkpoints_df.to_csv(output, index=False)
else:
raise ValueError("Unsupported filetype: {}".format(output))
print("Output saved at:", output_path)
print("Output saved at:", output)


def list_experiments(project_path,
Expand Down Expand Up @@ -295,15 +293,14 @@ def list_experiments(project_path,
print_format_output(info_df)

if output:
output_path = os.path.join(base, output)
file_extension = os.path.splitext(output)[1].lower()
if file_extension in (".p", ".pkl", ".pickle"):
info_df.to_pickle(output_path)
info_df.to_pickle(output)
elif file_extension == ".csv":
info_df.to_csv(output_path, index=False)
info_df.to_csv(output, index=False)
else:
raise ValueError("Unsupported filetype: {}".format(output))
print("Output saved at:", output_path)
print("Output saved at:", output)


def add_note(path, filename="note.txt"):
Expand Down

0 comments on commit bfd0af5

Please sign in to comment.