-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `gluonts.util.safe_extract` (#2606) Co-authored-by: Jasper <[email protected]> Co-authored-by: Lorenzo Stella <[email protected]> * Fix call to `extractall` (#2648) * remove py36 * fix requirements * fix flake8 * Cap numpy compatibility in `mxnet` extra requirements (#2506) * xfail multivariate grouper test Co-authored-by: Lorenzo Stella <[email protected]> Co-authored-by: Jasper <[email protected]> * roll back undesired change * fixup * remove np.long * fix * fix flake8 --------- Co-authored-by: Jasper <[email protected]> Co-authored-by: Lorenzo Stella <[email protected]> Co-authored-by: Jasper <[email protected]>
- Loading branch information
1 parent
5424442
commit 3099156
Showing
17 changed files
with
114 additions
and
29 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 |
---|---|---|
@@ -1 +1 @@ | ||
fbprophet>=0.4.* | ||
fbprophet>=0.4.0 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
rpy2>=2.9.*,<3.* | ||
rpy2>=2.9.0,<3.0 |
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
# upper bound added since numpy==1.24 broke importing mxnet, | ||
# see https://github.com/awslabs/gluonts/pull/2506 | ||
numpy<1.24 | ||
mxnet~=1.7 |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
flaky~=3.6 | ||
pytest-cov==2.6.* | ||
pytest-cov~=2.6.0 | ||
pytest-timeout~=1.3 | ||
pytest-xdist~=1.27 | ||
pytest~=5.0 | ||
|
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
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,48 @@ | ||
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# A copy of the License is located at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# or in the "license" file accompanying this file. This file is distributed | ||
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
# express or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
|
||
import tarfile | ||
from pathlib import Path | ||
|
||
|
||
def will_extractall_into(tar: tarfile.TarFile, path: Path) -> None: | ||
""" | ||
Check that the content of ``tar`` will be extracted within ``path`` | ||
upon calling ``extractall``. | ||
Raise a ``PermissionError`` if not. | ||
""" | ||
path = Path(path).resolve() | ||
|
||
for member in tar.getmembers(): | ||
member_path = (path / member.name).resolve() | ||
|
||
try: | ||
member_path.relative_to(path) | ||
except ValueError: | ||
raise PermissionError(f"'{member.name}' extracts out of target.") | ||
|
||
|
||
def safe_extractall( | ||
tar: tarfile.TarFile, | ||
path: Path = Path("."), | ||
members=None, | ||
*, | ||
numeric_owner=False, | ||
): | ||
""" | ||
Safe wrapper around ``TarFile.extractall`` that checks all destination | ||
files to be strictly within the given ``path``. | ||
""" | ||
will_extractall_into(tar, path) | ||
tar.extractall(path, members, numeric_owner=numeric_owner) |
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