eea.jupyter utilities for jupyter notebook
Project description
The eea.jupyter is a jupyter utility package for EEA.
Installation
pip install eea.jupyter
Usage
from eea.jupyter import upload_plotly
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:Nonefig(required): The figure to be used as part of the visualization. Can accept aplotly.graph_objs.Figureor adict. Default:Noneapi_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 theurlishttps://biodiversity.eea.europa.eu/en/sandbox/chart-1then the default value forapi_urlwill behttps://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 ifmicrosoftauth_provider is used. Default:__ac**metadata(optional): AnyChart (interactive)metadata desired to be customized, e.g., title, description, topics
Example 1: how to use it with basic authentication
# Cell 1 will have some logic to generate a fig
# Cell 2
from eea.jupyter import upload_plotly
url = "https://www.eea.europa.eu/en/sandbox/miu-test/chart-1"
metadata = {
"title": "Chart 1 example",
"description": "This exemplifies how to use upload_plotly"
}
upload_plotly(url=url, fig=fig, **metadata)
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
# Cell 1 will have some logic to generate a fig
# Cell 2
from eea.jupyter import upload_plotly
url = "https://www.eea.europa.eu/en/sandbox/miu-test/chart-1"
metadata = {
"title": "Chart 1 example",
"description": "This exemplifies how to use upload_plotly"
}
upload_plotly(url=url, fig=fig, auth_provider="microsoft", __ac__key="__ac__eea", **metadata)
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
# Cell 1 will have some logic to generate a fig
# Cell 2
auth_token = input()
# Cell 3
from eea.jupyter import upload_plotly
url = "https://www.eea.europa.eu/en/sandbox/miu-test/chart-1"
metadata = {
"title": "Chart 1 example",
"description": "This exemplifies how to use upload_plotly"
}
upload_plotly(url=url, fig=fig, auth_provider="microsoft", __ac__key="__ac__eea", auth_token=auth_token, **metadata)
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
# Cell 1 will have some logic to generate a fig
# Cell 2
auth_token = input()
# Cell 3
from eea.jupyter import upload_plotly
url = "https://www.eea.europa.eu/en/sandbox/miu-test/chart-1"
metadata = {
"title": "Chart 1 example",
"description": "This exemplifies how to use upload_plotly",
"topics": ["Agriculture and food"],
"temporal_coverage": [2011, 2020],
"geo_coverage": ["Italy"],
"subjects": ["tag 1"],
"data_provenance": [
{"title": "European Environment Agency", "organisation": "EEA", "link": "https://eea.europa.eu"}
]
}
upload_plotly(url=url, fig=fig, auth_provider="microsoft", __ac__key="__ac__eea", auth_token=auth_token, **metadata)
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.
Eggs repository
How to contribute
Copyright and license
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.
Funding
EEA - European Environment Agency (EU)
Changelog
1.8 - (2025-09-17)
Change: Add data sources extractor feature [razvanMiu]
1.7 - (2025-05-07)
Change: Develop [razvanMiu]
1.6 - (2025-03-20)
Change: Make sure fig is a real fig before transforming it into a png [razvanMiu]
1.5 - (2025-03-20)
Change: don’t extract data sources for now [razvanMiu]
1.4 - (2025-03-11)
Change: get_theme & get_template functions added [razvanMiu]
1.3 - (2025-02-20)
Change: Add debug [razvanMiu]
1.2 - (2025-01-16)
Change: Add preview_image [razvanMiu]
1.1 - (2025-01-16)
Change: Add new function, uplod_plotly, to automate jupyter workflow [razvanMiu]
1.0 - (2024-12-04)
Change: make uploadPlotly accept dict, ref #281230 [razvanMiu]
0.9 - (2024-02-02)
Change: update readme + set postMessage origin [razvanMiu]
0.8 - (2024-02-01)
Change: fix import [razvanMiu]
0.7 - (2024-02-01)
Change: add uploadPlotly function wrapper [razvanMiu]
0.6 - (2024-01-30)
Change: Develop [razvanMiu]
0.5 - (2024-01-30)
Change: Develop [razvanMiu]
0.4 - (2024-01-30)
Change: Develop [razvanMiu]
0.3 - (2024-01-30)
Change: Develop [razvanMiu]
0.2 - (2024-01-30)
Change: 0.2 [razvanMiu]
0.1 - (2024-01-19)
Initial release. [eea]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file eea_jupyter-1.8.tar.gz.
File metadata
- Download URL: eea_jupyter-1.8.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf619ebcf71858ac03c7092b24c7e1a88fe325f03496fb68514adcf1dd1884de
|
|
| MD5 |
a83a3da15706ab8a844900923ccb449f
|
|
| BLAKE2b-256 |
f137a8884304ef1429dc8cfc50752772349b73bdd6fac8019740711ae73d29a3
|