diff --git a/docs/README-STUB.md b/docs/README-STUB.md index e3c8df45f..041baa30c 100644 --- a/docs/README-STUB.md +++ b/docs/README-STUB.md @@ -160,7 +160,7 @@ When a library is included with `%use` keyword, the following functionality is a - library initialization code - renderers for special types, e.g. charts and data frames -This behavior is defined by `json` library descriptor. Descriptors for all supported libraries can be found in [libraries](../libraries) directory. +This behavior is defined by `json` library descriptor. Descriptors for all supported libraries can be found in [libraries](https://github.com/Kotlin/kotlin-jupyter-libraries) repository. A library descriptor may provide a set of properties with default values that can be overridden when library is included. The major use case for library properties is to specify a particular version of library. If descriptor has only one property, it can be defined without naming: @@ -175,8 +175,7 @@ Several libraries can be included in single `%use` statement, separated by `,`: ``` %use lets-plot, krangl, mysql(8.0.15) ``` -You can also specify the source of library descriptor. By default, it's taken from the `libraries` directory -of kernel installation. If you want to try descriptor from another revision, use the following syntax: +You can also specify the source of library descriptor. By default, it's taken from the [libraries repository](https://github.com/Kotlin/kotlin-jupyter-libraries). If you want to try descriptor from another revision, use the following syntax: ``` // Specify some git tag from this repository %use lets-plot@0.8.2.5 diff --git a/docs/README.md b/docs/README.md index 924dca4f2..61f9d4e79 100644 --- a/docs/README.md +++ b/docs/README.md @@ -167,7 +167,7 @@ When a library is included with `%use` keyword, the following functionality is a - library initialization code - renderers for special types, e.g. charts and data frames -This behavior is defined by `json` library descriptor. Descriptors for all supported libraries can be found in [libraries](../libraries) directory. +This behavior is defined by `json` library descriptor. Descriptors for all supported libraries can be found in [libraries](https://github.com/Kotlin/kotlin-jupyter-libraries) repository. A library descriptor may provide a set of properties with default values that can be overridden when library is included. The major use case for library properties is to specify a particular version of library. If descriptor has only one property, it can be defined without naming: @@ -182,8 +182,7 @@ Several libraries can be included in single `%use` statement, separated by `,`: ``` %use lets-plot, krangl, mysql(8.0.15) ``` -You can also specify the source of library descriptor. By default, it's taken from the `libraries` directory -of kernel installation. If you want to try descriptor from another revision, use the following syntax: +You can also specify the source of library descriptor. By default, it's taken from the [libraries repository](https://github.com/Kotlin/kotlin-jupyter-libraries). If you want to try descriptor from another revision, use the following syntax: ``` // Specify some git tag from this repository %use lets-plot@0.8.2.5 diff --git a/docs/libraries.md b/docs/libraries.md index 49d5c41bb..27f2ac4d2 100644 --- a/docs/libraries.md +++ b/docs/libraries.md @@ -8,7 +8,7 @@ Generally, there are two ways of adding new library: To support new `JVM` library and make it available via `%use` magic command you need to create a library descriptor for it. -Check [libraries](../libraries) directory to see examples of library descriptors. +Check [libraries][libs-repo] repository to see examples of library descriptors. Library descriptor is a `.json` file with the following fields: - `properties`: a dictionary of properties that are used within library descriptor @@ -37,7 +37,7 @@ To register new library descriptor: 1. For private usage - create it anywhere on your computer and reference it using file syntax. 2. Alternative way for private usage - create descriptor in `.jupyter_kotlin/libraries` folder and reference it using "default" syntax -3. For sharing with community - commit it to [libraries](../libraries) directory and create pull request. +3. For sharing with community - commit it to [libraries][libs-repo] repository and create pull request. If you are maintaining some library and want to update your library descriptor, create pull request with your update. After your request is accepted, new version of your library will be available to all Kotlin Jupyter users @@ -155,3 +155,5 @@ resources. This file should contain FQNs of all integration classes in the JSON ``` Classes derived from `LibraryDefinition` should be added to the `definitions` array. Classes derived from `LibraryDefinitionProducer` should be added to the `producers` array. + +[libs-repo]: https://github.com/Kotlin/kotlin-jupyter-libraries \ No newline at end of file diff --git a/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/ResolutionInfoProvider.kt b/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/ResolutionInfoProvider.kt index fee302425..b2275459b 100644 --- a/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/ResolutionInfoProvider.kt +++ b/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/ResolutionInfoProvider.kt @@ -42,7 +42,7 @@ class StandardResolutionInfoProvider(override var fallback: LibraryResolutionInf } private fun tryGetAsRef(ref: String): LibraryResolutionInfo? { - val response = getHttp("$GitHubApiPrefix/contents/$LibrariesDir?ref=$ref") + val response = getHttp("$GitHubApiPrefix/contents/$RemoteLibrariesDir?ref=$ref") return if (response.status.successful) LibraryResolutionInfo.getInfoByRef(ref) else null } diff --git a/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/constants.kt b/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/constants.kt index 796d7bee0..372edbf6e 100644 --- a/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/constants.kt +++ b/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/constants.kt @@ -7,8 +7,9 @@ const val LibrariesDir = "libraries" const val LocalCacheDir = "cache" const val LocalSettingsDir = ".jupyter_kotlin" const val GitHubApiHost = "api.github.com" -const val GitHubRepoOwner = "kotlin" -const val GitHubRepoName = "kotlin-jupyter" +const val GitHubRepoOwner = "Kotlin" +const val GitHubRepoName = "kotlin-jupyter-libraries" +const val RemoteLibrariesDir = "" const val GitHubApiPrefix = "https://$GitHubApiHost/repos/$GitHubRepoOwner/$GitHubRepoName" const val LibraryDescriptorExt = "json" const val LibraryPropertiesFile = ".properties" diff --git a/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/httpUtil.kt b/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/httpUtil.kt index 5ca31cde6..b74b55b38 100644 --- a/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/httpUtil.kt +++ b/jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/httpUtil.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlinx.jupyter.config.getLogger fun getLatestCommitToLibraries(ref: String, sinceTimestamp: String?): Pair? { val logger = getLogger() return logger.catchAll { - var url = "$GitHubApiPrefix/commits?path=$LibrariesDir&sha=$ref" + var url = "$GitHubApiPrefix/commits?path=$RemoteLibrariesDir&sha=$ref" if (sinceTimestamp != null) { url += "&since=$sinceTimestamp" } @@ -20,7 +20,7 @@ fun getLatestCommitToLibraries(ref: String, sinceTimestamp: String?): Pair { name -> if (name == null) throw ReplLibraryLoadingException(message = "Reference library resolver needs name to be specified") - val url = "$GitHubApiPrefix/contents/$LibrariesDir/$name.$LibraryDescriptorExt?ref=$sha" + val url = "$GitHubApiPrefix/contents/$RemoteLibrariesDir/$name.$LibraryDescriptorExt?ref=$sha" getLogger().info("Requesting library descriptor at $url") val response = getHttp(url).jsonObject diff --git a/src/test/kotlin/org/jetbrains/kotlinx/jupyter/test/repl/ReplWithStandardResolverTests.kt b/src/test/kotlin/org/jetbrains/kotlinx/jupyter/test/repl/ReplWithStandardResolverTests.kt index f2aabb9bb..8cf00ebba 100644 --- a/src/test/kotlin/org/jetbrains/kotlinx/jupyter/test/repl/ReplWithStandardResolverTests.kt +++ b/src/test/kotlin/org/jetbrains/kotlinx/jupyter/test/repl/ReplWithStandardResolverTests.kt @@ -1,8 +1,6 @@ package org.jetbrains.kotlinx.jupyter.test.repl import org.intellij.lang.annotations.Language -import org.jetbrains.kotlinx.jupyter.libraries.GitHubRepoName -import org.jetbrains.kotlinx.jupyter.libraries.GitHubRepoOwner import org.jetbrains.kotlinx.jupyter.libraries.LibrariesDir import org.jetbrains.kotlinx.jupyter.libraries.LibraryDescriptorExt import org.jetbrains.kotlinx.jupyter.libraries.LibraryResolutionInfo @@ -27,7 +25,7 @@ class ReplWithStandardResolverTests : AbstractSingleReplTest() { @file:DependsOn("org.geotools:gt-shapefile:[23,)") @file:DependsOn("org.geotools:gt-cql:[23,)") - %use lets-plot@cfcf8257116ad3753b176a9f779eaaea4619dacd(api=2.0.1) + %use lets-plot@f2bb7075b316e7181ff8fddb1e045c4ed2c26442(api=2.0.1) @file:DependsOn("org.jetbrains.lets-plot:lets-plot-kotlin-geotools:2.0.1") @@ -67,6 +65,7 @@ class ReplWithStandardResolverTests : AbstractSingleReplTest() { @Test fun testUseFileUrlRef() { val commit = "cfcf8257116ad3753b176a9f779eaaea4619dacd" + val libsCommit = "f2bb7075b316e7181ff8fddb1e045c4ed2c26442" val libraryPath = "src/test/testData/test-init.json" val res1 = eval( @@ -79,7 +78,7 @@ class ReplWithStandardResolverTests : AbstractSingleReplTest() { val res2 = eval( """ - %use @url[https://raw.githubusercontent.com/$GitHubRepoOwner/$GitHubRepoName/$commit/$libraryPath](name=y, value=43) + %use @url[https://raw.githubusercontent.com/Kotlin/kotlin-jupyter/$commit/$libraryPath](name=y, value=43) y """.trimIndent() ) @@ -88,7 +87,7 @@ class ReplWithStandardResolverTests : AbstractSingleReplTest() { val displays = mutableListOf() val handler = TestDisplayHandler(displays) - val res3 = eval("%use lets-plot@$commit", handler) + val res3 = eval("%use lets-plot@$libsCommit", handler) assertEquals(1, displays.count()) assertUnit(res3.resultValue) displays.clear()