Getting started with GoFigr =========================== Account registration ******************** Before you begin, create an account at https://app.gofigr.io/register Client setup ************* First, install the ``gofigr`` client library: .. code:: bash $ pip install gofigr .. _gfconfig: Once installed, configure it with ``gfconfig``. The tool will prompt you for a username and password, and a default workspace. .. code:: $ gfconfig ------------------------------ GoFigr configuration ------------------------------ Username: alyssa Password: Verifying connection... => Authenticated successfully API key (leave blank to generate a new key): Key name: Alyssa's Macbook => Your new API key will be saved to /Users/alyssa/.gofigr => Connected successfully Please select a default workspace: [ 1] - Scratchpad - alyssa's personal workspace - API ID: c6ecd353-321d-4089-b5aa-d94bf0ecb09a Selection [1]: 1 Configuration saved to /Users/alyssa/.gofigr. Happy analysis! ``gfconfig`` only configures the defaults. You will be able to customize any of the options on a per-notebook basis. .. _jupyter_setup: Jupyter setup ************* GoFigr works with both Jupyter Notebook and Jupyter Lab. To use it, simply load the extension: .. code:: python %load_ext gofigr That's it! If you need to override any of the defaults, use :func:`gofigr.jupyter.configure`: .. code:: python configure(analysis=FindByName("My Analysis", create=True)) You can also specify a custom workspace, override ``auto_publish``, or supply default revision metadata: .. code:: python %load_ext gofigr configure(auto_publish=False, workspace=FindByName("Primary Workspace", create=False), analysis=FindByName("My Analysis", create=True), default_metadata={'requested_by': "Alyssa", 'study': 'Pivotal Trial 1'}) .. _specifying_names: Publishing your first figure ***************************** Once you load the extension, your figures will be published automatically. If `auto_publish` if off, you can publish figures manually by calling `publish`: .. code:: python publish(plt.gcf()) You will get a barcoded image with a QR code and a unique revision ID: .. image:: images/scatter_example.png :alt: Example published figure You can now scan the barcode or manually navigate to the figure in the Web App at https://app.gofigr.io . .. image:: images/webapp.png :alt: Figure displayed in the Web App Publishing new revisions ------------------------- Feel free to run your code multiple times. GoFigr will automatically capture the different revisions: .. image:: images/revisions_example.png :alt: Figure revisions in the Web App Advanced use ********************** Specifying names & IDs ----------------------- Instead of using ``FindByName``, you can avoid ambiguity and specify API IDs directly. You can find the API IDs for workspaces and analyses in the web app. Mixing and matching is supported as well: .. code:: python %load_ext gofigr configure(workspace=ApiId("59da9bdb-2095-47a9-b414-c029f8a00e0e"), analysis=FindByName("My Analysis", create=True)) Environment variables ---------------------- By default, GoFigr reads configuration from the file ``.gofigr`` in the user's home directory. However, you can also use environment variables: * `GF_USERNAME` * `GF_PASSWORD` * `GF_API_KEY` * `GF_WORKSPACE`: must be an API ID (look it up in the Web App) * `GF_ANALYSIS`: must be an API ID (look it up in the Web App) * `GF_URL`: API URL * `GF_AUTO_PUBLISH`: true or false Advanced configuration ---------------------- Optionally, you can call ``gfconfig --advanced`` and customize some additional options: API URL: This is the API URL that the client will connect to. We use it for development, but you can just accept the default. Auto-publish: Whether to automatically capture and publish all figures generated by Jupyter, even without an explicit call to ``publish``. Auto-publish is on by default, but you can disable it here. Default revision metadata: JSON that we will automatically store with each figure revision. This is completely up to you. You can leave it empty or include details relevant to your team or organization. .. code:: $ gfconfig --advanced ------------------------------ GoFigr configuration ------------------------------ Username: mpacula Password: API URL [https://api.gofigr.io]: Verifying connection... => Connected successfully Auto-publish all figures [Y/n]: y Default revision metadata (JSON): {"study": "First in Human trial"} Please select a default workspace: [ 1] - Primary Workspace - mpacula's primary workspace - API ID: c6ecd353-321d-4089-b5aa-d94bf0ecb09a Selection [1]: 1 Configuration saved to /Users/maciej/.gofigr. Happy analysis!