kaggle 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kaggle/client.rb +15 -5
- data/lib/kaggle/version.rb +1 -1
- data/lib/kaggle.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56c5fd9c27bd8cdc20423167b912f171ee07d37e0413cfbbbcba2ea38140b7c6
|
4
|
+
data.tar.gz: 3f37e295dc32362f7606803790225af6a707021ba78b239d4f2a29567102fee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b60fa4d87d5a78778247acdbf620bbbcb2a23add74b07c76ff25fa2a02ed5675e8fd3aa27dce6352c2c49c0dfcfb90f54d55cbd1219cb81b04c6a2b371d086
|
7
|
+
data.tar.gz: c3b887147a1e0aeb38fdf1440b63f3c722e8375feaab45bbc0a5e4e434b0a8f7cb06ea71437fe08d888704c732d60629c7e3f18443c40e339abb72c88a56e667
|
data/lib/kaggle/client.rb
CHANGED
@@ -4,22 +4,23 @@ module Kaggle
|
|
4
4
|
|
5
5
|
base_uri Constants::BASE_URL
|
6
6
|
|
7
|
-
attr_reader :username, :api_key, :download_path, :cache_path, :timeout
|
7
|
+
attr_reader :username, :api_key, :download_path, :cache_path, :timeout, :cache_only
|
8
8
|
|
9
9
|
def initialize(username: nil, api_key: nil, credentials_file: nil, download_path: nil, cache_path: nil,
|
10
|
-
timeout: nil)
|
10
|
+
timeout: nil, cache_only: false)
|
11
11
|
load_credentials(username, api_key, credentials_file)
|
12
12
|
@download_path = download_path || Constants::DEFAULT_DOWNLOAD_PATH
|
13
13
|
@cache_path = cache_path || Constants::DEFAULT_CACHE_PATH
|
14
14
|
@timeout = timeout || Constants::DEFAULT_TIMEOUT
|
15
|
+
@cache_only = cache_only
|
15
16
|
|
16
|
-
unless valid_credential?(@username) && valid_credential?(@api_key)
|
17
|
+
unless cache_only || (valid_credential?(@username) && valid_credential?(@api_key))
|
17
18
|
raise AuthenticationError,
|
18
|
-
'Username and API key are required'
|
19
|
+
'Username and API key are required (or set cache_only: true for cache-only access)'
|
19
20
|
end
|
20
21
|
|
21
22
|
ensure_directories_exist
|
22
|
-
setup_httparty_options
|
23
|
+
setup_httparty_options unless cache_only
|
23
24
|
end
|
24
25
|
|
25
26
|
def download_dataset(dataset_owner, dataset_name, options = {})
|
@@ -37,6 +38,15 @@ module Kaggle
|
|
37
38
|
return handle_existing_dataset(extracted_dir, options)
|
38
39
|
end
|
39
40
|
|
41
|
+
# If cache_only mode and no cached data found, return nil or raise based on force_cache option
|
42
|
+
if @cache_only
|
43
|
+
if options[:force_cache]
|
44
|
+
raise CacheNotFoundError, "Dataset '#{dataset_path}' not found in cache and force_cache is enabled"
|
45
|
+
else
|
46
|
+
return nil # Gracefully return nil when cache_only but not forced
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
40
50
|
# Download the zip file
|
41
51
|
response = authenticated_request(:get, "#{Constants::DATASET_ENDPOINTS[:download]}/#{dataset_path}")
|
42
52
|
|
data/lib/kaggle/version.rb
CHANGED
data/lib/kaggle.rb
CHANGED