Skip to main content
Glama

ML Jupyter MCP

by sloflash
execute_notebook.py•2.34 kB
#!/usr/bin/env python3 """ Execute the notebook cells programmatically """ import nbformat from nbconvert.preprocessors import ExecutePreprocessor from pathlib import Path import sys def execute_notebook(): notebook_path = Path('torch_attention_demo.ipynb') if not notebook_path.exists(): print(f"āŒ Notebook not found: {notebook_path}") return print(f"šŸ““ Loading notebook: {notebook_path}") # Read the notebook with open(notebook_path, 'r') as f: nb = nbformat.read(f, as_version=4) # Create preprocessor with claude-jupy kernel ep = ExecutePreprocessor( timeout=60, kernel_name='claude-jupy', allow_errors=True ) print("šŸš€ Executing notebook cells...") print(f" Using kernel: {nb.metadata.get('kernelspec', {}).get('name', 'Not set')}") try: # Execute the notebook ep.preprocess(nb, {'metadata': {'path': '.'}}) print("āœ… Notebook executed successfully!") # Save the executed notebook output_path = Path('torch_attention_demo_executed.ipynb') with open(output_path, 'w') as f: nbformat.write(nb, f) print(f"šŸ’¾ Saved executed notebook to: {output_path}") # Show outputs from first few cells print("\nšŸ“Š Sample outputs:") for i, cell in enumerate(nb.cells[:3]): if cell.cell_type == 'code' and hasattr(cell, 'outputs'): print(f"\nCell {i+1} outputs:") for output in cell.outputs: if hasattr(output, 'text'): print(f" {output.text}") elif hasattr(output, 'data') and 'text/plain' in output.data: print(f" {output.data['text/plain']}") except Exception as e: print(f"āŒ Error executing notebook: {e}") # Check for errors in cells for i, cell in enumerate(nb.cells): if cell.cell_type == 'code' and hasattr(cell, 'outputs'): for output in cell.outputs: if hasattr(output, 'ename'): print(f"\nāš ļø Error in cell {i+1}:") print(f" {output.ename}: {output.evalue}") if __name__ == "__main__": execute_notebook()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sloflash/ClaudeJupy'

If you have feedback or need assistance with the MCP directory API, please join our Discord server