Git Product home page Git Product logo

sample-notebooks's Introduction

Sample Jupyter Notebooks

This repository contains Jupyter notebooks showcasing how to use the LUSID SDK. You can find a list of the notebooks at examples/README.

LUSID_by_Finbourne

branch status
master Daily build Build and test
develop Build and test view builds

Contributing

We welcome contributions from our community. See our contributing guide for information on how to contribute to the Sample Notebooks repository.

Running the Notebooks in Jupyterhub for your LUSID domain

Authentication is handled automatically; see https://support.lusid.com/knowledgebase/article/KA-01829/en-us

Running the Notebooks locally

You can run the Notebooks locally but you will need to set up authentication using a secrets file:

  1. Clone this repository
git clone [email protected]:finbourne/sample-notebooks.git
cd sample-notebooks
  1. Create a secrets.json file in the examples folder with your LUSID credentials. See how to assemble these.

  2. Build the Docker image

docker build -t finbourne/lusid-sample-notebooks .

Mac users may need to specify the platform. On a Mac M1 it is:

docker build --platform linux/arm64 -t finbourne/lusid-sample-notebooks .
  1. Run the Docker image / Run from command line

Windows

docker run --rm -it --name fbn-jupyter -v %cd%:/home/jovyan -e FBN_SECRETS_PATH=/home/jovyan/examples/secrets.json -p 8888:8888 finbourne/lusid-sample-notebooks

macOS/linux

docker run --rm -it --name fbn-jupyter \
  -v $(pwd):/home/jovyan \
  -e FBN_SECRETS_PATH=/home/jovyan/examples/secrets.json \
  -p 8888:8888 \
  finbourne/lusid-sample-notebooks

You will see something similar to the following output:

[I 09:14:44.031 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[I 09:14:45.228 NotebookApp] JupyterLab extension loaded from /opt/conda/lib/python3.7/site-packages/jupyterlab
[I 09:14:45.228 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 09:14:45.231 NotebookApp] Serving notebooks from local directory: /home/jovyan
[I 09:14:45.231 NotebookApp] The Jupyter Notebook is running at:
[I 09:14:45.231 NotebookApp] http://e910e1f74c45:8888/?token=<token>
[I 09:14:45.231 NotebookApp]  or http://127.0.0.1:8888/?token=<token>
[I 09:14:45.231 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:14:45.245 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html
    Or copy and paste one of these URLs:
        http://e910e1f74c45:8888/?token=<token>
     or http://127.0.0.1:8888/?token=<token>

If you chose to run directly from the command line instead of docker you will need to install the dependencies specified in requirements.txt and then run 'jupyter notebook'

  1. Click on the link shown in the console to open up JupyterHub in a browser.

  2. Open the examples folder and open index.ipynb to see a catalogue of available notebooks.

Running notebooks that require Luminesce

There are few notebooks that interact with Luminesce and need some extra config.

For these notebooks you will need to run the following code in the intended notebook:

import os
from IPython.core.magic import (register_line_cell_magic)
from lusidjam import RefreshingToken
import lumipy as lm

secrets_path = os.getenv("FBN_SECRETS_PATH")

@register_line_cell_magic
def luminesce(line, cell=None):
    query = cell if cell is not None else line

    lm_client = lm.get_client(token=RefreshingToken(), api_secrets_filename=secrets_path)

    df = lm_client.query_and_fetch(query)
            
    return df

# In an interactive session, we need to delete to avoid
# name conflicts for automagic to work on line magics.
del luminesce

sample-notebooks's People

Contributors

slemasne avatar mikemcgarry avatar mneedham avatar adammqm avatar jamesaleedham avatar cscialino avatar thomasdotred avatar rizwansaeed avatar lorenzdec avatar amelia0193 avatar jude-hunt avatar steco avatar dariadelu avatar kkeenan-finbourne avatar tomwp avatar andrewjlp avatar ppwfinbourne avatar pms1969 avatar jz-finbourne avatar omar-oz avatar hanialsibai avatar inwaves avatar jv-finbourne avatar slacki123 avatar tfnc-finbourne avatar armlowe avatar dgbarclay avatar davidwassellfinbourne avatar liberty-askew avatar timbarrass avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.