Skip to content

[WIP] Enable all Windows runtime env tests - #22186

Closed
architkulkarni wants to merge 5 commits into
ray-project:masterfrom
architkulkarni:enable-all-win-runtime-env-tests
Closed

architkulkarni wants to merge 5 commits into
ray-project:masterfrom
architkulkarni:enable-all-win-runtime-env-tests

Conversation

@architkulkarni

@architkulkarni architkulkarni commented Feb 7, 2022 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

This PR is just to trigger a Windows CI run with all the runtime_env tests enabled, to get an idea of what's currently not working on Windows.

Related issue number

Checks

@architkulkarni architkulkarni added the do-not-merge Do not merge this PR! label Feb 7, 2022
@architkulkarni architkulkarni changed the title [WIP] Enable all win runtime env tests [WIP] Enable all Windows runtime env tests Feb 7, 2022
@pcmoritz pcmoritz added the QS label Feb 10, 2022
@pcmoritz

Copy link
Copy Markdown
Contributor

Maybe @czgdp1807 and @mattip can help with activating these tests?

"Windows."
)
elif isinstance(conda, str):
if isinstance(conda, str):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Has this been changed upstream so that the conda field is now supported?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the lack of context for this PR--I just wanted to enable all the tests to see which ones were broken. I'm currently going through the tests to see what we can learn from the test output.

Nothing has changed upstream for conda and pip, but I wanted to see if or how it would fail on Windows since it hasn't been tested. I'm not an expert but I think the only potential compatibility problem might be in the parts where we call into the command line for conda create, conda activate, pip install and so on, since the windows shell is different from bash which we have on MacOS and Linux.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

A lot of tests were skipped with "fail to create tmp dir"; I wonder if these can be fixed by using the pytest tmpdir fixture. I also found some lines in the tests like https://buildkite.com/ray-project/ray-builders-pr/builds/23946#a57060c9-fc8f-4fe6-b509-7f99afe842c5/3206-8106 tmp_path = archive_path[: archive_path.rfind("/")] which seem to depend on paths using forward slashes and not back slashes, which we can probably fix by using an appropriate library to deal with paths.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

@mattip Have you seen something like this before where a test file "passes" in 3 seconds? E.g. here //python/ray/tests:test_runtime_env_working_dir_remote_uri:Test execution time (3.1s excluding execution overhead) outside of range for LONG tests. Consider setting timeout="short" or size="small".

I'm pretty sure this means the test file was skipped for Windows, but I couldn't find anywhere in the code that was indicating that it should be skipped, so I'm not sure how to un-skip it.

@czgdp1807

Copy link
Copy Markdown
Contributor

Have you seen something like this before where a test file "passes" in 3 seconds?

Let me try executing it locally.

@czgdp1807

czgdp1807 commented Feb 11, 2022 •

Copy link
Copy Markdown
Contributor

Well, all the cluster tests are globally enable or disabled via the following flag. When you set cluster_not_supported = False, then the above tests will run properly. I faced a similar problem in #22208 (see diff).

https://github.com/architkulkarni/ray/blob/fb8f8c4935de7112152e7b0ac8421d5ce33aa7cd/python/ray/cluster_utils.py#L19

P.S. An error which I noticed after setting the above flag to False.

― test_remote_package_uri[ray_client-True-py_modules-s3://runtime-env-test/test_runtime_env.zip] ―

start_cluster = (<ray.cluster_utils.Cluster object at 0x0000014D5E5CC3D0>, 'ray://localhost:10004')
remote_uri = 's3://runtime-env-test/test_runtime_env.zip', option = 'py_modules'
per_task_actor = True

    @pytest.mark.parametrize("remote_uri", REMOTE_URIS)
    @pytest.mark.parametrize("option", ["failure", "working_dir", "py_modules"])
    @pytest.mark.parametrize("per_task_actor", [True, False])
    def test_remote_package_uri(start_cluster, remote_uri, option, per_task_actor):
        """Tests the case where we lazily read files or import inside a task/actor.

        In this case, the files come from a remote location.

        This tests both that this fails *without* the working_dir and that it
        passes with it.
        """
        cluster, address = start_cluster

        if option == "working_dir":
            env = {"working_dir": remote_uri}
        elif option == "py_modules":
            env = {"py_modules": [remote_uri]}

        if option == "failure" or per_task_actor:
            ray.init(address)
        else:
            ray.init(address, runtime_env=env)

        @ray.remote
        def test_import():
            import test_module

            return test_module.one()

        if option != "failure" and per_task_actor:
            test_import = test_import.options(runtime_env=env)

        if option == "failure":
            with pytest.raises(ImportError):
                ray.get(test_import.remote())
        else:
>           assert ray.get(test_import.remote()) == 2

python\ray\tests\test_runtime_env_working_dir_remote_uri.py:59:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python\ray\_private\client_mode_hook.py:104: in wrapper
    return getattr(ray, func.__name__)(*args, **kwargs)
python\ray\util\client\api.py:43: in get
    return self.worker.get(vals, timeout=timeout)
python\ray\util\client\worker.py:384: in get
    res = self._get(to_get, op_timeout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <ray.util.client.worker.Worker object at 0x0000014D5E541610>
ref = [ClientObjectRef(16310a0f0a45af5cffffffffffffffffffffffff0100000001000000)], timeout = 2.0

    def _get(self, ref: List[ClientObjectRef], timeout: float):
        req = ray_client_pb2.GetRequest(ids=[r.id for r in ref], timeout=timeout)
        try:
            resp = self._call_stub("GetObject", req, metadata=self.metadata)
        except grpc.RpcError as e:
            raise decode_exception(e)
        if not resp.valid:
            try:
                err = cloudpickle.loads(resp.error)
            except (pickle.UnpicklingError, TypeError):
                logger.exception("Failed to deserialize {}".format(resp.error))
                raise
>           raise err
E           ray.exceptions.RuntimeEnvSetupError: Failed to setup runtime environment.
E           Failed to create runtime env {"pythonRuntimeEnv":{"pyModules":["s3://runtime-env-test/test_runtime_env.zip"]},"uris":{"pyModulesUris":["s3://runtime-env-test/test_runtime_env.zip"]}}.
E           Unable to locate credentials

python\ray\util\client\worker.py:412: RuntimeEnvSetupError

@mattip

mattip commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

which we can probably fix by using an appropriate library to deal with paths.

The canonical way to deal with this is os.path.sep which is '/' on posix, '\' on windows

@mattip

mattip commented Feb 13, 2022

Copy link
Copy Markdown
Contributor

I fixed (and unskipped) some of the tests unskipped here in #22342.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

@mattip Thank you so much! I'll review that PR.

@czgdp1807 regarding the credential missing issue, let me find out how the S3 credentials are set up on the current Linux machines and see if we can set up something similar in the Windows CI.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

@czgdp1807 So it turns out the S3 bucket used by the test is public, and in order to access it you just need to have some AWS credentials set up (any credentials will do). I'm not sure how to set up AWS credentials on the Windows CI, do you happen to know how? If not I can ask for help.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

For more context on my recent commits on this PR adding the "post-wheel-build tests":

Currently the runtime_env conda feature automatically injects the currently running Ray version into the user-provided conda environment.yml spec. This means inserting a pip specifier for the current Ray version, which is ray==1.10.0 for a stable version, or a link to a nightly wheel file on S3 if the user is running the Ray nightly.

The problem is when running the test in CI, the build from the PR doesn't match any existing wheel on PyPI or S3. So to work around this, we have the following:

if os.environ.get("RAY_CI_POST_WHEEL_TESTS"):
# Running in Buildkite CI after the wheel has been built.
# Wheels are at in the ray/.whl directory, but use relative path to
# allow for testing locally if needed.
return os.path.join(
Path(ray.__file__).resolve().parents[2], ".whl", get_wheel_filename()
)

In the Linux "post-wheel" tests we build a Ray wheel from the PR and store it locally on the CI machine, and when running the conda tests in CI we insert the local path to the build wheel file as part of the conda spec.

Right now the newly-added post-wheel-build Windows tests are failing with some numpy import issue, still trying to figure that out.

@czgdp1807

Copy link
Copy Markdown
Contributor

I'm not sure how to set up AWS credentials on the Windows CI, do you happen to know how? If not I can ask for help.

I don't have any idea about setting up AWS credentials on Windows CI. We can use some help here.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

@czgdp1807 Was the credentials error you posted from running the test locally on your Windows machine, or was it from Windows CI?

@czgdp1807

Copy link
Copy Markdown
Contributor

Was the credentials error you posted from running the test locally on your Windows machine

It's locally from my Windows machine. Though now I think this error makes sense locally, right? I am not sure if the same thing happens on CI.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

Was the credentials error you posted from running the test locally on your Windows machine

It's locally from my Windows machine. Though now I think this error makes sense locally, right? I am not sure if the same thing happens on CI.

Oh yeah, makes sense! So to run it locally, you just need some AWS credentials set (any AWS credentials will work).
I'll check the actual Windows CI to see if it passed.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

@mattip Thanks for the work on fixing the paths, test_runtime_env and test_runtime_env_complicated! That covers a lot of the fundamental use cases.

There are some remainingtest_runtime_env_* tests.

One issue is that some tests are "passing" in 3s (so not actually running), as mentioned above and it looks like @czgdp1807 has an idea about how to fix this using cluster_not_supported.

The other issue is that individual tests within the files are skipped on Windows.

How would it be best to track this, should we create github issues and tag with windows and QS?

@mattip

mattip commented Mar 9, 2022 •

Copy link
Copy Markdown
Contributor

Once we get the basic conda scripts working, it should be easy to enable the tests. Right now I have a problem on the branch for #22449 that running the following opens a large number of processes all running exactly the same conda create env --file .. command, which on windows cannot succeed since they try to write to the same location

ray.init(num_cpu=1)

@ray.remote
def f():
    pass
ray.get(f.options(runtime_env={'conda': {'dependencies': ['package-that-doesnt-exist']}}).remote())

This results in ~4 processes running over and over again


@mattip

mattip commented Mar 9, 2022

Copy link
Copy Markdown
Contributor

It seems the agent is timing out? I see this in the raylet.out log

[2022-03-09 18:03:17,780 W 5324 15696] (raylet.exe) agent_manager.cc:92: Agent process with pid 17776 has not registered, restart it. ip 127.0.0.1. pid 17904
[2022-03-09 18:03:17,782 W 5324 17552] (raylet.exe) agent_manager.cc:102: Agent process with pid 17776 exit, return value 1067. ip 127.0.0.1. pid 17904
[2022-03-09 18:03:17,783 I 5324 15696] (raylet.exe) agent_manager.cc:216: Failed to create the runtime env: {"extensions": {"_ray_commit": "{{RAY_COMMIT_SHA}}"}, "pythonRuntimeEnv": {"condaRuntimeEnv": {"config": "{\"dependencies\": [\"package-that-doesnt-exist\"]}"}}, "uris": {"condaUri": "conda://734b4a8ae2e056c7ddc0b0778e4a2ee917d73c51"}}, status = GrpcUnknown: RPC Error message: Stream removed; RPC Error details: , maybe there are some network problems, will retry it later.
[2022-03-09 18:03:19,798 I 5324 6224] (raylet.exe) agent_manager.cc:86: Monitor agent process with pid 12804, register timeout 30000ms.
[2022-03-09 18:03:21,156 I 5324 15696] (raylet.exe) agent_manager.cc:216: Failed to create the runtime env: {"extensions": {"_ray_commit": "{{RAY_COMMIT_SHA}}"}, "pythonRuntimeEnv": {"condaRuntimeEnv": {"config": "{\"dependencies\": [\"package-that-doesnt-exist\"]}"}}, "uris": {"condaUri": "conda://734b4a8ae2e056c7ddc0b0778e4a2ee917d73c51"}}, status = GrpcUnknown: RPC Error message: Method not found!; RPC Error details: , maybe there are some network problems, will retry it later.
[2022-03-09 18:03:21,159 I 5324 15696] (raylet.exe) agent_manager.cc:37: HandleRegisterAgent, ip: 127.0.0.1, port: 63484, pid: 428
[2022-03-09 18:03:49,796 W 5324 15696] (raylet.exe) agent_manager.cc:92: Agent process with pid 12804 has not registered, restart it. ip 127.0.0.1. pid 428
[2022-03-09 18:03:49,797 W 5324 6224] (raylet.exe) agent_manager.cc:102: Agent process with pid 12804 exit, return value 1067. ip 127.0.0.1. pid 428
[2022-03-09 18:03:49,798 I 5324 15696] (raylet.exe) agent_manager.cc:216: Failed to create the runtime env: {"extensions": {"_ray_commit": "{{RAY_COMMIT_SHA}}"}, "pythonRuntimeEnv": {"condaRuntimeEnv": {"config": "{\"dependencies\": [\"package-that-doesnt-exist\"]}"}}, "uris": {"condaUri": "conda://734b4a8ae2e056c7ddc0b0778e4a2ee917d73c51"}}, status = GrpcUnknown: RPC Error message: Stream removed; RPC Error details: , maybe there are some network problems, will retry it later.

@mattip

mattip commented Mar 9, 2022

Copy link
Copy Markdown
Contributor

Got it: I needed to increase the agent_register_timeout_ms on windows to 60 secs. I will propose making the default larger on windows.

@architkulkarni

Copy link
Copy Markdown
Contributor Author

Got it: I needed to increase the agent_register_timeout_ms on windows to 60 secs. I will propose making the default larger on windows.

Oh wow, great find! I was pretty confused.

@stale

stale Bot commented Apr 9, 2022

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

  • If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@stale stale Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Apr 9, 2022
@stale

stale Bot commented Apr 23, 2022

Copy link
Copy Markdown

Hi again! The issue will be closed because there has been no more activity in the 14 days since the last message.

Please feel free to reopen or open a new issue if you'd still like it to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for opening the issue!

@stale stale Bot closed this Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Do not merge this PR! stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants