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

[tune] Simplify experiment tag formatting, clean directory names #23672

Merged
merged 4 commits into from
Apr 4, 2022

Conversation

krfricke
Copy link
Contributor

@krfricke krfricke commented Apr 2, 2022

Why are these changes needed?

Experiment tags are not always rendered in a sane way for all operating systems. For instance, a config of

            "a": tune.choice([(3, 4), (5, 6)]),
            "b": tune.choice([[7, 8], [6, 5]]),

will lead to an experiment dir like lambda_53737_00000_0_a=_3, 4_,b=[7, 8]_2022-04-02_10-21-27/. This can lead to problems with utilities such as gsutil (which misinterprets some characters as wildcards, see #23670), but also with e.g. MacOS which doesn't like [ brackets in filenames.

This PR adds an improvement to the _clean_value function used to sanitize values. We specify a valid alphabet which includes a limited set of characters that is broadly usable in most operating systems. We also simplify the format_vars function - even though it was previously a bit more sophisticated in handling list items, this was error-prone, and can be replaced in favor of a better readable and simpler implementation that yields the same results in almost all cases.

Related issue number

Closes #23670

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

if isinstance(value, float):
return "{:.5}".format(value)
return f"{value:.4f}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 should be enough

Copy link
Member

@Yard1 Yard1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@krfricke krfricke merged commit 7e0c63a into ray-project:master Apr 4, 2022
@krfricke krfricke deleted the tune/trial-dirname branch April 4, 2022 15:05
edoakes pushed a commit to edoakes/ray that referenced this pull request Apr 7, 2022
…-project#23672)

Experiment tags are not always rendered in a sane way for all operating systems. For instance,  a config of

```
            "a": tune.choice([(3, 4), (5, 6)]),
            "b": tune.choice([[7, 8], [6, 5]]),
```

will lead to an experiment dir like `lambda_53737_00000_0_a=_3, 4_,b=[7, 8]_2022-04-02_10-21-27/`. This can lead to problems with utilities such as gsutil (which misinterprets some characters as wildcards, see ray-project#23670), but also with e.g. MacOS which doesn't like `[` brackets in filenames. 

This PR adds an improvement to the `_clean_value` function used to sanitize values. We specify a valid alphabet which includes a limited set of characters that is broadly usable in most operating systems. We also simplify the `format_vars` function - even though it was previously a bit more sophisticated in handling list items, this was error-prone, and can be replaced in favor of a better readable and simpler implementation that yields the same results in almost all cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] gsutil cannot use wildcards - some hyperparameters are problematic
3 participants