eea.jupyter utilities for jupyter notebook
The eea.jupyter is a jupyter utility package for EEA.
Contents
Uploads or creates a Chart (interactive) to a specified url. This function accepts any number of keyword arguments.
Parameters:
url
(required): The URL of the visualization to be updated or created, e.g. https://eea.europa.eu/en/sandbox/chart-1
. Default: None
fig
(required): The figure to be used as part of the visualization. Can accept a plotly.graph_objs.Figure
or a dict
. Default: None
api_url
(optional): The base URL of the plone API, e.g., https://eea.europa.eu/admin/++api++
. Default: /++api++
concatenated to the hostname of the visualization URL, e.g.: if the url
is https://biodiversity.eea.europa.eu/en/sandbox/chart-1
then the default value for api_url
will be https://biodiversity.eea.europa.eu/admin/++api++
auth_provider
(optional): Provider to be used for authentication. Allowed values: basic, microsoft. Default: basicauth_token
(optional): Token to be used instead of allways authenticating. Default: None
__ac__key
(optional): Key to be used in cookies if microsoft
auth_provider is used. Default: __ac
**metadata
(optional): Any Chart (interactive)
metadata desired to be customized, e.g., title, description, topicsExample 1: how to use it with basic authentication
In this example you specify the visualization that you want to update, if it already exists, or where you want to create it. In case the visualization doesn't exists it will be created inside of https://www.eea.europa.eu/en/sandbox/miu-test
with the id of chart-1
.
After calling upload_plotly
you will be prompted with username
and password
inputs.
Example 2: how to use it with microsoft authentication
In this example you specify the microsoft auth_provider and also the key of __ac.
After calling upload_plotly
you will be prompted with auth_token
input which expects a valid __ac
token. To get the __ac
you will need to authenticate on https://www.eea.europa.eu/admin and get the value of __ac__eea
cookie. You can use a cookie chrome extension to retrive the value of the cookie.
Example 3: initialize auth_token
so that you can pass the authentication input
In this example, firstly, you will be prompted with specifying the value of auth_token
, which will then be added as a parameter to upload_plotly
. This allows you to initialize the value of auth_token
only once, then you can run cell 3 as many times as you like.
Same behaviour regardless of the auth_provider
.
Example 4: passing multiple types of metadata
In this section you will learn about various metadata that can be specified when calling upload_plotly
.
figure_note
(slate): sets the figure notetopics
(list): sets the list of strings for topics (e.g., ["Agriculture and food", "Bathing water quality"])temporal_coverage
(list): sets the list of years for temporal coverage (e.g., [2022, 2023, 2024])geo_coverage
(list): sets the list of strings for geographical coverage (e.g., ["Italy", "Romania"])subjects
(list): sets the list of strings for tags (e.g., ["tag 1", "tag 2"])data_provenance
(list) sets the list of data provenance (e.g., [{ "title": "European Environment Agency", "organization": "EEA", "link": "https://eea.europa.eu"}])If any of these doesn't meet the required format, you will get an error explaining what is wrong.
If, for example, you specify topics = ["Agriculture and fod"]
with a typo, you will get an error because the topic is not in the topics vocabulary and a list with the available topics will be printed.
eea.jupyter (the Original Code) is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
The Initial Owner of the Original Code is European Environment Agency (EEA). Portions created by Eau de Web are Copyright (C) 2009 by European Environment Agency. All Rights Reserved.