Get Started
Welcome to Anyscale, the infinite laptop!
Welcome to the Anyscale platform! We are glad to have you on board! This quickstart assumes

Remote "Hello, World" from scratch

    Open a shell and navigate to an empty directory.
    Install Ray and Anyscale:
      pip install "ray[default]"
      pip install anyscale
Note: If you have any issues with this step, you'll want to go back and ensure you have a good python environment. Some developers prefer to select a specific version of ray (pip install "ray[default]"==1.6.0)
    If you are the first person in your organization to use Anyscale, configure your cloud. All subsequent users of the platform can use the cloud that you've set up in this step.
    Initialize this directory as an Anyscale project:
      anyscale init --name helloworld
    Run a Python script to connect and get Anyscale to print "Hello, World" for you. Save the following as hello.py in your working directory and run it with python hello.py.
import ray
import anyscale
def say_hi(message):
return f"Hello, {message}."

What happened?

In this example, you have exercised the fundamentals of distributed computing, and used Anyscale, to direct your AWS cloud, to do it.
    @ray.remote tells Python that the annotated function is to be run on a Ray cluster.
    say_hi is a function which returns its single argument appended to a friendly greeting. Since it is annotated with @ray.remote, you have to call it as a remote function.
    ray.init("anyscale://hello_cluster") initiates the connection to a Ray cluster managed by Anyscale. A Ray client's connection string begins with anyscale:// for all clusters managed by Anyscale. This example creates or uses a cluster called hello_cluster; if the cluster does not exist, it will be created and subsequent attempts to connect will re-use this cluster.
    The last line of the script invokes the remote function and prints its output. say_hi.remote("World") creates a non-blocking function call, which ray.get(...) subsequently waits for and returns. In between, Ray and Anyscale have marshalled the resources to compute the result of this function.
    The script authenticated automatically via one of two methods. A script connecting to Anyscale will read a token from the ANYSCALE_CLI_TOKEN environment variable, or if that variable is not set, will look at the user's credentials file at ~/.anyscale/credentials.json. If neither method succeeds to authenticate, then Anyscale refuses to run the script.

Why does it matter?

The example remote function above is not practical; it takes longer to run in the cloud than it would locally. To realize the potential of Anyscale and Ray, you'll find yourself heading in the following directions:
    More complex non-blocking functions show how Ray parallelizes and sequences tasks for high utilization.
    Actors encapsulate functionality into distributed and scalable stateful objects.
    Long running API servers, implemented as Actors, provide replicated endpoints for high-volume API calls.
    Distributed iterators and data structures provide parallel abstractions over pythonic idioms.
    Higher-level libraries like Ray Tune or RLlib leverage Ray under the hood to provide parallelization without coding it at all.

Next Steps

    Learn some Anyscale concepts more deeply.
    Check out the Ray documentation. The Ray client (since Ray 1.4) in OSS interacts with Ray clusters the same way that it does when connecting to Anyscale, so any project you've written for Ray will also work on the Anyscale platform.
Last modified 11d ago