Skip to main content

TEMD: Error Message Decoder for Python

TEMD is a Python library designed to help beginner Python programmers understand and resolve errors in their code. It provides detailed, user-friendly explanations for common Python errors, making it easier for learners to debug their programs and improve their coding skills. The project leverages machine learning models to interpret and explain error messages, supporting both automatic and wrapped error detection modes.

Requirements

  • Python 3.x
  • joblib
  • requests
  • scikit-learn

Installation

You can install TEMD directly from PyPI:

pip install TEMD

How to Use

1. Initialize TEMD for Global Error Handling

To set up global error handling, import the TEMD class and call the init method. This will catch and explain errors automatically.

from TEMD.temd import TEMD

# Initialize TEMD for global error handling
temd = TEMD()
temd.init()  # This sets up the global error handler

print("Global error handling active!")

2. Example of Automatic Error Handling

Once initialized, TEMD will automatically catch and explain errors that occur during the execution of the program.

# Example of automatic error handling
my_list = [1, 2, 3]
print(my_list[5])  # This will raise an IndexError and TEMD will handle it

3. Example of Wrapped Error Handling

You can also wrap specific blocks of code to focus error detection and explanation on those sections.

user_code = """
def forloop():
    my_list = [1, 2, 3]
    for i in range(5):
        print(my_list[i])  # This will raise an IndexError when i >= 3
forloop()
"""

# Use wrap to execute the code inside a focused error handling scope
temd.wrap(user_code)  # This will catch errors in the wrapped block and explain them

Logic and Functionality

Data Collection

A dataset of Python errors was collected from various sources, including common error messages encountered by beginners. The dataset includes both AST (Abstract Syntax Tree) errors and runtime errors.

Model Training

Machine learning models were trained using the collected dataset. The models include an AST error model and a runtime error model. These models were trained to recognize and interpret various Python error messages.

Library Development

A Python library was developed to encapsulate the trained models and provide an interface for error interpretation. The library includes functionality for both automatic error handling and error handling within wrapped code blocks.

Integration and Testing

The library was integrated into Python projects to test its effectiveness in real-world scenarios. Various test cases were designed to ensure the library provides accurate and helpful error explanations.

Documentation and Deployment

Comprehensive documentation was created to assist users in integrating and using the TEMD library. The library was packaged and deployed to PyPI (Python Package Index) for easy installation and use.

How to Train Models

  1. Train the Runtime Error Model

    Run the following script to train the runtime error model:

    python train_runtime_error_model.py
    
  2. Train the AST Error Model

    Run the following script to train the AST error model:

    python train_ast_error_model.py
    

How to Run the Main Program

Run the main_program.py to trigger and handle errors, and view the error explanations provided by the models:

python main_program.py

Example Usage

from TEMD.temd import TEMD

# Initialize TEMD for global error handling
temd = TEMD()
temd.init()  # This sets up the global error handler

print("Global error handling active!")

# Example of automatic error handling
my_list = [1, 2, 3]
print(my_list[5])  # This will raise an IndexError and TEMD will handle it

# Example function that will trigger an IndexError
def forloop():
    my_list = [1, 2, 3]
    for i in range(5):
        print(my_list[i])

# Calling the function will automatically trigger TEMD's global error handler
forloop()  # This should trigger an IndexError, and TEMD will explain it

# Focused Error Handling with wrap() (Only this block of code will be monitored)
user_code = """
def forloop():
    my_list = [1, 2, 3]
    for i in range(5):
        print(my_list[i])
forloop()
"""
temd.wrap(user_code)  # This will catch errors in the wrapped block and explain them

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the EMD Team and all contributors for their support and guidance.
  • Special thanks to Asst. Prof. [Guide Name] and Prof. Manish Agrawal for their invaluable guidance throughout the project.

This README file provides a comprehensive overview of the TEMD project, including installation instructions, usage examples, and the underlying logic and functionality. You can use this as a template for your project's documentation.

Metadata

Release files for TEMD 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TEMD 0.1.1
File Size Uploaded Provenance Actions
temd-0.1.1.tar.gz 94.5 kB Without provenance Details for temd-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for TEMD 0.1.1
File Interpreter ABI Platform Actions
TEMD-0.1.1-py3-none-any.whl Python 3 none any Details for TEMD-0.1.1-py3-none-any.whl

Total release size: 192.8 kB

Release files / temd-0.1.1.tar.gz

Download URL temd-0.1.1.tar.gz
Size 94.5 kB
Tags Source
SHA-256 checksum
How to use checksums
297b5a2e2ba8475563385de06ac5350a5192217cdda365283dcc46c664907fa6
BLAKE2b-256 checksum
How to use checksums
25145ab8f26c34d9fe7cb1145152ac8a175c594ab047fbfd3072563ec4011de2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / TEMD-0.1.1-py3-none-any.whl

Download URL TEMD-0.1.1-py3-none-any.whl
Size 98.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca73810127d02645ed5cf3eac5b1b1b17e6677b2b4d4496f4fb7981bd0627f97
BLAKE2b-256 checksum
How to use checksums
7bf0689b8c3921e25ab388932170cb9f82804177329167ae4ff50784abcdc8ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Security for TEMD 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page