跳转至

foundryts.objects.Object

class foundryts.objects.Object(object_type_id)

An object type in the Ontology.

This class provides methods to create references to time series stored as time series properties on objects in the Ontology.

  • Parameters: object_type_id (str) – ID of the object type in the Ontology.

:::callout{theme="warning" title="Note"} Ensure you’re using the ID for object_type_id since there are three object type references available on the platform: ID, API, RID. :::

Examples

>>> aircraft_object_type = Object("aircraft") # object type reference
>>> airplane = airplane_object_type.id("aircraft-1") # you can now use the primary key to get the object reference

id(object_primary_key_value)

Creates a reference to an Ontology object using its primary key.

  • Parameters: object_primary_key_value (str) – The primary key of the object which can be found either in the dataset defining the object or in the ↗ Object Explorer.
  • Returns: A reference to the Ontology object that can be used to access a time series property using Time Series Property with FoundryObject.property()
  • Return type: FoundryObject

Examples

>>> aircraft_object_type = Object("aircraft")
>>> airplane = airplane_object_type.id("aircraft-1") # the object reference can be used for accessing the TSP

The example below shows a fuller implementation of performing a FoundryTS function on a time series property of a foundryts.objects.Object.

...
import foundryts.functions as F
from foundryts.objects import Object
from foundryts import FoundryTS
# optional: from foundry_sdk_runtime.context_vars import FOUNDRY_HOSTNAME
from foundry_sdk_runtime.context_vars import FOUNDRY_TOKEN
import os

@function
def get_sensor_range() -> str:
    stack = "<your stack here>" #or use FOUNDRY_HOSTNAME

    os.environ["FOUNDRYTS_CODEX_HUB_URIS"] = f"https://{stack}.palantirfoundry.com/codex-hub/api"
    os.environ["FOUNDRYTS_ONTOLOGY_METADATA_URIS"] = f"https://{stack}.palantirfoundry.com/ontology-metadata/api"
    os.environ["FOUNDRYTS_OSS_URIS"] = f"https://{stack}.palantirfoundry.com/object-set-service/api"
    os.environ["FOUNDRY_AUTH_TOKEN"] = FOUNDRY_TOKEN.get()

    foundry = FoundryTS()

    sensor_object_type = Object("<object id>")
    sensor = sensor_object_type.id("<primary key>")
    series = sensor.property("<time series property>")
    end_dt = datetime(2025, 9, 23)
    series = F.time_range(start=0, end=end_dt)(series)
    return str(series.to_pandas())

中文翻译


foundryts.objects.Object

class foundryts.objects.Object(object_type_id)

本体(Ontology)中的一种对象类型。

该类提供了创建时间序列引用的方法,这些时间序列以时间序列属性(time series property)的形式存储在本体中的对象上。

  • 参数: object_type_id (str) – 本体中对象类型的 ID。

:::callout{theme="warning" title="注意"} 请确保使用的是 object_type_id 的 ID,因为平台上提供了三种对象类型引用:ID、API 和 RID。 :::

示例

>>> aircraft_object_type = Object("aircraft") # 对象类型引用
>>> airplane = airplane_object_type.id("aircraft-1") # 现在可以使用主键获取对象引用

id(object_primary_key_value)

使用主键创建对本体中某个对象的引用。

  • 参数: object_primary_key_value (str) – 对象的主键,可在定义对象的数据集或 ↗ 对象浏览器 中找到。
  • 返回: 对本体中对象的引用,可通过时间序列属性(Time Series Property)配合 FoundryObject.property() 访问时间序列属性。
  • 返回类型: FoundryObject

示例

>>> aircraft_object_type = Object("aircraft")
>>> airplane = airplane_object_type.id("aircraft-1") # 该对象引用可用于访问 TSP

以下示例展示了如何在 foundryts.objects.Object 的时间序列属性上执行 FoundryTS 函数的完整实现。

...
import foundryts.functions as F
from foundryts.objects import Object
from foundryts import FoundryTS
# 可选:from foundry_sdk_runtime.context_vars import FOUNDRY_HOSTNAME
from foundry_sdk_runtime.context_vars import FOUNDRY_TOKEN
import os

@function
def get_sensor_range() -> str:
    stack = "<your stack here>" # 或使用 FOUNDRY_HOSTNAME

    os.environ["FOUNDRYTS_CODEX_HUB_URIS"] = f"https://{stack}.palantirfoundry.com/codex-hub/api"
    os.environ["FOUNDRYTS_ONTOLOGY_METADATA_URIS"] = f"https://{stack}.palantirfoundry.com/ontology-metadata/api"
    os.environ["FOUNDRYTS_OSS_URIS"] = f"https://{stack}.palantirfoundry.com/object-set-service/api"
    os.environ["FOUNDRY_AUTH_TOKEN"] = FOUNDRY_TOKEN.get()

    foundry = FoundryTS()

    sensor_object_type = Object("<object id>")
    sensor = sensor_object_type.id("<primary key>")
    series = sensor.property("<time series property>")
    end_dt = datetime(2025, 9, 23)
    series = F.time_range(start=0, end=end_dt)(series)
    return str(series.to_pandas())