datahen 1.5.3 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: beadb0e5b371134e96d8e1888250de66411eb287a30cfc5f717e525c19343d6c
4
- data.tar.gz: 298daaf6f56f1fcfb4e842b9e82d0e4f8896315d264b9481aa2ed4ec55bc8a9b
3
+ metadata.gz: 0aeab36656b35d48d158c46e90cf504007727d60000352503468c743b8f519f3
4
+ data.tar.gz: 62dc78ad8d8388f62db06217507e4ff8f22d004501f264d899dfb14afd9d5df1
5
5
  SHA512:
6
- metadata.gz: 8cba2e599b72315d65cd20440c6a8804d7298bd577d5d24f9408bc71e35f47ee5abb8e7d580b7b42cc95c10608f852339a1d44ecfedaedd82acb565f5ffb05d2
7
- data.tar.gz: 6a8c1c8f7d8deca7663699f7f20ea0e9cf7e7608b2d93150fb2fd4da438780fecff010332e43675800f94012739bfcda6a85dd27df1055958e6de0bbd4c158ab
6
+ metadata.gz: f83d2cf14b3b1f00ff2f7b8f319c52bb408301e318a390b419f1b87e7b4a79a0ba7b40468079c8b8b22562d24a8eef6c6bde60d40a11930dbc3af44c16c3acd7
7
+ data.tar.gz: 8a05fc8d0419c13f0849fdeb53f1c91455d359539431623138e31895c192994a786fc271df7dc2ae223f1d7a6cdaa46eeb81939e093cb6d850aded106809c66c
@@ -252,6 +252,9 @@ module Datahen
252
252
  desc "task SUBCOMMAND ...ARGS", "manage task on a job"
253
253
  subcommand "task", ScraperTask
254
254
 
255
+ desc "resource SUBCOMMAND ...ARGS", "manage resource on a job"
256
+ subcommand "resource", ScraperResource
257
+
255
258
 
256
259
  end
257
260
  end
@@ -112,6 +112,7 @@ module Datahen
112
112
  option :soft_refetch_limit, type: :numeric, desc: 'Set the soft refetch limit value.'
113
113
  option :parsing_try_limit, type: :numeric, desc: 'Set the parsing try limit value.'
114
114
  option :prevent_kb_autoscaler, type: :boolean, desc: 'Set true to prevent the autoscaler from restarting the job. Default: false'
115
+ option :deletion_protected, type: :boolean, desc: 'Set true to prevent the job to be deleted from max job count or job older than X days rules. Default: false'
115
116
  def update(scraper_name)
116
117
  if options[:job]
117
118
  client = Client::Job.new(options)
@@ -0,0 +1,35 @@
1
+ module Datahen
2
+ class CLI < Thor
3
+ class ScraperResource < Thor
4
+ package_name "scraper resource"
5
+ def self.banner(command, namespace = nil, subcommand = false)
6
+ "#{basename} #{@package_name} #{command.usage}"
7
+ end
8
+
9
+ desc "list", "List resources on a scraper's current job"
10
+ long_desc <<-LONGDESC
11
+ List all resources in a scraper's current job or given job ID.\x5
12
+ LONGDESC
13
+ option :scraper_name, :aliases => :s, type: :string, desc: 'Filter by a specific scraper_name'
14
+ option :job, :aliases => :j, type: :numeric, desc: 'Set a specific job ID'
15
+ option :pod, type: :string, desc: 'Returns only tasks with specific pod.'
16
+ option :container, type: :string, desc: 'Returns only tasks with specific container.'
17
+ option :executor, type: :string, desc: 'Returns only tasks with specific executor.'
18
+ def list()
19
+ if options[:job]
20
+ client = Client::JobResource.new(options)
21
+ puts "#{client.all(options[:job])}"
22
+ else
23
+ if options[:scraper_name]
24
+ client = Client::ScraperResource.new(options)
25
+ puts "#{client.all(options[:scraper_name])}"
26
+ else
27
+ puts 'Must specify either a job ID or a scraper name'
28
+ end
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ end
data/lib/datahen/cli.rb CHANGED
@@ -7,6 +7,7 @@ require 'datahen/cli/scraper_job_var'
7
7
  require 'datahen/cli/scraper_job'
8
8
  require 'datahen/cli/scraper_finisher'
9
9
  require 'datahen/cli/global_page'
10
+ require 'datahen/cli/scraper_resource'
10
11
  require 'datahen/cli/scraper_page'
11
12
  require 'datahen/cli/job_output'
12
13
  require 'datahen/cli/job'
@@ -128,6 +128,10 @@ module Datahen
128
128
  query[:force] = opts[:force] if opts[:force]
129
129
  query[:action] = opts[:action] if opts[:action]
130
130
  query[:"include-system"] = opts[:"include-system"] if opts[:"include-system"]
131
+ query[:"pod"] = opts[:"pod"] if opts[:"pod"]
132
+ query[:"container"] = opts[:"container"] if opts[:"container"]
133
+ query[:"executor"] = opts[:"executor"] if opts[:"executor"]
134
+
131
135
 
132
136
  if opts[:query]
133
137
  if opts[:query].is_a?(Hash)
@@ -29,6 +29,7 @@ module Datahen
29
29
  body[:soft_refetch_limit] = opts[:soft_refetch_limit] if opts[:soft_refetch_limit]
30
30
  body[:parsing_try_limit] = opts[:parsing_try_limit] if opts[:parsing_try_limit]
31
31
  body[:prevent_kb_autoscaler] = opts[:prevent_kb_autoscaler] if opts.has_key?("prevent_kb_autoscaler") || opts.has_key?(:prevent_kb_autoscaler)
32
+ body[:deletion_protected] = opts[:deletion_protected] if opts.has_key?("deletion_protected") || opts.has_key?(:deletion_protected)
32
33
  params = @options.merge({body: body.to_json})
33
34
 
34
35
  self.class.put("/jobs/#{job_id}", params)
@@ -0,0 +1,11 @@
1
+ module Datahen
2
+ module Client
3
+ class JobResource < Datahen::Client::Base
4
+ def all(job_id, opts={})
5
+ params = @options.merge(opts)
6
+ self.class.get("/jobs/#{job_id}/resources", params)
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -19,6 +19,7 @@ module Datahen
19
19
  body[:soft_refetch_limit] = opts[:soft_refetch_limit] if opts[:soft_refetch_limit]
20
20
  body[:parsing_try_limit] = opts[:parsing_try_limit] if opts[:parsing_try_limit]
21
21
  body[:prevent_kb_autoscaler] = opts[:prevent_kb_autoscaler] if opts.has_key?("prevent_kb_autoscaler") || opts.has_key?(:prevent_kb_autoscaler)
22
+ body[:deletion_protected] = opts[:deletion_protected] if opts.has_key?("deletion_protected") || opts.has_key?(:deletion_protected)
22
23
  if opts[:vars]
23
24
  if opts[:vars].is_a?(Array)
24
25
  body[:vars] = opts[:vars]
@@ -53,6 +54,7 @@ module Datahen
53
54
  body[:soft_refetch_limit] = opts[:soft_refetch_limit] if opts[:soft_refetch_limit]
54
55
  body[:parsing_try_limit] = opts[:parsing_try_limit] if opts[:parsing_try_limit]
55
56
  body[:prevent_kb_autoscaler] = opts[:prevent_kb_autoscaler] if opts.has_key?("prevent_kb_autoscaler") || opts.has_key?(:prevent_kb_autoscaler)
57
+ body[:deletion_protected] = opts[:deletion_protected] if opts.has_key?("deletion_protected") || opts.has_key?(:deletion_protected)
56
58
  params = @options.merge({body: body.to_json})
57
59
 
58
60
  self.class.put("/scrapers/#{scraper_name}/current_job", params)
@@ -0,0 +1,11 @@
1
+ module Datahen
2
+ module Client
3
+ class ScraperResource < Datahen::Client::Base
4
+ def all(scraper_name, opts={})
5
+ params = @options.merge(opts)
6
+ self.class.get("/scrapers/#{scraper_name}/resources", params)
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -26,6 +26,8 @@ require "datahen/client/scraper_job_var"
26
26
  require "datahen/client/job_finisher"
27
27
  require "datahen/client/job_task"
28
28
  require "datahen/client/scraper_task"
29
+ require "datahen/client/job_resource"
30
+ require "datahen/client/scraper_resource"
29
31
 
30
32
  module Datahen
31
33
  module Client
@@ -1,3 +1,3 @@
1
1
  module Datahen
2
- VERSION = "1.5.3"
2
+ VERSION = "1.6.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datahen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parama Danoesubroto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-25 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -227,6 +227,7 @@ files:
227
227
  - lib/datahen/cli/scraper_job.rb
228
228
  - lib/datahen/cli/scraper_job_var.rb
229
229
  - lib/datahen/cli/scraper_page.rb
230
+ - lib/datahen/cli/scraper_resource.rb
230
231
  - lib/datahen/cli/scraper_task.rb
231
232
  - lib/datahen/cli/scraper_var.rb
232
233
  - lib/datahen/cli/seeder.rb
@@ -245,6 +246,7 @@ files:
245
246
  - lib/datahen/client/job_log.rb
246
247
  - lib/datahen/client/job_output.rb
247
248
  - lib/datahen/client/job_page.rb
249
+ - lib/datahen/client/job_resource.rb
248
250
  - lib/datahen/client/job_stat.rb
249
251
  - lib/datahen/client/job_task.rb
250
252
  - lib/datahen/client/job_var.rb
@@ -257,6 +259,7 @@ files:
257
259
  - lib/datahen/client/scraper_job_output.rb
258
260
  - lib/datahen/client/scraper_job_page.rb
259
261
  - lib/datahen/client/scraper_job_var.rb
262
+ - lib/datahen/client/scraper_resource.rb
260
263
  - lib/datahen/client/scraper_task.rb
261
264
  - lib/datahen/client/scraper_var.rb
262
265
  - lib/datahen/error.rb
@@ -281,7 +284,7 @@ metadata:
281
284
  allowed_push_host: https://rubygems.org
282
285
  homepage_uri: https://datahen.com
283
286
  source_code_uri: https://github.com/DataHenOfficial/datahen-ruby
284
- post_install_message:
287
+ post_install_message:
285
288
  rdoc_options: []
286
289
  require_paths:
287
290
  - lib
@@ -296,8 +299,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
299
  - !ruby/object:Gem::Version
297
300
  version: '0'
298
301
  requirements: []
299
- rubygems_version: 3.0.3
300
- signing_key:
302
+ rubygems_version: 3.5.6
303
+ signing_key:
301
304
  specification_version: 4
302
305
  summary: DataHen toolbelt for developers
303
306
  test_files: []