Part Impacted Substances

Query Definition

class PartImpactedSubstancesQuery

Gets the substances impacted by a list of legislations for Granta MI part records.

All methods used to add parts and legislations to this query return the query itself so that they can be chained together as required. Records can be added using a combination of any of the available methods.

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

Examples

>>> cxn = Connection("http://localhost/mi_servicelayer").with_autologon().connect()
>>> query = (
...     PartImpactedSubstancesQuery()
...     .with_part_numbers(['DRILL', 'FLRY34'])
...     .with_legislations(["REACH - The Candidate List"])
... )
>>> cxn.run(query)
<PartImpactedSubstancesQueryResult: 2 PartWithImpactedSubstances results>
with_legislations(legislation_names)

Add a list or set of legislations to retrieve the impacted substances for. The legislation records are referenced by legislation name.

Parameters
legislation_nameslist[str] | set[str]
Returns
Query

Current query object.

Raises
TypeError

If the method is called with values that do not match the types described above.

Examples

>>> query = MaterialImpactedSubstancesQuery()
>>> query = query.with_legislations(["California Proposition 65 List",
>>>                                  "REACH - The Candidate List"])
<MaterialImpactedSubstances: 0 materials, batch size = 100, 2 legislations>
with_part_numbers(part_numbers)

Add a list or set of parts to a part query, referenced by part number.

Parameters
part_numberslist[str] | set[str]
Returns
Query

Current query object.

Raises
TypeError

If the method is called with values that do not match the types described above.

Examples

>>> query = PartComplianceQuery().with_part_numbers(['DRILL', 'FLRY34'])
<PartCompliance: 2 parts, batch size = 10, 0 indicators>
with_record_guids(record_guids)

Add a list or set of record GUIDs to a query.

Parameters
record_guidslist[str] | set[str]
Returns
Query

Current query object.

Raises
TypeError

If the method is called with values that do not match the types described above.

Examples

>>> query = MaterialComplianceQuery()
>>> query = query.with_record_guids(['bdb0b880-e6ee-4f1a-bebd-af76959ae3c8',
>>>                                  'a98cf4b3-f96a-4714-9f79-afe443982c69'])
<MaterialCompliance: 2 materials, batch size = 100, 0 indicators>
with_record_history_guids(record_history_guids)

Add a list or set of record history GUIDs to a query.

Parameters
record_history_guidslist[str] | set[str]
Returns
Query

Current query object.

Raises
TypeError

If the method is called with values that do not match the types described above.

Examples

>>> query = MaterialComplianceQuery()
>>> query.with_record_history_guids(['41e20a88-d496-4735-a177-6266fac9b4e2',
>>>                                  'd117d9ad-e6a9-4ba9-8ad8-9a20b6d0b5e2'])
<MaterialCompliance: 2 materials, batch size = 100, 0 indicators>
with_record_history_ids(record_history_identities)

Add a list or set of record history identities to a query.

Parameters
record_history_identitieslist[int] | set[int]
Returns
Query

Current query object.

Raises
TypeError

If the method is called with values that do not match the types described above.

Examples

>>> MaterialComplianceQuery().with_record_history_ids([15321, 17542, 942])
<MaterialCompliance: 3 materials, batch size = 50, 0 indicators>
with_batch_size(batch_size)

Set the number of records to include in a single request for this query.

Default values are set based on typical usage of the Restricted Substances database. This value can be changed to optimize performance on a query-by-query basis if required. For example, you can change it if certain records contain particularly large or small numbers of associated records.

Parameters
batch_sizeint

Number of records to include in a single request to Granta MI.

Returns
Query

Current query object.

Raises
ValueError

If the batch size is set to a number less than 1.

TypeError

If a value of any type other than int is specified.

Notes

The Restricted Substances database makes extensive use of tabular data and associated records to store the complex hierarchical relationships that define compliance of products, assemblies, parts, specifications, and materials. As a result, it is impossible to determine the complexity of a particular query without knowing precisely how many records are related to the record included in the query.

The default batch sizes are set for each record type and represent appropriate numbers of those records to be included in the same request assuming typical numbers of associated records.

Even if the records are queried in multiple batches, the results will be assembled into a single result object.

Examples

>>> MaterialComplianceQuery().with_batch_size(50)
<MaterialCompliance: 0 materials, batch size = 50, 0 indicators>

Query Result

class PartImpactedSubstancesQueryResult(results, messages)

Retrieves the result of running the PartImpactedSubstancesQuery class. This class describes the substances in the specified parts impacted by one or more legislations.

Notes

Objects of this class are only returned as the result of a query. The class is not intended to be instantiated directly.

impacted_substances_by_part

Impacted substances for each part specified in the original query.

Because parts do not have a single well-defined reference, the results are provided as a flat list.

Returns
list[PartWithImpactedSubstancesResult]

Examples

>>> result: PartImpactedSubstancesQueryResult
>>> result.impacted_substances_by_part
[<PartWithImpactedSubstancesResult({PartNumber: DRILL}), 1 legislations>,...]
impacted_substances_by_legislation

View of the results for a query for impacted substances, grouped by legislation only.

The substances from all items specified in the query are merged for each legislation, providing a single list of impacted substances grouped by legislation only. Substances are duplicated where they appear in multiple items for the same legislation.

Returns
impacted_substancesdict[str, ImpactedSubstance]

Examples

>>> result: MaterialImpactedSubstancesQueryResult
>>> result.impacted_substances_by_legislation
{'REACH - The Candidate List': [
    <ImpactedSubstance: {"cas_number": 90481-04-2}>, ...]
}
impacted_substances

View of the results for a query for impacted substances, flattened into a single list.

The substances from all items specified in the query are merged across item and legislation, providing a single flat list. Substances are duplicated where they appear in multiple items or legislations.

Returns
impacted_substanceslist[ImpactedSubstance]

Examples

>>> result: MaterialImpactedSubstancesQueryResult
>>> result.impacted_substances
[<ImpactedSubstance: {"cas_number": 90481-04-2}>, ...]
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.

Returns
list[LogMessage]

Examples

>>> result: MaterialImpactedSubstancesQueryResult
>>> result.messages
[LogMessage(severity='warning', message='Material "ABS+PVC (flame retarded)" has
    2 substance row(s) with missing substance links.')]

Part Result

class PartWithImpactedSubstancesResult(legislations, **kwargs)

Retrieves an individual part included as part of an impacted substances query result. This object includes two categories of attributes:

  • The reference to the part in Granta MI

  • The impacted substances associated with this part, both as a flat list and separated by legislation

Notes

With the exception of record_history_identity, the record reference attributes below are only populated if they were specified in the original query.

Objects of this class are only returned as the result of a query. The class is not intended to be instantiated directly.

Examples

>>> result: PartImpactedSubstancesQueryResult
>>> part_result = result.impacted_substances_by_part[0]
>>> part_result.substances_by_legislation
{'California Proposition 65 List': [<ImpactedSubstance: {"cas_number": 90481-04-2}>]}
>>> result: PartImpactedSubstancesQueryResult
>>> part_result = result.impacted_substances_by_part[0]
>>> part_result.substances
[<ImpactedSubstance: {"cas_number": 90481-04-2}>]
Attributes
record_history_identitylist, optional
part_numberstr, optional
record_history_guidstr, optional
record_guidstr, optional
substances_by_legislationdict[str, list[ImpactedSubstance]]

Substances impacted for a particular part, grouped by legislation name.

substanceslist[ImpactedSubstance]

Substances impacted for a particular part as a flattened list.