Import Logger
This was a terrible, quickly slapped together, package designed as a quick debugging tool.
Over the past few years, it has proved to be incredibly useful.
what this does
This package is used to override calls to import, wrapping every import with
a call to psutil which measures memory.
The outputs are written to a versioned file as csv compatible text files --
one for "successful" imports, another for "failures"".
The output files are written to an __imports_logged directory and stored under
an incremental __imports_logged/runs subfolder.
This is rough and can be customized. This should NEVER NEVER NEVER be used on production code. This is a quick debugging tool.
DANGER DANGER DANGER
DO NOT RUN THIS IN PRODUCTION
DANGER DANGER DANGER
SERIOUSLY, DO NOT RUN THIS IN PRODUCTION
Why not? This library saves the loaded information in a versioned format - so every time you start/restart your applications, more disk space will be consumed.
so why would I use this?
There are two main use-cases:
-
The outputs can be processed and analyzed (even imported to Excel!) to determine where the biggest imports are, and what causes them.
-
Knowing import errors is useful in two situations: refactoring your own code, and finding what libraries are conditionally importing other 3rd party tools.
requirements
psutil
usage
try running the demo.py script
it is just...
# at the top of your script
import imports_logger
imports_logger.setup_logger()
# your code here
import re
# this should have created a folder named `__imports_logged/runs/001`
the text in runs 001 should look like
import|re.None,demo.py,0,12664832,12664832
Metadata
Release files for imports-logger 1.0.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 | |
|---|---|---|---|---|
| imports_logger-1.0.1.tar.gz | 5.4 kB | Without provenance | Details |
Release files / imports_logger-1.0.1.tar.gz
| Download URL | imports_logger-1.0.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83bfc84ed88f8af844b54c21bdf79ff1dcf19945589b8d571ddc2d8895a338bc
|
|
BLAKE2b-256 checksum How to use checksums |
670882df2a9f04bc1369da04ce9b3e6b0b7a176f12446837a0793be58e1c3ccc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for imports-logger 1.0.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.