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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dd4c5fcd2e2e0f7841b00ba3b27d9dc75e898dc77bbc25b9ddbf10aad9f7561
4
- data.tar.gz: e44814e2269cf74aafc044e60653c36523fa0868b4c1548da1083ece0866bf90
3
+ metadata.gz: 56c5fd9c27bd8cdc20423167b912f171ee07d37e0413cfbbbcba2ea38140b7c6
4
+ data.tar.gz: 3f37e295dc32362f7606803790225af6a707021ba78b239d4f2a29567102fee6
5
5
  SHA512:
6
- metadata.gz: 9f81008f7591da868c6eea42414b36159aa6d6c4e3be1ffd18f89f85a0e6e2c120310e4c56f71d32bd406d2eaced158d96972ccd653c3da215f6cfb256eac7d2
7
- data.tar.gz: f3215a4798e90fa5e3496f2364f5da4e5bad5adf982e470c54118c8a5afea3c9ebdca99251e3ba4bf76a9c8f64dbe90664f91d7bff1d6ecec600708cf12c34ec
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
 
@@ -1,3 +1,3 @@
1
1
  module Kaggle
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/kaggle.rb CHANGED
@@ -16,4 +16,5 @@ module Kaggle
16
16
  class DatasetNotFoundError < Error; end
17
17
  class DownloadError < Error; end
18
18
  class ParseError < Error; end
19
+ class CacheNotFoundError < Error; end
19
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaggle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Your Name