Skip to content

Commit 4f92929

Browse files
committed
Either long or short
1 parent 8700ad0 commit 4f92929

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

patches/kaggle_module_resolver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
from tensorflow_hub import resolver
66

7-
url_pattern = re.compile(r"https?://([a-z]+\.)?kaggle.com/models/(?P<owner>[^\\/]+)/(?P<model>[^\\/]+)/(?P<framework>[^\\/]+)/(?P<variation>[^\\/]+)/(?P<version>[0-9]+)$")
7+
short_url_pattern = re.compile(r"https?://([a-z]+\.)?kaggle.com/models/(?P<owner>[^\\/]+)/(?P<model>[^\\/]+)/(?P<framework>[^\\/]+)/(?P<variation>[^\\/]+)/(?P<version>[0-9]+)$")
8+
long_url_pattern = re.compile(r"https?://([a-z]+\.)?kaggle.com/models/(?P<owner>[^\\/]+)/(?P<model>[^\\/]+)/frameworks/(?P<framework>[^\\/]+)/variations/(?P<variation>[^\\/]+)/versions/(?P<version>[0-9]+)$")
89

910
def _is_on_kaggle_notebook():
1011
return os.getenv("KAGGLE_KERNEL_RUN_TYPE") != None and os.getenv("KAGGLE_USER_SECRETS_TOKEN") != None
@@ -17,5 +18,5 @@ def is_supported(self, handle):
1718
return _is_on_kaggle_notebook() and _is_kaggle_handle(handle)
1819

1920
def __call__(self, handle):
20-
m = url_pattern.match(handle)
21+
m = long_url_pattern.match(handle) or short_url_pattern.match(handle)
2122
return kagglehub.model_download(f"{m.group('owner')}/{m.group('model')}/{m.group('framework').lower()}/{m.group('variation')}/{m.group('version')}")

0 commit comments

Comments
 (0)