[PyCharm] Jupyter (fix): Proper way to set title and icon for DataView, Plots and HuggingFace toolwindows. #PY-82232 Ready For Merge

GitOrigin-RevId: 80216ce8fecea34ae208913be71fe34dbdfe2c96
This commit is contained in:
Nikita Pavlenko
2025-10-15 10:58:34 +00:00
committed by intellij-monorepo-bot
parent 76c6323c80
commit e8f103ec7d
5 changed files with 14 additions and 15 deletions
@@ -1,4 +1,7 @@
<idea-plugin visibility="internal">
<resource-bundle>messages.PyHuggingFaceBundle</resource-bundle>
<dependencies>
<module name="intellij.json.backend"/>
<module name="intellij.python.community.impl"/>
@@ -4,7 +4,6 @@ python.hugging.face.could.not.fetch=Could not fetch data
python.hugging.face.default.value=Default value
python.hugging.face.unknown.element=Unknown element
python.hugging.face.not.found=Error fetching model data: {0}
python.hugging.face.base.url=https://huggingface.co
python.hugging.face.updated.suffix= Updated {0}
python.hugging.face.open.on.link.text=Open on Hugging Face
@@ -3,7 +3,6 @@ package com.intellij.python.community.impl.huggingFace.api
import com.intellij.python.community.impl.huggingFace.HuggingFaceConstants
import com.intellij.python.community.impl.huggingFace.HuggingFaceEntityKind
import com.intellij.python.community.impl.huggingFace.service.PyHuggingFaceBundle
import org.jetbrains.annotations.ApiStatus
import java.net.URL
import java.net.URLEncoder
@@ -12,15 +11,15 @@ import java.nio.charset.StandardCharsets
@ApiStatus.Internal
object HuggingFaceURLProvider {
// todo: there must be already existing solutions for URL building in the platform, find and apply them
private val baseURL = PyHuggingFaceBundle.message("python.hugging.face.base.url")
private const val BASE_URL = "https://huggingface.co"
private val modelsExpandParameters = listOf("gated", "downloads", "likes", "lastModified", "pipeline_tag", "library_name")
private val datasetsExpandParameters = listOf("gated", "downloads", "likes", "lastModified")
fun getEntityMarkdownURL(entityId: String, entityKind: HuggingFaceEntityKind): URL {
return when(entityKind) {
HuggingFaceEntityKind.MODEL -> URL("$baseURL/$entityId/raw/main/README.md")
HuggingFaceEntityKind.DATASET -> URL("$baseURL/datasets/$entityId/raw/main/README.md")
HuggingFaceEntityKind.SPACE -> URL("$baseURL/spaces/$entityId/raw/main/README.md")
HuggingFaceEntityKind.MODEL -> URL("$BASE_URL/$entityId/raw/main/README.md")
HuggingFaceEntityKind.DATASET -> URL("$BASE_URL/datasets/$entityId/raw/main/README.md")
HuggingFaceEntityKind.SPACE -> URL("$BASE_URL/spaces/$entityId/raw/main/README.md")
}
}
@@ -32,11 +31,11 @@ object HuggingFaceURLProvider {
}
}
fun getModelCardLink(modelId: String): URL = URL("$baseURL/$modelId")
fun getModelCardLink(modelId: String): URL = URL("$BASE_URL/$modelId")
fun getDatasetCardLink(datasetId: String): URL = URL("$baseURL/datasets/$datasetId")
fun getDatasetCardLink(datasetId: String): URL = URL("$BASE_URL/datasets/$datasetId")
private fun getSpaceLink(spaceId: String): URL = URL("$baseURL/spaces/$spaceId")
private fun getSpaceLink(spaceId: String): URL = URL("$BASE_URL/spaces/$spaceId")
private fun createCommonParametersString(commonParameters: Map<String, String>): String {
return commonParameters.entries.joinToString("&") {
@@ -73,10 +72,10 @@ object HuggingFaceURLProvider {
val filterParameter = if (tags.isNullOrBlank()) "" else "&filter=${URLEncoder.encode(tags, StandardCharsets.UTF_8)}"
val allParameters = "$encodedCommonParameters&$encodedExpandParameters$filterParameter"
return URL("$baseURL/api/models?$allParameters")
return URL("$BASE_URL/api/models?$allParameters")
}
fun fetchApiDataForModel(modelId: String) = URL("$baseURL/api/models/$modelId")
fun fetchApiDataForModel(modelId: String): URL = URL("$BASE_URL/api/models/$modelId")
fun fetchApiDataUrl(
entityKind: HuggingFaceEntityKind,
@@ -100,9 +99,9 @@ object HuggingFaceURLProvider {
val allParameters = "$encodedCommonParameters&$encodedExpandParameters"
return URL("$baseURL/api/${entityKind.urlFragment}?$allParameters")
return URL("$BASE_URL/api/${entityKind.urlFragment}?$allParameters")
}
fun makeAbsoluteFileLink(entityId: String, relativeFilePath: String): URL =
URL("$baseURL/$entityId/blob/main/$relativeFilePath")
URL("$BASE_URL/$entityId/blob/main/$relativeFilePath")
}
@@ -1230,7 +1230,6 @@ python.requirements.error.create.requirements.file=Could not create requirements
python.requirements.info.file.ref.dropped=Some requirements from base files were not updated: {0}
python.requirements.balloon=Sync Python requirements
toolwindow.stripe.SciView=SciView
toolwindow.stripe.Python_Console=Python Console
toolwindow.stripe.Jupyter_Variables=Jupyter Variables
toolwindow.stripe.Python_Packages=Python Packages
@@ -40,7 +40,6 @@ class PyDataView(private val project: Project) : DumbAware {
private lateinit var contentManager: ContentManager
fun init(toolWindow: ToolWindow) {
toolWindow.stripeTitle = PyBundle.message("debugger.data.view.title")
toolWindow.helpId = HELP_ID
toolWindow.isAvailable = true