-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MNT] add minimal dependency management utilities (#1628)
Adds minimal utilities for dependency management, to determine the packages installed. This will be used later in isolation of dependencies that could be soft dependencies. Instead of dumping the new utils in the current `utils` file, a new folder `utils` is added, in which the current `utils` is moved one level lower, and a `_dependencies` submodule is also added.
- Loading branch information
Showing
10 changed files
with
114 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ nbconvert >=6.3.0 | |
recommonmark >=0.7.1 | ||
pytorch-optimizer >=2.5.1 | ||
fastapi >0.80 | ||
cpflows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" | ||
PyTorch Forecasting package for timeseries forecasting with PyTorch. | ||
""" | ||
|
||
from pytorch_forecasting.utils._utils import ( | ||
InitialParameterRepresenterMixIn, | ||
OutputMixIn, | ||
TupleOutputMixIn, | ||
apply_to_list, | ||
autocorrelation, | ||
concat_sequences, | ||
create_mask, | ||
detach, | ||
get_embedding_size, | ||
groupby_apply, | ||
integer_histogram, | ||
masked_op, | ||
move_to_device, | ||
padded_stack, | ||
profile, | ||
redirect_stdout, | ||
repr_class, | ||
to_list, | ||
unpack_sequence, | ||
unsqueeze_like, | ||
) | ||
|
||
__all__ = [ | ||
"InitialParameterRepresenterMixIn", | ||
"OutputMixIn", | ||
"TupleOutputMixIn", | ||
"apply_to_list", | ||
"autocorrelation", | ||
"get_embedding_size", | ||
"concat_sequences", | ||
"create_mask", | ||
"to_list", | ||
"RecurrentNetwork", | ||
"DecoderMLP", | ||
"detach", | ||
"masked_op", | ||
"move_to_device", | ||
"integer_histogram", | ||
"groupby_apply", | ||
"padded_stack", | ||
"profile", | ||
"redirect_stdout", | ||
"repr_class", | ||
"unpack_sequence", | ||
"unsqueeze_like", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Utilities for managing dependencies. | ||
Copied from sktime/skbase. | ||
""" | ||
|
||
from functools import lru_cache | ||
|
||
|
||
@lru_cache | ||
def _get_installed_packages_private(): | ||
"""Get a dictionary of installed packages and their versions. | ||
Same as _get_installed_packages, but internal to avoid mutating the lru_cache | ||
by accident. | ||
""" | ||
from importlib.metadata import distributions, version | ||
|
||
dists = distributions() | ||
package_names = {dist.metadata["Name"] for dist in dists} | ||
package_versions = {pkg_name: version(pkg_name) for pkg_name in package_names} | ||
# developer note: | ||
# we cannot just use distributions naively, | ||
# because the same top level package name may appear *twice*, | ||
# e.g., in a situation where a virtual env overrides a base env, | ||
# such as in deployment environments like databricks. | ||
# the "version" contract ensures we always get the version that corresponds | ||
# to the importable distribution, i.e., the top one in the sys.path. | ||
return package_versions | ||
|
||
|
||
def _get_installed_packages(): | ||
"""Get a dictionary of installed packages and their versions. | ||
Returns | ||
------- | ||
dict : dictionary of installed packages and their versions | ||
keys are PEP 440 compatible package names, values are package versions | ||
MAJOR.MINOR.PATCH version format is used for versions, e.g., "1.2.3" | ||
""" | ||
return _get_installed_packages_private().copy() |
File renamed without changes.