Skip to content

Commit

Permalink
Change remote libraries repository in code and README
Browse files Browse the repository at this point in the history
  • Loading branch information
ileasile committed Jul 20, 2021
1 parent d275f1d commit 4fb7ef4
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
5 changes: 2 additions & 3 deletions docs/README-STUB.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions docs/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<libName>.json` file with the following fields:
- `properties`: a dictionary of properties that are used within library descriptor
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.jetbrains.kotlinx.jupyter.config.getLogger
fun getLatestCommitToLibraries(ref: String, sinceTimestamp: String?): Pair<String, String>? {
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"
}
Expand All @@ -20,7 +20,7 @@ fun getLatestCommitToLibraries(ref: String, sinceTimestamp: String?): Pair<Strin
if (sinceTimestamp != null) {
getLatestCommitToLibraries(ref, null)
} else {
logger.info("Didn't find any commits to '$LibrariesDir' at $url")
logger.info("Didn't find any commits to libraries at $url")
null
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ object FallbackLibraryResolver : LibraryDescriptorResolver() {
resolver<LibraryResolutionInfo.ByGitRef> { 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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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(
Expand All @@ -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()
)
Expand All @@ -88,7 +87,7 @@ class ReplWithStandardResolverTests : AbstractSingleReplTest() {
val displays = mutableListOf<Any>()
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()
Expand Down

0 comments on commit 4fb7ef4

Please sign in to comment.