Skip to main content

layer.run

run()

  • Parameters

    • functions (List[Any**]) -- List of decorated functions to run in the Layer backend.
    • debug (bool) -- Stream logs to console from infra executing the project remotely.
    • ray_address (Optional[str**]) --
    • kwargs (Any) --
  • Returns

    An object with information on the run triggered, unless there is an initialization error.

  • Return type

    Run

Runs the specified functions on Layer infrastructure.

Running the project does the following:

  • Adds new versions of decorated functions to the Layer web UI.
  • Runs any logs and stores them.
import pandas as pd
from layer
from layer.decorators import dataset

# Define a new function for dataset generation
@dataset("my_dataset_name")
def create_my_dataset():
data = [[1, "product1", 15], [2, "product2", 20], [3, "product3", 10]]
dataframe = pd.DataFrame(data, columns=["Id", "Product", "Price"])
return dataframe

# Initialize current project locally and remotely (if it doesn't exist)
project = layer.init("my_project_name", fabric="x-small")

# Run the dataset generation code using Layer's backend compute resources
run = layer.run([create_my_dataset])
# run = layer.run([create_my_dataset], debug=True) # Stream logs to console