{ "cells": [ { "cell_type": "markdown", "id": "522812e8", "metadata": {}, "source": [ "# Database-specific configuration options" ] }, { "cell_type": "markdown", "id": "1bb8c72d", "metadata": {}, "source": [ "Granta MI BoM Analytics work with an off-the-shelf Granta MI Restricted Substances database. However, there are\n", "some situations in which additional run-time configuration changes are required:\n", "\n", "- If the database key or table names have been modified from their default values, these must be set on the\n", " ``Connection`` object.\n", "- If the number of linked records is very large, the batch sizes should be changed for each query. For more\n", " information, see [Batching requests](../../api/batching.rst)." ] }, { "cell_type": "markdown", "id": "93a49b4b", "metadata": {}, "source": [ "## Specify a custom database key or table name" ] }, { "cell_type": "markdown", "id": "974b8066", "metadata": {}, "source": [ "The default database key, ``MI_Restricted_Substances``, is used if no database key is specified. To specify a\n", "key, use the ``Connection.set_database_details()`` method. The specified key is then used for all queries made\n", "with this ``Connection`` object." ] }, { "cell_type": "code", "execution_count": null, "id": "48a584d4", "metadata": { "tags": [] }, "outputs": [], "source": [ "from ansys.grantami.bomanalytics import Connection\n", "\n", "server_url = \"http://my_grantami_server/mi_servicelayer\"\n", "cxn = Connection(server_url).with_credentials(\"user_name\", \"password\").connect()\n", "cxn.set_database_details(database_key=\"ACME_SUBSTANCES_DATABASE\")\n", "cxn" ] }, { "cell_type": "markdown", "id": "ae87175f", "metadata": {}, "source": [ "It is also possible to specify alternative names for the relevant restricted substances tables, if they\n", "have been modified from the defaults. You provide the names to the ``.set_database_details()`` method in the same way." ] }, { "cell_type": "code", "execution_count": null, "id": "494256d0", "metadata": { "tags": [] }, "outputs": [], "source": [ "cxn.set_database_details(in_house_materials_table_name=\"ACME Materials\")\n", "cxn" ] }, { "cell_type": "markdown", "id": "875051ab", "metadata": {}, "source": [ "## Batch size" ] }, { "cell_type": "markdown", "id": "7966c5a2", "metadata": {}, "source": [ "The queries that can be performed with this package are batched if they exceed a certain size. This is achieved by\n", "splitting the list of parts, materials, etc. into smaller lists to reduce the overall time taken\n", "to perform the query. Default batch sizes have been chosen based on typical tabular attribute sizes, but\n", "these might need to be changed in some situations. For examples, see the relevant page in the API documentation." ] }, { "cell_type": "markdown", "id": "0c732ddf", "metadata": {}, "source": [ "The batch size is included in the query ``__repr__``. The following cell shows a ``SpecificationComplianceQuery``\n", "object with the default batch size." ] }, { "cell_type": "code", "execution_count": null, "id": "d1916325", "metadata": { "tags": [] }, "outputs": [], "source": [ "from ansys.grantami.bomanalytics import queries\n", "\n", "spec_query = queries.SpecificationComplianceQuery()\n", "spec_query" ] }, { "cell_type": "markdown", "id": "018441dc", "metadata": {}, "source": [ "You can manually set the batch size like this:" ] }, { "cell_type": "code", "execution_count": null, "id": "228a3dcc", "metadata": { "tags": [] }, "outputs": [], "source": [ "spec_query = spec_query.with_batch_size(5)\n", "spec_query" ] }, { "cell_type": "markdown", "id": "ad62a354", "metadata": {}, "source": [ "## Specification to Specification links" ] }, { "cell_type": "markdown", "id": "20c4f647", "metadata": {}, "source": [ "> Supported with Restricted Substances Reports 2023 R2 and newer" ] }, { "cell_type": "markdown", "id": "c9c6b0c4", "metadata": {}, "source": [ "The Restricted Substances database allows Specification records to be defined in terms of other Specification records.\n", "Since this is a recursive relationship, there is in principle no limit to the complexity of these\n", "Specification-to-Specification (spec-to-spec) hierarchies. By default, this package will consider every spec-to-spec\n", "hierarchy completely, with no truncation imposed." ] }, { "cell_type": "markdown", "id": "38ad766d", "metadata": {}, "source": [ "For typical databases this is the correct and desired behavior, however in some circumstances this may cause query\n", "times and response sizes to become very large. In such cases you should control the maximum spec-to-spec hierarchy\n", "depth followed using the ``maximum_spec_link_depth`` parameter on the ``BomAnalyticsClient`` object." ] }, { "cell_type": "markdown", "id": "855c7160", "metadata": {}, "source": [ "The default value is None, setting it to a positive integer will limit the depth to at most that many spec-to-spec\n", "links." ] }, { "cell_type": "code", "execution_count": null, "id": "2392eaaa", "metadata": { "tags": [] }, "outputs": [], "source": [ "cxn.maximum_spec_link_depth = 2\n", "cxn" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:light" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }