Skip to main content

GoFigr client library

Project description

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:

$ pip install gofigr

Once installed, configure it with gfconfig. The tool will prompt you for a username and password, and a default workspace.

$ 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.

$ 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

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

%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:

%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 & 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:

%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:

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:

Example published figure

You can now scan the barcode or manually navigate to the figure in the Web App at https://app.gofigr.io .

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:

Figure revisions in the Web App

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gofigr-0.17.3.tar.gz (374.7 kB view details)

Uploaded Source

Built Distribution

gofigr-0.17.3-py3-none-any.whl (364.0 kB view details)

Uploaded Python 3

File details

Details for the file gofigr-0.17.3.tar.gz.

File metadata

  • Download URL: gofigr-0.17.3.tar.gz
  • Upload date:
  • Size: 374.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for gofigr-0.17.3.tar.gz
Algorithm Hash digest
SHA256 a7713a9cc01d117157421f4b98aa19c620895b053de18e405f51480eacaa14b9
MD5 30d1665984c3cda8f8e3ca352194828a
BLAKE2b-256 6e16acd954c5c0eb29715ed7c35b9c6cd83c19960cda00aab09bc1c949ad9093

See more details on using hashes here.

File details

Details for the file gofigr-0.17.3-py3-none-any.whl.

File metadata

  • Download URL: gofigr-0.17.3-py3-none-any.whl
  • Upload date:
  • Size: 364.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for gofigr-0.17.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a1c4cbba9690dd51d0ad69caa19822b6117892c9c30d963290c2d35b5f0e3f16
MD5 8a1536584ee74e2399526c63a2fe007e
BLAKE2b-256 8ad2ebd14f1e39ff6806603c2786e9fe804731bc6503ed1e9f09039eb07240ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page