Skip to content

Latest commit

 

History

History
118 lines (93 loc) · 4.25 KB

quickstart.mdx

File metadata and controls

118 lines (93 loc) · 4.25 KB
title description icon
Quickstart
This guide helps you set up and get started using Tilebox. It covers how to install a Tilebox client for your preferred language and how to use it to query data from a dataset and run a workflow.
rocket

Select your preferred language and follow the steps below to get started.

## Start in a Notebook

Explore the provided Sample Notebooks to begin your journey with Tilebox. These notebooks offer a step-by-step guide to using the API and showcase many features supported by Tilebox Python clients. You can also use these notebooks as a foundation for your own projects.

Start on Your Device

If you prefer to work locally, follow these steps to get started.

Install the Tilebox Python packages. The easiest way to do this is using `pip`:
  ```
  pip install tilebox-datasets tilebox-workflows tilebox-storage
  ```
</Step>
<Step title="Create an API Key">
  Create an API key by logging into the [Tilebox Console](https://console.tilebox.com), navigating to [Account -> API Keys](https://console.tilebox.com/account/api-keys), and clicking the "Create API Key" button.

  <Frame>
    <img src="/assets/console/api-keys-light.png" alt="Tilebox Console" className="dark:hidden"  />
    <img src="/assets/console/api-keys-dark.png" alt="Tilebox Console" className="hidden dark:block" />
  </Frame>

  <Tip>Copy the API key and keep it somewhere safe. You will need it to authenticate your requests.</Tip>
</Step>
<Step title="Create a Cluster">
  Create a cluster by logging into the [Tilebox Console](https://console.tilebox.com), navigating to [Workflows -> Clusters](https://console.tilebox.com/workflows/clusters), and clicking the "Create cluster" button.

  <Frame>
    <img src="/assets/console/cluster-light.png" alt="Tilebox Console" className="dark:hidden"  />
    <img src="/assets/console/cluster-dark.png" alt="Tilebox Console" className="hidden dark:block" />
  </Frame>

  <Tip>Copy the cluster slug, you will need it to run your workflows.</Tip>
</Step>
<Step title="Query Data">
  Use the datasets client to query data from a dataset.

  ```python Python
  from tilebox.datasets import Client

  client = Client(token="YOUR_TILEBOX_API_KEY")

  # select a dataset
  datasets = client.datasets()
  dataset = datasets.open_data.copernicus.sentinel2_msi

  # and load data from a collection in a given time range
  collection = dataset.collection("S2A_S2MSI1C")
  data_january_2022 = collection.load(("2022-01-01", "2022-02-01"))
  ```
</Step>
<Step title="Run a Workflow">
  Use the workflows client to create a task and submit it as a job.

  ```python Python
  from tilebox.workflows import Client, Task

  # Replace with your actual cluster and token
  cluster = "YOUR_COMPUTE_CLUSTER"
  client = Client(token="YOUR_TILEBOX_API_KEY")

  class HelloWorldTask(Task):
      greeting: str = "Hello"
      name: str = "World"

      def execute(self, context):
          print(f"{self.greeting} {self.name}, from the main task!")
          context.submit_subtask(HelloSubtask(name=self.name))

  class HelloSubtask(Task):
      name: str

      def execute(self, context):
          print(f"Hello from the subtask, {self.name}!")

  # Initiate the job
  jobs = client.jobs()
  jobs.submit("parameterized-hello-world", HelloWorldTask(greeting="Greetings", name="Universe"), cluster)

  # Run the tasks
  runner = client.runner(cluster, tasks=[HelloWorldTask, HelloSubtask])
  runner.run_all()
  ```
</Step>
<Step title="Explore Further">
  Review the following guides to learn more about the modules that make up Tilebox:

  <CardGroup cols={2}>
    <Card
      title="Datasets Quickstart"
      icon="database"
      href="/datasets/introduction#quickstart"
      horizontal
    />
    <Card
      title="Workflows Quickstart"
      icon="network-wired"
      href="/workflows/introduction#quickstart"
      horizontal
    />
  </CardGroup>
</Step>