{ "cells": [ { "cell_type": "markdown", "id": "fc121ab7", "metadata": {}, "source": [ "# Database-specific configuration options" ] }, { "cell_type": "markdown", "id": "3f8cf3e9", "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", " informatioon, see [Batching requests](../../api/batching.rst)." ] }, { "cell_type": "markdown", "id": "b4a891b2", "metadata": {}, "source": [ "## Specify a custom database key or table name" ] }, { "cell_type": "markdown", "id": "f6a342cd", "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": "dfb1f0f3", "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": "6b4d854c", "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": "d4b69aa5", "metadata": { "tags": [] }, "outputs": [], "source": [ "cxn.set_database_details(in_house_materials_table_name=\"ACME Materials\")\n", "cxn" ] }, { "cell_type": "markdown", "id": "199d24a7", "metadata": {}, "source": [ "## Batch size" ] }, { "cell_type": "markdown", "id": "580fc1d7", "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": "589957ca", "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": "ec7acf5d", "metadata": { "tags": [] }, "outputs": [], "source": [ "from ansys.grantami.bomanalytics import queries\n", "\n", "spec_query = queries.SpecificationComplianceQuery()\n", "spec_query" ] }, { "cell_type": "markdown", "id": "fffbf041", "metadata": {}, "source": [ "You can manually set the batch size like this:" ] }, { "cell_type": "code", "execution_count": null, "id": "e53e6392", "metadata": { "tags": [] }, "outputs": [], "source": [ "spec_query = spec_query.with_batch_size(5)\n", "spec_query" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:light" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }