Skip to content

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

Closed
@hartikainen

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?

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