Integrates ChartFactor with Jupyter Notebooks
This project has been quarantined.
PyPI Admins need to review this project before it can be restored. While in quarantine, the project is not installable by clients, and cannot be being modified by its maintainers.
Read more in the project in quarantine help article.
Project description
ChartFactor for Python
How to install and test
After download the project go to the root directory
Uninstall any previous installation
python -m pip uninstall chartfactor --yes
Build the chartfactor package like this
python setup.py sdist
The previous command will create a dist folder with tha package in the chartfactor-1.0.tar.gz file.
Install the package locally
python -m pip install ./dist/chartfactor-1.0.tar.gz
Usage
Go to the Jupyter Notebook and in a new python notebook do the following
Cell 1
from chartfactor import cf
import pandas as pd
Cell 2
ts = pd.read_csv('./csvs/ticket_sales.csv')
Cell 3
jsonConfig = {
"showRowNumber": False,
"autoSizeColumns": False,
"config": {
"filters": [
# {
# "path": "company",
# "operation": "TS",
# "value": [
# "pedia"
# ]
# }
],
"groups": [
{
"name": "catname",
"label": "catname",
"sort": {
"name": "commission",
"func": "sum",
"dir": "desc"
},
"limit": 10
},
{
"name": "eventname",
"label": "eventname",
"sort": {
"name": "eventname",
"func": "unique",
"dir": "asc"
},
"limit": 5
}
],
"metrics": [
{
"name": "pricepaid",
"func": "sum"
}
],
"fields": [
],
"exclude": []
},
"rows": [],
"limit": 8,
"offset": 0,
"visualization" : "Bars"
}
Cell 4
prov = cf.provider(ts, jsonConfig)
# prov.get_config()
# prov.run_count_query()
# prov.run_raw_query()
prov.visualize()
How to run test
- Make sure you are in a virtual environment where you have installed chartfactor-py
- Copy the
funding_rounds.csvfile from the data sources Google Drive folder to thechartfactor-py/tests/csv/funding_rounds.csvfolder - Change directories to the
chartfactor-py/testsfolder execute the following command:
python -m unittest
Increase jupyter notebook data rate limit
This may only be required on Windows environments. Run the following command in a terminal to generate the jupyter_notebook_config.py file if not exists:
jupyter notebook --generate-config
After that, locate the file in the .jupyter folder and add the following line at the end:
c.NotebookApp.iopub_data_rate_limit = 1.0e10
Configuring deployment credentials
Create and configure ~/.pypirc which is the pypi.org configuration file, in order to set the user and the token to upload the package.
- Create the file:
touch ~/.pypirc
- Assign permissions:
chmod 600 ~/.pypirc
- Open the file:
open ~/.pypirc
- Add this configuration:
[distutils]
index-servers =
pypi
testpypi
[pypi]
username = __token__
repository = https://upload.pypi.org/legacy/
[testpypi]
username = __token__
repository = https://test.pypi.org/legacy/
Notice that instead of using the password field, we are going to save the API tokens and passwords securely using keyring (which is installed by Twine):
- Configuring the test server:
keyring set https://test.pypi.org/legacy/ __token__
- Enter the generated token for the test environment:
Password for '__token__' in 'https://test.pypi.org/legacy/': TOKEN
- Configuring the production server:
keyring set https://upload.pypi.org/legacy/ __token__
- Enter the generated token for the production environment:
Password for '__token__' in 'https://upload.pypi.org/legacy/': TOKEN
Install Python Package Dependencies
To build the project successfully
pip install -r requirements.txt
To load packages for developers
pip install -r requirements-dev.txt
The execution of the command above will install if not exists the following packages:
- twine>=3.7.1
- build>=0.7.0
- wheel>=0.37.1
If is necessary to upgrade the packages to a newer version just run the following command:
python3 -m pip install --upgrade {twine|build|wheel}
Code Obfuscation
The code obfuscation allows to modify a program code so that it is no longer useful to a hacker but remains fully functional.
Two processes to achieve code obfuscation and its corresponding deployment are detailed below.
Using pyarmor package to build a pyarmored wheel (Recommended)
Installing Anaconda
In order to create easily the virtual environments with the different python versions, and also obfuscate the code and be able to run the chartfactor-py package in every python version, it's necessary to install the Anaconda software.
First download it from the official website.
Next, open the software, go to the Environments tab, and create two virtual environment for python 3.6 and 3.7 with the following names:
- env3.6
- env3.7
Executing the build-pyarmored-wheel.sh file
The build-pyarmored-wheel.sh file was created to automatically build, obfuscate and deploy the package to the pypi.org server.
After installing Anaconda successfully and created the virtual environments, execute the following command inside the chartfactor-py folder:
sh build-pyarmored-wheel.sh -v 1.x <-t|-p>
Flags:
-vpackage version-tupload package to the test environment-pupload package to the production environment
Using pyc-wheel package
This package allows you to compile all py files in a wheel to pyc files. For more information go to the pyc-wheel page
In the chartfactor-py folder execute the following build command:
python3 -m build
After execution, 2 files should have been generated in the dist folder:
- chartfactor-1.x.tar.gz
- chartfactor-1.x-py3-none-any.whl
Next, the following command must be executed to convert the .py files to .pyc (compiled and with the code obfuscated) inside the .whl file.
python -m pyc_wheel dist/chartfactor-1.x-py3-none-any.whl
You can add this option
--with_backupto create a backup during the process.
Once the .whl file has been processed, it must be uploaded to the pypi.org or test.pypi.org repository, whichever the case may be.
To achieve that do the following:
Test server
python3 -m twine upload --repository testpypi ./*
Production server
python3 -m twine upload dist/*
For each case you must enter the user name __token__ and the provided token after.
To install the package run the following command:
pip uninstall chartfactor
Installing the Chartfactor.py package as an end-user
From test server
pip install -i https://test.pypi.org/simple/ chartfactor==1.x
From production server
python3 -m pip install chartfactor
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chartfactor-3.1.0.tar.gz.
File metadata
- Download URL: chartfactor-3.1.0.tar.gz
- Upload date:
- Size: 197.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2bcb2e6a52578d7bb8f73712492a9ebb91df51344d874be2366947f79589908
|
|
| MD5 |
b13a97716a8e50e0cf19ba88559e76b4
|
|
| BLAKE2b-256 |
909307e480fdae1f8e66fc6618b36ae9762d4363c5d93be71ce5c674b716c4b7
|
File details
Details for the file chartfactor-3.1.0-py3-none-any.whl.
File metadata
- Download URL: chartfactor-3.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f8398ad2a5ae065a0a24e57778fee3dc6d20e1b3b80a12215c637d5d831f49e
|
|
| MD5 |
af9b5a1bb250ae32bec14bd668cf2f88
|
|
| BLAKE2b-256 |
5a8f9cc6fd4e0db207250caa12bbb292dd403874d0a6e724b5ad6b123bc230fb
|