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

[WIP] Bug/log syncer fails with parentheses #2653

Merged

Conversation

hartikainen
Copy link
Contributor

@hartikainen hartikainen commented Aug 15, 2018

WIP: Still needs some testing.

What do these changes do?

Changes the rsync command in tune.log_sync to allow special characters to be used in experiment names when logging is turned on.

Related issue number

#2388

@@ -103,11 +111,13 @@ def sync_now(self, force=False):
if not distutils.spawn.find_executable("rsync"):
print("Error: log sync requires rsync to be installed.")
return
source = '{}@{}:{}/'.format(ssh_user, self.worker_ip,
escape_rsync_location(self.local_dir))
target = '{}/'.format(escape_rsync_location(self.local_dir))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if this is ideal or needed. I tested several ways of quoting the local dir without escaping and didn't manage to make it work. Happy to change this if someone has better ideas of how to handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually weird since the log sync definitely worked before with whitespaces and some other special characters. Not sure why the parenthesis caused a problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have some example input / outputs of this with other quoting strategies?

@hartikainen hartikainen changed the title Bug/log syncer fails with parentheses [WIP] Bug/log syncer fails with parentheses Aug 15, 2018
@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7474/
Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/7473/
Test PASSed.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/8566/
Test PASSed.

@hartikainen
Copy link
Contributor Author

hartikainen commented Oct 6, 2018

@ericl Sorry for dropping the ball on this earlier. I looked into this again today, and it looks like adding -s flag to the rsync command (as suggested here) together with the changes suggested by you here solves the problem.

Having:

sync_cmd = ((
    """rsync -avz -e "ssh -i {} -o ConnectTimeout=120s """
    """-o StrictHostKeyChecking=no" {} {} """).format(
            quote(ssh_key), source, target))

I get the following error:

Running log sync: rsync -avz -e "ssh -i /home/ubuntu/ray_bootstrap_key.pem -o ConnectTimeout=120s -o StrictHostKeyChecking=no" 'ubuntu@10.138.0.34:'/home/ubuntu/ray_results/my_experiment/my_func_1_alpha=(0.4, None),beta=2_2018-10-06_04-06-590xhbsymz'/' ''/home/ubuntu/ray_results/my_experiment/my_func_1_alpha=(0.4, None),beta=2_2018-10-06_04-06-590xhbsymz'/'
/bin/sh: 1: Syntax error: "(" unexpected

Adding -s to the rsync:

sync_cmd = ((
    """rsync -savz -e "ssh -i {} -o ConnectTimeout=120s """
    """-o StrictHostKeyChecking=no" {} {} """).format(
            quote(ssh_key), source, target))

I get:

Running log sync: rsync -savz -e "ssh -i /home/ubuntu/ray_bootstrap_key.pem -o ConnectTimeout=120s -o StrictHostKeyChecking=no" 'ubuntu@10.138.0.6:/home/ubuntu/ray_results/my_experiment/my_func_1_alpha=(0.4, None),beta=2_2018-10-06_05-44-258v3bql9m/' '/home/ubuntu/ray_results/my_experiment/my_func_1_alpha=(0.4, None),beta=2_2018-10-06_05-44-258v3bql9m/'
receiving incremental file list
./

sent 27 bytes received 59 bytes 57.33 bytes/sec
total size is 0 speedup is 0.00

And

ubuntu@ray-log-sync-parentheses-test-head-09a4127b:~$ ls -la ~/ray_results/my_experiment/my_func_1_alpha\=\(0.4\,\ None\)\,beta\=2_2018-10-06_05-44-258v3bql9m/
total 244
drwxrwxr-x 2 ubuntu ubuntu   4096 Oct  6 05:44 .
drwxrwxr-x 4 ubuntu ubuntu   4096 Oct  6 05:44 ..
-rw-rw-r-- 1 ubuntu ubuntu     33 Oct  6 05:44 params.json
-rw-rw-r-- 1 ubuntu ubuntu  66747 Oct  6 05:48 progress.csv
-rw-rw-r-- 1 ubuntu ubuntu 156693 Oct  6 05:48 result.json

Here's the script I ran:

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'][0])
        i += config['beta']
        time.sleep(1)


tune.register_trainable('my_func', my_func)
ray.init(redis_address=ray.services.get_node_ip_address() + ':6379')

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

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/8567/
Test PASSed.

Copy link
Contributor

@ericl ericl left a comment

Choose a reason for hiding this comment

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

Ah nice, I didn't know about -s!

@ericl ericl merged commit 2d35a97 into ray-project:master Oct 6, 2018
@hartikainen hartikainen deleted the bug/log-syncer-fails-with-parentheses branch October 7, 2018 20:04
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.

3 participants