Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

aarsh1a
Copy link
Contributor

@aarsh1a aarsh1a commented Jun 13, 2025

This PR adds documentation for handling module-level soft dependency imports in sktime. The existing developer guide explains how to manage soft dependencies within estimators, but does not cover scenarios where optional dependencies need to be imported at the module level.

To address this, I have added a new section titled "Module-level soft dependency imports" under dependencies.rst. It provides clear usage patterns for using _check_soft_dependencies before importing optional modules directly. Example code snippets are included to demonstrate both severity-based checks and conditional imports.

This PR adds documentation for how to handle module-level soft dependency imports.
Copy link
Member

@yarnabrina yarnabrina left a comment

Choose a reason for hiding this comment

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

Hi @aarsh1a thanks for your contribution.

It is recommended to rely on the python dependencies tag as much as possible, and avoid module level imports even after checks. This is to avoid possible side effects that imports may cause. In some cases we do deviate from this, mostly in our deep learning estimators, but those are specific cases and if I am not wrong we are trying to reduce those as well. Can you please update accordingly?

@aarsh1a
Copy link
Contributor Author

aarsh1a commented Jun 13, 2025

sure! i'll make the changes and update the file.

Made specific changes that were asked for and updated the file.
@aarsh1a
Copy link
Contributor Author

aarsh1a commented Jun 13, 2025

hi @yarnabrina I made some changes to the file please take a look.

@aarsh1a aarsh1a requested a review from yarnabrina June 14, 2025 19:15
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Nice! Thanks!

Some requests to make it clearer:

  • can you turn the content into a subsection of the previous section "handling soft dependencies", and turn part of the previous section into another subsection?
  • at the start, it should be explained that (a) soft dependencies should be restricted to estimators if possible, and (b) if not possible, then the instructions in the other section should be followed
  • the distribute the examples in the appropriate section
  • _safe_import should also be mentioned

Addressed the changes requested.
@aarsh1a aarsh1a requested a review from fkiraly June 15, 2025 17:12
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Great! left some improvement requests

@fkiraly fkiraly changed the title DOC: Add guide for module-level soft dependency imports (#7690) [DOC] Add guide for module-level soft dependency imports (#7690) Jul 18, 2025
@fkiraly fkiraly changed the title [DOC] Add guide for module-level soft dependency imports (#7690) &fkiraly [DOC] Add guide for module-level soft dependency imports (#7690) Jul 18, 2025
@fkiraly fkiraly added the documentation Documentation & tutorials label Jul 18, 2025
@fkiraly
Copy link
Collaborator

fkiraly commented Jul 18, 2025

This is abandoned, I wrapped it up now.

@fkiraly fkiraly merged commit e529480 into sktime:main Jul 18, 2025
1 of 2 checks passed
ericjb pushed a commit to ericjb/sktime that referenced this pull request Jul 31, 2025
…time#7690) (sktime#8386)

This PR adds documentation for handling module-level soft dependency
imports in sktime. The existing developer guide explains how to manage
soft dependencies within estimators, but does not cover scenarios where
optional dependencies need to be imported at the module level.

To address this, I have added a new section titled "Module-level soft
dependency imports" under dependencies.rst. It provides clear usage
patterns for using _check_soft_dependencies before importing optional
modules directly. Example code snippets are included to demonstrate both
severity-based checks and conditional imports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation & tutorials
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants