Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

[#215] Suggest existing poetry venvs that are in existing modules #217

Conversation

roxchkplusony
Copy link
Contributor

@roxchkplusony roxchkplusony commented Apr 29, 2021

Fixes #215

@roxchkplusony roxchkplusony force-pushed the roxchkplusony/add-existing-venv-multiproject branch from f8aca8b to bc3c2b3 Compare April 29, 2021 05:01
@roxchkplusony roxchkplusony force-pushed the roxchkplusony/add-existing-venv-multiproject branch from bc3c2b3 to b702342 Compare April 29, 2021 05:02
@roxchkplusony
Copy link
Contributor Author

roxchkplusony commented Apr 29, 2021

@koxudaxi I must admit that I'm a little uncomfortable with how to test the plugin well. I did test manually in IJ Ultimate. There is some change in behavior here: module path is used instead of project path if it's non-null now. But, I was unable to get module to be non-null in IJ Ultimate when pulling up the dialog, not sure the scenario that would produce.

@@ -55,20 +58,32 @@ class PyAddExistingPoetryEnvPanel(private val project: Project?,
.panel
add(formPanel, BorderLayout.NORTH)
addInterpretersAsync(sdkComboBox) {
detectPoetryEnvs(module, existingSdks, context, project?.basePath ?: newProjectPath)
val existingSdkPaths = sdkHomes(existingSdks)
val moduleSdks = allModules(project).parallelStream().flatMap { module ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not take a crazy long time to load if there are many modules (I have 45):
Add_Python_Interpreter_and_Project_Structure

.filterNot { it.isAssociatedWithAnotherModule(module) }
val moduleSdkPaths = moduleSdks.map { it.name }.toSet()
val sdks = rootSdks.filterNot { moduleSdkPaths.contains(it.name) } + moduleSdks
sdks.sortedBy { it.name }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted alphabetically, which is understandable and searchable (alternative was by module name):
Add_Python_Interpreter_and_Project_Structure

.filterNot { it.isAssociatedWithAnotherModule(module) }
val moduleSdkPaths = moduleSdks.map { it.name }.toSet()
val sdks = rootSdks.filterNot { moduleSdkPaths.contains(it.name) } + moduleSdks
Copy link
Contributor Author

@roxchkplusony roxchkplusony Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure we only have one entry for the project if there's a module at the same level:
Add_Python_Interpreter_and_Project_Structure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that associated sdks are not in the dropdown:
Project_Structure_and_data-mesh
Add_Python_Interpreter_and_Project_Structure_and_data-mesh

is PyDetectedSdk ->
setupPoetrySdkUnderProgress(project, module, existingSdks, newProjectPath,
is PyDetectedSdk -> {
val mappedModule = sdkToModule[sdk.name] ?: module
Copy link
Contributor Author

@roxchkplusony roxchkplusony Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created sdk matches the corresponding module's folder's name:
Project_Structure_and_data-mesh

@roxchkplusony roxchkplusony changed the title [Fixes #215] Suggest existing poetry venvs that are in existing modules [#215] Suggest existing poetry venvs that are in existing modules Apr 29, 2021
@koxudaxi
Copy link
Owner

@roxchkplusony
Thank you for creating awesome PR 😸

But, I was unable to get module to be non-null in IJ Ultimate when pulling up the dialog, not sure the scenario that would produce.

I guess the case is for PyCharm.

I must admit that I'm a little uncomfortable with how to test the plugin well. I did test manually in IJ Ultimate. There is some change in behavior here: module path is used instead of project path if it's non-null now.

All changes look good. I will check the PR in PyCharm.

@koxudaxi
Copy link
Owner

koxudaxi commented Apr 29, 2021

I can't get the existing SDK 🤔
2021-04-30 0 33 48

@koxudaxi
Copy link
Owner

koxudaxi commented Apr 29, 2021

This problem happened after just creating a new project with a poetry environment.
I'm sorry, I forget to remove the SDK from settings. 😅

@koxudaxi koxudaxi merged commit 08e8bfc into koxudaxi:master Apr 29, 2021
@koxudaxi
Copy link
Owner

@roxchkplusony
I tested patterns in PyCharm.
It looks good 😄
I have pushed it as 0.11.3.

Thank you very much.

@roxchkplusony roxchkplusony deleted the roxchkplusony/add-existing-venv-multiproject branch April 29, 2021 20:28
@roxchkplusony
Copy link
Contributor Author

I'm so glad, thank you for your leadership!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest existing poetry venvs that are in existing modules
2 participants