{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Global Configuration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**ccapi** introduces a global configuration object. You can configure all settings which will be respected while you use **ccapi**.\n", "\n", "You can get a configuration object in the following way:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import ccapi" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "config = ccapi.Configuration()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The configuration object is a [singleton](https://en.wikipedia.org/wiki/Singleton_pattern). That means only one instance can exist and it is respected everywhere in **ccapi**." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### URL" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By default, the base URL points to [Cell Collective](https://cellcollective.org). You can however, change the same as follows:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "config.url = \"https://test.cellcollective.org\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, when you attempt to create a client instance, it would attempt to use the value assigned to `config.url`." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "client = ccapi.Client()\n", "client" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Jupyter Notebook renders the `Configuration` object as follows:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " \n", " display_max_cols\n", " \n", " \n", " 20\n", "
\n", " \n", " display_max_rows\n", " \n", " \n", " 15\n", "
\n", " \n", " ginsim_version\n", " \n", " \n", " 2.4\n", "
\n", " \n", " max_api_resource_fetch\n", " \n", " \n", " 5\n", "
\n", " \n", " max_chunk_download_bytes\n", " \n", " \n", " 1024\n", "
\n", " \n", " model_domain_type\n", " \n", " \n", " {'value': 'research'}\n", "
\n", " \n", " model_name\n", " \n", " \n", " Unnamed Model\n", "
\n", " \n", " model_type\n", " \n", " \n", " {'value': 'boolean'}\n", "
\n", " \n", " url\n", " \n", " \n", " https://test.cellcollective.org\n", "
\n", " \n", " user_agent\n", " \n", " \n", " Python CCAPI / 0.1.0\n", "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "config" ] } ], "metadata": { "file_extension": ".py", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.9" }, "mimetype": "text/x-python", "name": "python", "npconvert_exporter": "python", "pygments_lexer": "ipython3", "version": 3 }, "nbformat": 4, "nbformat_minor": 2 }