Skip to content

[tune] tune.run_experiments local_dir starting with tilde (~) is interpreted as relative path on macOS #2008

Closed

Description

@hartikainen

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS High Sierra 10.13.1
  • Ray installed from (source or binary): pip binary
  • Ray version: 0.4.0
  • Python version: Python 3.6.5 :: Anaconda, Inc.

Describe the problem

The following example considers local_dir to be relative to the directory where I run the script, whereas I believe it should consider it to be in the home directory. As an example, if I run the script in /Users/username/ray_local_dir_test, my results get written into /Users/username/ray_local_dir_test/~/ray_results/my_experiment instead of /Users/username/ray_results as I would expect.

This also confuses the ray.tune.log_sync.get_syncer to not correctly modify the remote_dir and thus all the files are written directly to the upload_dir instead of e.g. upload_dir/upload_dir_test/my_experiment/my_func_0_alpha=0.2,beta=2_2018-05-06_15-13-31lkpz7e9q.

import ray
from ray import tune


def my_func(config, reporter):  # add the reporter parameter
    import time, numpy as np
    i = 0
    while True:
        reporter(timesteps_total=i, mean_accuracy=i ** config['alpha'])
        i += config['beta']
        time.sleep(.01)


tune.register_trainable('my_func', my_func)
ray.init(resources={'cpu': 1})


tune.run_experiments({
    'my_experiment': {
        'run': 'my_func',
        'trial_resources': {'cpu':1},
        'stop': { 'mean_accuracy': 100 },
        'config': {
            'alpha': tune.grid_search([0.2, 0.4]),
            'beta': tune.grid_search([2]),
        },
        'local_dir': '~/ray_results',
    }
})

Happy to submit a PR to fix this. I guess the upload_dir should be run through os.path.expanduser at some point, maybe in Trial.__init__. Does that sound correct?

Activity

  1. changed the title [-]tune.run_experiments local_dir with tilde (~) is interpreted as relative path[/-] [+]tune.run_experiments local_dir with tilde (~) is interpreted as relative path on macOS[/+] on May 6, 2018
  2. changed the title [-]tune.run_experiments local_dir with tilde (~) is interpreted as relative path on macOS[/-] [+]tune.run_experiments local_dir starting with tilde (~) is interpreted as relative path on macOS[/+] on May 6, 2018
  3. changed the title [-]tune.run_experiments local_dir starting with tilde (~) is interpreted as relative path on macOS[/-] [+][tune] tune.run_experiments local_dir starting with tilde (~) is interpreted as relative path on macOS[/+] on May 7, 2018
  4. richardliaw commented on May 7, 2018

    @richardliaw
    Contributor

    @hartikainen expanduser in Trial.init` in line 113 seems to be a right fix for this - would you be willing to submit a PR?

  5. self-assigned this
    on May 7, 2018
  6. hartikainen commented on May 7, 2018

    @hartikainen
    ContributorAuthor

    Thanks @richardliaw. Will do once I get my dev environment running.

  7. richardliaw commented on May 8, 2018

    @richardliaw
    Contributor

    Merged via #2013 - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions