Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/ipython@9.5.x
tile.json

tessl/pypi-ipython

tessl install tessl/pypi-ipython@9.5.0

IPython: Productive Interactive Computing - An advanced interactive computing environment and command shell for Python.

Agent Success

Agent success rate when using this tile

86%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.09x

Baseline

Agent success rate without this tile

79%

task.mdevals/scenario-4/

Custom Extension Manager

Build a custom extension manager for tracking and managing extension lifecycles in an interactive environment.

Requirements

Create a system that manages extensions with the following capabilities:

  1. Extension Registration: Track which extensions are currently loaded in the system
  2. Load Extensions: Load extensions dynamically by module name and execute their initialization code
  3. Unload Extensions: Unload extensions and execute their cleanup code
  4. Reload Extensions: Reload an extension by unloading and loading it again
  5. Error Handling: Handle common error cases like attempting to load an already loaded extension or unload a non-loaded extension

Functionality

Your implementation should provide:

  • A way to load an extension that isn't currently loaded
  • A way to unload an extension that is currently loaded
  • A way to reload an extension
  • Proper tracking of which extensions are currently loaded
  • Return status messages indicating success or specific error conditions:
    • Return 'already loaded' when attempting to load an extension that's already loaded
    • Return 'no load function' when a module doesn't have the required load function
    • Return 'not loaded' when attempting to unload an extension that isn't loaded
    • Return 'no unload function' when a module doesn't have an unload function
    • Return None for successful operations

Test Cases

Create test files that verify the following behaviors:

  • Loading a new extension succeeds @test
  • Loading an already loaded extension returns 'already loaded' @test
  • Unloading a loaded extension succeeds @test
  • Unloading a non-loaded extension returns 'not loaded' @test
  • Reloading an extension unloads and loads it again @test

Implementation

@generates

API

class ExtensionManager:
    """
    Manager for loading and unloading extensions.

    Tracks loaded extensions and provides methods for loading,
    unloading, and reloading extensions by module name.
    """

    def __init__(self, shell=None):
        """
        Initialize the extension manager.

        Parameters:
        - shell: Optional shell instance to pass to extension functions
        """
        pass

    def load_extension(self, module_str):
        """
        Load an extension by module name.

        Imports the module and calls its initialization function
        if present. Tracks the extension as loaded.

        Parameters:
        - module_str: str - Python module name of the extension

        Returns:
        - str: 'already loaded' if extension is already loaded
        - str: 'no load function' if module lacks the required initialization function
        - None: if load succeeds
        """
        pass

    def unload_extension(self, module_str):
        """
        Unload an extension by module name.

        Calls the module's cleanup function if present
        and removes it from the loaded extensions.

        Parameters:
        - module_str: str - Python module name of the extension

        Returns:
        - str: 'not loaded' if extension is not currently loaded
        - str: 'no unload function' if module lacks the required cleanup function
        - None: if unload succeeds
        """
        pass

    def reload_extension(self, module_str):
        """
        Reload an extension by unloading and loading it.

        Parameters:
        - module_str: str - Python module name of the extension

        Returns:
        - Result from load_extension after unloading
        """
        pass

Dependencies { .dependencies }

IPython { .dependency }

Provides the interactive computing framework and extension system patterns.