gofigr


Namegofigr JSON
Version 0.17.3 PyPI version JSON
download
home_pageNone
SummaryGoFigr client library
upload_time2024-08-18 17:29:09
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseCopyright 2022-2024 Flagstaff Solutions, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords science visualization version control plotting data reproducibility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. figure:: docs/source/images/logo_wide_light.png
  :alt: GoFigr.io logo

GoFigr - Python Client (0.17.3)
====================================
GoFigr (https://www.gofigr.io) is a service which provides sophisticated version control for figures.

This repository contains the Python client for 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.


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!


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

.. _jupyter_setup:

Jupyter setup
*************
GoFigr works with both Jupyter Notebook and Jupyter Lab. To use it, simply
load the extension and call ``gofigr.jupyter.configure``:

.. code:: python

    %load_ext gofigr

    from gofigr.jupyter import *

    configure(analysis=FindByName("My Analysis", create=True))

This will set your current analysis to ``My Analysis`` under the default workspace (selected through ``gfconfig``),
creating it if it doesn't already exist.

You can also specify a custom workspace, override ``auto_publish``, or supply
default revision metadata:

.. code:: python

    %load_ext gofigr

    from gofigr.jupyter import *

    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:

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

    from gofigr.jupyter import *

    configure(workspace=ApiId("59da9bdb-2095-47a9-b414-c029f8a00e0e"),
              analysis=FindByName("My Analysis", create=True))

Publishing your first figure
*****************************

To publish your first figure, simply call ``publish`` (if you have auto-publish turned on,
the figure will be published automatically without this call). For example, here we publish
a scatter plot:

.. code:: python

    from datetime import datetime
    def test_figure(figsize=(7, 7)):
        df = pd.DataFrame(
             {"x1": npr.normal(size=100),
              "y1": npr.normal(size=100),

              "x2": npr.normal(size=100) + 2,
              "y2": npr.normal(size=100) + 3,

              "x3": npr.normal(size=100) + 3,
              "y3": npr.normal(size=100) - 2})

        fig = plt.figure(figsize=figsize)
        plt.scatter(x=df['x1'], y=df['y1'])
        plt.scatter(x=df['x2'], y=df['y2'])
        plt.scatter(x=df['x3'], y=df['y3'])

        plt.title(f"Example scatter\n{datetime.now()}")
        return plt.gcf(), df

    _ = test_figure()

    publish(fig=plt.gcf(), target=FindByName("My first figure!", create=True))

You will get a barcoded image with a QR code and a unique revision ID:

.. image:: docs/source/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:: docs/source/images/webapp.png
  :alt: Figure displayed in the Web App

Publishing new revisions
-------------------------

Feel free to run the above code multiple times. GoFigr will automatically capture the different revisions:

.. image:: docs/source/images/revisions_example.png
  :alt: Figure revisions in the Web App

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gofigr",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "science, visualization, version control, plotting, data, reproducibility",
    "author": null,
    "author_email": "Maciej Pacula <maciej@gofigr.io>",
    "download_url": "https://files.pythonhosted.org/packages/6e/16/acd954c5c0eb29715ed7c35b9c6cd83c19960cda00aab09bc1c949ad9093/gofigr-0.17.3.tar.gz",
    "platform": null,
    "description": ".. figure:: docs/source/images/logo_wide_light.png\n  :alt: GoFigr.io logo\n\nGoFigr - Python Client (0.17.3)\n====================================\nGoFigr (https://www.gofigr.io) is a service which provides sophisticated version control for figures.\n\nThis repository contains the Python client for GoFigr.\n\nAccount registration\n********************\n\nBefore you begin, create an account at https://app.gofigr.io/register\n\nClient setup\n*************\n\nFirst, install the ``gofigr`` client library:\n\n.. code:: bash\n\n    $ pip install gofigr\n\n.. _gfconfig:\n\nOnce installed, configure it with ``gfconfig``. The tool will prompt you for a\nusername and password, and a default workspace.\n\n.. code::\n\n    $ gfconfig\n    ------------------------------\n    GoFigr configuration\n    ------------------------------\n    Username: alyssa\n    Password:\n    Verifying connection...\n      => Authenticated successfully\n    API key (leave blank to generate a new key):\n    Key name: Alyssa's Macbook\n      => Your new API key will be saved to /Users/alyssa/.gofigr\n      => Connected successfully\n\n    Please select a default workspace:\n      [ 1] - Scratchpad - alyssa's personal workspace  - API ID: c6ecd353-321d-4089-b5aa-d94bf0ecb09a\n    Selection [1]: 1\n\n    Configuration saved to /Users/alyssa/.gofigr. Happy analysis!\n\n``gfconfig`` only configures the defaults. You will be able to customize\nany of the options on a per-notebook basis.\n\n\nAdvanced configuration\n----------------------\n\nOptionally, you can call ``gfconfig --advanced`` and customize some additional options:\n\nAPI URL:\n     This is the API URL that the client will connect to. We use it for development, but you can just accept the default.\nAuto-publish:\n     Whether to automatically capture and publish all figures generated by Jupyter, even without\n     an explicit call to ``publish``. Auto-publish is on by default, but you can disable it here.\nDefault revision metadata:\n     JSON that we will automatically store with each figure revision. This is completely up to you. You can leave it\n     empty or include details relevant to your team or organization.\n\n.. code::\n\n    $ gfconfig --advanced\n    ------------------------------\n    GoFigr configuration\n    ------------------------------\n    Username: mpacula\n    Password:\n    API URL [https://api.gofigr.io]:\n    Verifying connection...\n      => Connected successfully\n    Auto-publish all figures [Y/n]: y\n    Default revision metadata (JSON): {\"study\": \"First in Human trial\"}\n\n    Please select a default workspace:\n      [ 1] - Primary Workspace              - mpacula's primary workspace    - API ID: c6ecd353-321d-4089-b5aa-d94bf0ecb09a\n    Selection [1]: 1\n\n    Configuration saved to /Users/maciej/.gofigr. Happy analysis!\n\n\nEnvironment variables\n----------------------\nBy default, GoFigr reads configuration from the file ``.gofigr`` in the user's home directory. However, you\ncan also use environment variables:\n\n* `GF_USERNAME`\n* `GF_PASSWORD`\n* `GF_API_KEY`\n* `GF_WORKSPACE`: must be an API ID (look it up in the Web App)\n* `GF_ANALYSIS`: must be an API ID (look it up in the Web App)\n* `GF_URL`: API URL\n* `GF_AUTO_PUBLISH`: true or false\n\n.. _jupyter_setup:\n\nJupyter setup\n*************\nGoFigr works with both Jupyter Notebook and Jupyter Lab. To use it, simply\nload the extension and call ``gofigr.jupyter.configure``:\n\n.. code:: python\n\n    %load_ext gofigr\n\n    from gofigr.jupyter import *\n\n    configure(analysis=FindByName(\"My Analysis\", create=True))\n\nThis will set your current analysis to ``My Analysis`` under the default workspace (selected through ``gfconfig``),\ncreating it if it doesn't already exist.\n\nYou can also specify a custom workspace, override ``auto_publish``, or supply\ndefault revision metadata:\n\n.. code:: python\n\n    %load_ext gofigr\n\n    from gofigr.jupyter import *\n\n    configure(auto_publish=False,\n              workspace=FindByName(\"Primary Workspace\", create=False),\n              analysis=FindByName(\"My Analysis\", create=True),\n              default_metadata={'requested_by': \"Alyssa\",\n                                'study': 'Pivotal Trial 1'})\n\n.. _specifying_names:\n\nSpecifying names & IDs\n-----------------------\nInstead of using ``FindByName``, you can avoid ambiguity and specify API IDs directly. You\ncan find the API IDs for workspaces and analyses in the web app. Mixing and matching\nis supported as well:\n\n.. code:: python\n\n    %load_ext gofigr\n\n    from gofigr.jupyter import *\n\n    configure(workspace=ApiId(\"59da9bdb-2095-47a9-b414-c029f8a00e0e\"),\n              analysis=FindByName(\"My Analysis\", create=True))\n\nPublishing your first figure\n*****************************\n\nTo publish your first figure, simply call ``publish`` (if you have auto-publish turned on,\nthe figure will be published automatically without this call). For example, here we publish\na scatter plot:\n\n.. code:: python\n\n    from datetime import datetime\n    def test_figure(figsize=(7, 7)):\n        df = pd.DataFrame(\n             {\"x1\": npr.normal(size=100),\n              \"y1\": npr.normal(size=100),\n\n              \"x2\": npr.normal(size=100) + 2,\n              \"y2\": npr.normal(size=100) + 3,\n\n              \"x3\": npr.normal(size=100) + 3,\n              \"y3\": npr.normal(size=100) - 2})\n\n        fig = plt.figure(figsize=figsize)\n        plt.scatter(x=df['x1'], y=df['y1'])\n        plt.scatter(x=df['x2'], y=df['y2'])\n        plt.scatter(x=df['x3'], y=df['y3'])\n\n        plt.title(f\"Example scatter\\n{datetime.now()}\")\n        return plt.gcf(), df\n\n    _ = test_figure()\n\n    publish(fig=plt.gcf(), target=FindByName(\"My first figure!\", create=True))\n\nYou will get a barcoded image with a QR code and a unique revision ID:\n\n.. image:: docs/source/images/scatter_example.png\n  :alt: Example published figure\n\nYou can now scan the barcode or manually navigate to the figure in the Web App\nat https://app.gofigr.io .\n\n.. image:: docs/source/images/webapp.png\n  :alt: Figure displayed in the Web App\n\nPublishing new revisions\n-------------------------\n\nFeel free to run the above code multiple times. GoFigr will automatically capture the different revisions:\n\n.. image:: docs/source/images/revisions_example.png\n  :alt: Figure revisions in the Web App\n",
    "bugtrack_url": null,
    "license": "Copyright 2022-2024 Flagstaff Solutions, LLC  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "GoFigr client library",
    "version": "0.17.3",
    "project_urls": {
        "Documentation": "https://gofigr.io/docs/gofigr-python/0.17.3/",
        "Homepage": "https://www.gofigr.io"
    },
    "split_keywords": [
        "science",
        " visualization",
        " version control",
        " plotting",
        " data",
        " reproducibility"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ad2ebd14f1e39ff6806603c2786e9fe804731bc6503ed1e9f09039eb07240ba",
                "md5": "8a1536584ee74e2399526c63a2fe007e",
                "sha256": "a1c4cbba9690dd51d0ad69caa19822b6117892c9c30d963290c2d35b5f0e3f16"
            },
            "downloads": -1,
            "filename": "gofigr-0.17.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8a1536584ee74e2399526c63a2fe007e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 364023,
            "upload_time": "2024-08-18T17:29:07",
            "upload_time_iso_8601": "2024-08-18T17:29:07.791575Z",
            "url": "https://files.pythonhosted.org/packages/8a/d2/ebd14f1e39ff6806603c2786e9fe804731bc6503ed1e9f09039eb07240ba/gofigr-0.17.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e16acd954c5c0eb29715ed7c35b9c6cd83c19960cda00aab09bc1c949ad9093",
                "md5": "30d1665984c3cda8f8e3ca352194828a",
                "sha256": "a7713a9cc01d117157421f4b98aa19c620895b053de18e405f51480eacaa14b9"
            },
            "downloads": -1,
            "filename": "gofigr-0.17.3.tar.gz",
            "has_sig": false,
            "md5_digest": "30d1665984c3cda8f8e3ca352194828a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 374687,
            "upload_time": "2024-08-18T17:29:09",
            "upload_time_iso_8601": "2024-08-18T17:29:09.361176Z",
            "url": "https://files.pythonhosted.org/packages/6e/16/acd954c5c0eb29715ed7c35b9c6cd83c19960cda00aab09bc1c949ad9093/gofigr-0.17.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-18 17:29:09",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gofigr"
}
        
Elapsed time: 4.03967s