{"id":13675951,"url":"https://github.com/jupyter/jvm-magics","last_synced_at":"2025-10-19T16:32:31.634Z","repository":{"id":66075426,"uuid":"171375305","full_name":"jupyter/jvm-magics","owner":"jupyter","description":"A plugin system for magic function implementations across JVM kernels.","archived":false,"fork":false,"pushed_at":"2019-02-26T00:10:00.000Z","size":64,"stargazers_count":7,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T21:28:07.787Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jupyter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-02-19T00:10:47.000Z","updated_at":"2024-06-06T17:07:43.000Z","dependencies_parsed_at":"2023-03-31T06:03:01.330Z","dependency_job_id":null,"html_url":"https://github.com/jupyter/jvm-magics","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupyter%2Fjvm-magics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupyter%2Fjvm-magics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupyter%2Fjvm-magics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupyter%2Fjvm-magics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jupyter","download_url":"https://codeload.github.com/jupyter/jvm-magics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237172185,"owners_count":19266627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T12:01:06.478Z","updated_at":"2025-10-19T16:32:31.145Z","avatar_url":"https://github.com/jupyter.png","language":"Java","funding_links":[],"categories":["Jupyter Auxiliary Libraries"],"sub_categories":[],"readme":"# JVM Magics\n\n[![Build Status](https://travis-ci.org/jupyter/jvm-magics.svg?branch=master)](https://travis-ci.org/jupyter/jvm-magics)\n[![JVM magics on jitpack](https://jitpack.io/v/jupyter/jvm-magics.svg)](https://jitpack.io/#jupyter/jvm-magics)\n\n[**Configuration**](#configuration) | [**Usage for Library Authors**](#usage---library-authors) | [**Usage for Kernel Authors**](#usage---kernel-authors)\n\nThis project is a plugin system for magics implementations across JVM kernels (Scala, Clojure, Groovy, ...).\n\n## Purpose\n\nThis API has two main uses:\n\n* For library authors to provide a way to expose Jupyter magic functions to JVM kernels\n* For kernel authors to call magic functions that are made available by libraries\n\nFor example, Apache Spark runs on the JVM. Instead of implementing a `sql` magic function separately in every kernel to run a SparkSQL statement, a library can implement a `sql` magic function once to make it available to any kernel.\n\nThis separates the dependencies of the kernel from the dependencies of magic functions that are available. Kernels and magics can be written in different languages and magics can be loaded at runtime.\n\n## Configuration\n\nSee [instructions on JitPack](https://jitpack.io/#jupyter/jvm-magics) for gradle, maven, sbt, or leiningen.\n\n## Usage\n\n### Usage - Library authors\n\nLibrary authors can register a magic function by calling `Magics.register`.\n\nFor example, the following will register a magic function for SparkSQL:\n\n```scala\nMagics.registerLineCellMagic(\"sql\", (line, cell, interp) -\u003e {\n  String sqlText = cell != null ? cell : line;\n  SparkSession spark = SparkSession.builder.getOrCreate();\n  DataFrame df = spark.sql(sqlText);\n  interp.setVariable(\"sqlResult\", df);\n  return df;\n});\n```\n\nAny kernel implementation can use this `sql` magic to run SQL queries using Spark.\n\nThis library is intended to be used with jvm-repr. Objects returned by magic functions are displayed by kernel implementations, and the recommended implementation is to use `jvm-repr` displayers.\n\nMagics implementations can provide jvm-repr displayers for classes returned by magics. By using displayers, magics do not need to spend time in expensive display conversions unless the representations will be sent to the user session.\n\n### Usage - Kernel authors\n\nKernel authors can use this API to call registered magic functions:\n\n```java\nObject result = Magics.callLineMagic(\"sql\", lineText);\nMap\u003cString, String\u003e resultByMIME = Displayers.display(result);\nKernel.this.display(resultByMIME);\n```\n\nIt is up to the kernel to display the object returned by a magic function, ideally using `jvm-repr` displayers.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupyter%2Fjvm-magics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupyter%2Fjvm-magics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupyter%2Fjvm-magics/lists"}