Skip to content

Fleet

Fleet is a data models that can be thought as a collection of assets.

In theory there is no need to assets to be of the same type or come from the same organization, but in practice it is often the case. For example for the Drive Fleet report we are interested in a collection of Drive Assets that are part of the same organization. Likewise, for the SmartSensor Fleet report we are interested in a collection of Motors and Generic Machine Assets from the same organization.

Fleet can be initialized by providing a list of Asset objects and the fleet name.

To simplify the main use-case (Powertrain API based, fleets made from list of asset ids) there is a from_access_token() factory method available that takes an access_token and a list of asset_ids and creates a Fleet object with corresponding Asset objects. It accepts the same parameters as the AssetDataReader constructor, plus it takes an asset_type parameter that specifies the type of the asset object used in the fleet.

Drives and Motors

The benefit of the Fleet structure is that it provides a common interface for different types of assets. For example, Drive Fleet and Motor Fleet reports uses the same Fleet structure, but the underlying assets are of different types (DriveAsset and MotorAsset).

To filter assets in the Fleet object, the filter() method is available that returns a list of assets that met the filter criteria. Filtering can be done by asset type, organization id or site id.

Data prefetching

Fleet object provides a prefetch_data() method that fetches data for all assets in the fleet. This is useful when we want to fetch data for all assets at once, to avoid multiple requests to the API. It should be used by the report generator before generating the report.

API

smartreport.v3.models.fleet.Fleet

Bases: Collection

Representation of the Fleet of assets. It is the main data object used by the Fleet Reports group collection of assets in a single object.

organization property

Returns the organization details for the fleet.

If multiple organizations are found, the first one is returned, and if no organization is found, an empty OrganizationDetails object is returned.

__init__(assets, name, asset_data_reader=None)

Initialize Fleet object.

If you work with Powertrain API, you can use the from_access_token class method to create the Fleet object.

Parameters:

Name Type Description Default
assets Sequence[Asset]

Collection of assets

required
name str

Name of the fleet

required
asset_data_reader Optional[AssetDataReader]

Asset

None

assign_assets_unique_display_names()

Ensure unique display names for assets by appending (1), (2), ... if duplicates are found

filter(asset_type=None, organization_id=None, site_id=None)

Filters the assets in the fleet based on the provided parameters.

Parameters:

Name Type Description Default
asset_type Optional[AssetType]

Asset type

None
organization_id Optional[int]

Organization id

None
site_id Optional[int]

Site id

None

Returns:

Type Description
List[Asset]

List of assets that match the provided parameters

from_access_token(access_token, asset_ids, asset_types, name, **kwargs) classmethod

Creates a Fleet from the sequence of asset ids using the provided Powertrain access token.

Parameters:

Name Type Description Default
access_token str

Access token that should be used to initialize the assets

required
asset_ids Sequence[int]

List of asset IDs that should be used to initialize the Fleet

required
asset_types Union[Sequence[AssetType], AssetType]

List of asset types that should be used to initialize the Fleet. If a single asset type is provided, it will be used for all assets.

required
name str

Name of the fleet

required

Other Parameters:

Name Type Description
start_date datetime

Default start date for the asset's time range.

end_date datetime

Default end date for the asset's time range.

Returns:

Type Description
Fleet

Fleet object with Assets from the provided asset ids

get_algorithm_results(algorithm_name, start_date=None, end_date=None, extend=False, upsample_interval=None, upsample_offset=None, **kwargs)

Gets the algorithm results for the fleet of asset.

Algorithms are identified by their name. If dates are not provided, the asset start_date and end_date are used.

Results are returned as a pandas DataFrame. It's up to the user to interpret the data.

Parameters:

Name Type Description Default
algorithm_name str

Name of the algorithm

required
start_date Optional[datetime]

Start date of the results. If None, we use the asset.start_date.

None
end_date Optional[datetime]

End date of the results. If None, we use the asset.end_date.

None
extend bool

If True, the signal is extended to the start_date and end_date timerange. Default: False.

False
upsample_interval Optional[Timedelta]

Interval for upsampling the signal. Default: None.

None
upsample_offset Optional[Timedelta]

Offset for upsampling the signal. Default: 10% of interval.

None

Other Parameters:

Name Type Description
id_column_name str

Name of the id column. Default: id.

id_value str

Name of the asset property that should be used to identify the asset. Default: name.

Returns:

Type Description
DataFrame

DataFrame with the algorithm results.

get_condition_indices(start_date=None, end_date=None)

Get condition indices for all assets in the fleet. It runs the get_condition_indices method on each asset in the fleet and returns the combined results.

Parameters:

Name Type Description Default
start_date Optional[datetime]

Start date of the condition indices. If None, we use the asset.start_date.

None
end_date Optional[datetime]

End date of the condition indices. If None, we use the asset.end_date.

None

Returns:

Type Description
ConditionIndicesResults

ConditionIndicesResults object with the combined condition indices for the fleet.

has_display_asset_names()

Checks if any asset in the fleet has a display name different from its original name.

Returns:

Type Description
bool

True if any asset has a display name different from its original name, False otherwise.

prefetch_data(symbolic_names, algorithm_names, start_date=None, end_date=None, **kwargs)

Prefetches data for all assets in the fleet.

It uses the prefetch_data method from the asset data reader to prefetch the data for the provided symbolic names and algorithm names for all assets in the fleet.

Parameters:

Name Type Description Default
symbolic_names Sequence[str]

List of symbolic names to prefetch

required
algorithm_names Sequence[str]

List of algorithm names to prefetch

required
start_date datetime

Start date of the data to prefetch. If not provided then the asset start_date is used.

None
end_date datetime

End date of the data to prefetch. If not provided then the asset end_date is used.

None

Returns:

Type Description
Optional[float]

Time taken to prefetch the data in seconds.