nbresult
A simple package to test Jupyter notebook result for the Le Wagon's Data Science Bootcamp.
1. Installation
Installation with pip from Pypi:
pip install nbresult
2. Usage
2.1 Basic usage
Considering the default data challenge architecture:
.
├── challenge.ipynb
├── Makefile
├── README.md
├── data
│ └── data.csv
└── tests
└── __init__.py
If you want to test a variable log_model_score from the challenge.ipynb notebook with pytest:
Anywhere in the notebook you can add a cell with the following code:
from nbresult import ChallengeResult
result = ChallengeResult('score',
score=log_model_score
)
result.write()
This outputs a score.pickle file in the tests directory:
.
├── challenge.ipynb
├── Makefile
├── README.md
├── data
│ └── data.csv
└── tests
├── __init__.py
└── score.pickle
Now you would like to write test on the log_model_score with pytest. Create a test_score.py file:
# tests/test_score.py
from nbresult import ChallengeResultTestCase
class TestScore(ChallengeResultTestCase):
def test_score_is_above_82(self):
self.assertEqual(self.result.score > 0.82, True)
Finally you can run your tests with pytest:
pytest tests/test_score.py
OR
Run the tests with make:
- Setup a
Makefile
# Makefile
default: pytest
pytest:
PYTHONDONTWRITEBYTECODE=1 pytest -v --color=yes
- Run
make
OR
Run the tests inside the notebook:
from nbresult import ChallengeResult
result = ChallengeResult('score',
score=log_model_score
)
result.write()
print(result.check())
2.2 Advanced usage
For more advanced folder structure, you also can specify a subdir folder in which store & read pickle file
from nbresult import ChallengeResult
result = ChallengeResult('score',
subdir='a', # This will store pickle in tests/a/score.pickle
score=log_model_score
)
result.write()
result.check()
Check out detailed example below
Testing
Run make
Metadata
Release files for nbresult 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nbresult-0.1.1.tar.gz | 4.8 kB | Without provenance | Details for nbresult-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nbresult-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for nbresult-0.1.1-py3-none-any.whl |
Total release size: 9.3 kB
Release files / nbresult-0.1.1.tar.gz
| Download URL | nbresult-0.1.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2243d74843eaee0127692fe9574638be8107e350a0cc1eb43a09c08ddb3eeb7e
|
|
BLAKE2b-256 checksum How to use checksums |
cad5bd2c986a556692f6f6f5b4a3d3e84cb0d5de5543afd6528681ac4b94b303
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / nbresult-0.1.1-py3-none-any.whl
| Download URL | nbresult-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
017eedf7b5964c9eb82198db2943545f139bbd4de6ad7a92de75d2ba23ea3b62
|
|
BLAKE2b-256 checksum How to use checksums |
d07dbfcab3fd5bab7072ce01f55d3313d7b4860d46642d628752ef78b5245593
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for nbresult 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.