Skip to main content

Send parameters/arguments to notebooks via URL query string parameters.

Project description

ipyparams

Send parameters/arguments to notebooks via URL query string parameters.

Examples

If you want to prepopulate parameters like foo=bar and baz=1 in a notebook, you can simply encode them in the URL:

https://your.jupyter.server/awsome_notebook.ipynb?foo=bar&baz=1

In the notebook, just include the following:

import ipyparams

The values are now accessible in the ipyparams.params dictionary.

ipyparams.params['foo']  # returns "bar"
ipyparams.params['baz']  # returns "1"

Duplicate parameters

URL query strings can contain multiple parameters with the same name, such as https://your.jupyter.server/awsome_notebook.ipynb?foo=bar&foo=baz. The ipyparams.params dictionary only contains the last value for each name, but you can still access all the "raw" parameters using ipyparams.raw_params dictionary.

import ipyparams
ipyparams.params['foo']      # returns 'baz'
ipyparams.raw_params['foo']  # returns ['bar', 'baz']

Missing parameters

If you try to access a parameter that does not exist, you will simply get None back.

import ipyparams
ipyparams.params['unicorn']      # returns None
ipyparams.raw_params['unicorn']  # returns None

Get the notebook name

import ipyparams
ipyparams.notebook_name  # returns 'awesome_notebook.ipynb'

Get the full, raw URL of the notebook

import ipyparams
ipyparams.raw_url
# returns https://your.jupyter.server/awsome_notebook.ipynb?foo=bar&baz=1

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

ipyparams-0.2.0.tar.gz (2.7 kB view details)

Uploaded Source

File details

Details for the file ipyparams-0.2.0.tar.gz.

File metadata

  • Download URL: ipyparams-0.2.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for ipyparams-0.2.0.tar.gz
Algorithm Hash digest
SHA256 19b5a2b84643781db8067c6cbff5343875cf6517351e4da506acbc51438d416b
MD5 0abf6223edafb5a6859d8192cfd3e419
BLAKE2b-256 c07b1941d4e3c6ce4e68a6a363a21190c4a573e0c562a4db2415b3f6d6365f96

See more details on using hashes here.

Supported by

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