-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support tracking accessed datasources and writing / reading them to a requirements.yaml file. Support a "Package Scope" using that file which applies those datasource versions at runtime if the user requests a datasource without an explicit version. Support importing a Package. This uses a handle equivalent to a Notebook handle, and like Notebooks is currently limited to the latest version, with version support coming soon. Support Package Asset files whose path honors the current Package Scope.
- Loading branch information
Showing
26 changed files
with
911 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import sys | ||
import unittest | ||
|
||
from kagglehub import package_import | ||
|
||
from .utils import create_test_cache, unauthenticated | ||
|
||
UNVERSIONED_HANDLE = "dster/package-test" | ||
VERSIONED_HANDLE = "dster/package-test/versions/1" | ||
|
||
|
||
class TestPackageImport(unittest.TestCase): | ||
|
||
def tearDown(self) -> None: | ||
# Clear any imported packages from sys.modules. | ||
for name in list(sys.modules.keys()): | ||
if name.startswith("kagglehub_package"): | ||
del sys.modules[name] | ||
|
||
def test_package_versioned_succeeds(self) -> None: | ||
with create_test_cache(): | ||
package = package_import(VERSIONED_HANDLE) | ||
|
||
self.assertIn("foo", dir(package)) | ||
self.assertEqual("bar", package.foo()) | ||
|
||
def test_package_unversioned_succeeds(self) -> None: | ||
with create_test_cache(): | ||
package = package_import(UNVERSIONED_HANDLE) | ||
|
||
self.assertIn("foo", dir(package)) | ||
self.assertEqual("baz", package.foo()) | ||
|
||
def test_download_private_package_succeeds(self) -> None: | ||
with create_test_cache(): | ||
package = package_import("integrationtester/kagglehub-test-private-package") | ||
|
||
self.assertIn("foo", dir(package)) | ||
self.assertEqual("bar", package.foo()) | ||
|
||
def test_public_package_with_unauthenticated_succeeds(self) -> None: | ||
with create_test_cache(): | ||
with unauthenticated(): | ||
package = package_import(UNVERSIONED_HANDLE) | ||
|
||
self.assertIn("foo", dir(package)) | ||
self.assertEqual("baz", package.foo()) |
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ dependencies = [ | |
"tqdm", | ||
"packaging", | ||
"model_signing", | ||
"pyyaml", | ||
] | ||
|
||
[project.urls] | ||
|
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
Oops, something went wrong.