BoM compliance#

For more information about BoM item types relevant for compliance analysis, see BoM item types for Restricted Substances in the Granta MI product documentation.

For some important restrictions on BoM-based queries, see Items added during restricted substances analysis.

Query definition#

class BomComplianceQuery#

Evaluates compliance for a BoM against a number of indicators.

The BoM must be in the Ansys Granta 1711 XML BoM format or Ansys Granta 2301 XML BoM format.

All BoM-based queries only operate on a single BoM. As a result, the .with_batch_size() method is not implemented for BoM-based queries.

The methods used to add the BoM and Indicators to this query return the query itself so that they can be chained together as required.

Once the query is fully constructed, use the cxn. run() method to return a result of type PartComplianceQueryResult.

Examples

>>> cxn = Connection("http://my_mi_server/mi_servicelayer").with_autologon().connect()
>>> bom = "<PartsEco xmlns..."
>>> indicator = WatchListIndicator(
...     name="Prop 65",
...     legislation_ids=["Prop65"]
... )
>>> query = (
...     BomComplianceQuery()
...     .with_bom(bom)
...     .with_indicators([indicator])
... )
>>> cxn.run(query)
<BomComplianceQueryResult: 1 PartWithCompliance results>
with_bom(bom)#

Set the BoM to use for the query.

See the documentation for the parent query class for supported BoM formats.

Minimal validation is performed on the provided BoM to ensure the request is sent to the appropriate endpoint. XSD files are provided in schemas for full validation.

Parameters:
bomstr

BoM to use for the query.

Returns:
Query

Current query object.

Raises:
TypeError

Error raised if the method is called with values that do not match the types described earlier.

ValueError

Error raised if the bom isn’t valid XML, or isn’t in a known supported BoM format.

Notes

See the ansys.grantami.bomanalytics.schemas subpackage for Ansys Granta XML BoM Schema Definitions.

with_indicators(indicators)#

Add a list or set of WatchListIndicator or RoHSIndicator objects to evaluate compliance against.

Parameters:
indicatorslist[WatchListIndicator | RoHSIndicator]

List of indicators.

Returns:
Query

Current query object.

Raises:
TypeError

Error to raise if the method is called with values that do not match the types described above.

Examples

>>> indicator = WatchListIndicator(
...     name="Prop 65",
...     legislation_ids=["Prop65"]
... )
>>> MaterialComplianceQuery().with_indicators([indicator])
<MaterialCompliance: 0 materials, batch size = 100, 1 indicators>

Query result#

class BomComplianceQueryResult(results, indicator_definitions, messages)#

Retrieves the result of running the BomComplianceQuery class.

This class summarizes the compliance status of a BoM against one or more indicators.

compliance_by_indicator#

Compliance status for each indicator in the original query. The indicator name is used as the dictionary key.

The result for each indicator is determined by taking the worst result for that indicator across all items included in the query.

Returns:
dict[str, WatchListIndicator | RoHSIndicator]

Examples

>>> compliance_result: MaterialComplianceQueryResult
>>> compliance_result.compliance_by_indicator
{'Prop 65': <WatchListIndicator,
        name: Prop 65,
        flag: WatchListFlag.WatchListAboveThreshold>
}
compliance_by_part_and_indicator#

Compliance status for each root part included in the BoM specified in the original query.

Returns:
list[PartWithComplianceResult]

Examples

>>> result: BomComplianceQueryResult
>>> result.compliance_by_part_and_indicator
[<PartWithComplianceResult, 1 indicators>]
messages#

Messages generated by Granta MI when running the query. The presence of one or more messages means that something unexpected happened when running the query but that the query could still be completed.

Messages are sorted in order of decreasing severity and are available in the Service Layer log file.

Messages are also logged using the Python logging module to the ansys.grantami.bomanalytics logger. By default, messages with a severity of "warning" or higher are printed on stderr.