Skip to main content
Question

How can we give run time inputs to the python script in atlas ai

  • September 11, 2025
  • 1 reply
  • 38 views

Forum|alt.badge.img

This is sample code

how can i give custom input to this python code

 

# Note that the docstring is how the agent knows how to call the function. It follows the Google Python Style Guide:

# https://google.github.io/styleguide/pyguide.html#383-functions-and-methods

 

from cognite.client import CogniteClient

from cognite.client.data_classes.data_modeling import NodeId

from cognite.client.data_classes.data_modeling.cdm.v1 import CogniteTimeSeries

 

client = CogniteClient()

 

# Retrieve latest data point by time series node id

def handle(time_series_id: NodeId):

    """

    Retrieves the latest data point for a given time series.

   

    Args:

        time_series_id: The node id of the time series to retrieve the latest data point for.

   

    Returns:

        The latest data point for the given time series.

    """

    datapoint = client.time_series.data.retrieve_latest(instance_id=time_series_id)

   

    # Only json serializable data is supported, so we convert the created_data to a dict with .dump().

    return datapoint.dump()

 

# This test function runs when you click the "Test code" button in the UI

def test():

    time_series = client.data_modeling.instances.list(sources=CogniteTimeSeries.get_source(), limit=1)

    time_series_node_id = time_series[0].as_id()

    return handle(time_series_id=time_series_node_id)

 

1 reply

Anders Hafreager
Practitioner

Hi, thanks for creating agents!

What do you want to put in? The dropdown with examples show various ways on how to put data in. In general you can put in primitives and list of primitives as arguments into the function. If you can elaborate a bit more on what you want to do, I can provide more help.

Anders