Skip to content

magic

%aicrowd magic command

AIcrowdMagics

AIcrowd magic commands

aicrowd(self, line)

Utility function to expose CLI commands as line magic commands

Parameters:

Name Type Description Default
line str

Text written next to the command

required
Source code in aicrowd/magic.py
@line_magic
def aicrowd(self, line: str):
    """Utility function to expose CLI commands as line magic commands

    Args:
        line: Text written next to the command
    """
    try:
        cli.main(line.split(" "), "%aicrowd")
    except Exception as e:
        print("An error occured:", e)
    except SystemExit:
        # Captures sys.exit from click
        pass

load_ipython_extension(ipython)

Register our magic commands with ipython kernel

The magic commands will be available as an extension amd can be loaded using

%load_ext aicrowd.magic
Source code in aicrowd/magic.py
def load_ipython_extension(ipython):
    """Register our magic commands with ipython kernel

    The magic commands will be available as an extension amd can be loaded
    using

        %load_ext aicrowd.magic
    """
    ipython.register_magics(AIcrowdMagics)