scaleapi 0.7.0 → 0.8.0

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
  SHA1:
3
- metadata.gz: f64310f0a86e358c3276470614a1765d3c159451
4
- data.tar.gz: 08a1d94d7a89806c4d0797b4fe850f4b0e41bf6a
3
+ metadata.gz: 8cb383bc4a0b712791bf78fd77c8832c8cc5b234
4
+ data.tar.gz: 2bbdafb977cd3a8f4978eca2000960788cc09815
5
5
  SHA512:
6
- metadata.gz: f5c2d38c5c9900a3ff93be46c0dd378794a14e093821470c65aaf2815c9fbf8be8780c326bb718d356231da8018dc83f771215cf0e3428193ae7942ed0dd8d73
7
- data.tar.gz: f3ac401696810987741e607cc80937e14be0c90e25667985092b92cf1621026c9ae49b2e8bf53f4ecc2531d23a2421324664fe2875b77f17f1b7d59cbf0cb08a
6
+ metadata.gz: d96f6bb45ad25adb85661bd48dacab9e65120681914f2d25455e2e9aa021d5250ca3ec7f853dbd18ae3e0fa66915ab42ca624d5125f56ba8013434aefb572254
7
+ data.tar.gz: 442478afc12398266fb996dd6990ca3bd59cd9bffab2dd6b266737d274ecd1eba0c1f4d9ca4c58678278f7aca45dc3a18b687bfd10fc30a10ac6100519acac81
@@ -1,6 +1,35 @@
1
1
  class Scale
2
2
  attr_accessor :api_key, :callback_auth_key, :default_request_params, :logging
3
3
 
4
+ VALID_TASK_TYPES = [
5
+ "datacollection",
6
+ "categorization",
7
+ "comparison",
8
+ "annotation",
9
+ "polygonannotation",
10
+ "lineannotation",
11
+ "transcription",
12
+ "audiotranscription",
13
+ "pointannotation",
14
+ "segmentannotation"
15
+ ].freeze
16
+
17
+ def method_missing(methodId, *args, &block)
18
+ str = methodId.id2name
19
+ match = /^create_([a-z_]+)_task$/.match(str)
20
+ if match
21
+ taskType = match[1].gsub(/[^a-z]/, '')
22
+ taskType = "annotation" if taskType == "imagerecognition"
23
+ if VALID_TASK_TYPES.include?(taskType)
24
+ create_task(match[1], *args)
25
+ else
26
+ raise ArgumentError.new("Method `#{methodId}` doesn't exist.")
27
+ end
28
+ else
29
+ raise ArgumentError.new("Method `#{methodId}` doesn't exist.")
30
+ end
31
+ end
32
+
4
33
  def self.validate_api_key(api_key)
5
34
  if api_key.length < 5 || !(api_key.start_with?('live') || api_key.start_with?('test'))
6
35
  raise Api::APIKeyInvalid
@@ -32,48 +61,8 @@ class Scale
32
61
  @tasks ||= Scale::Api::Tasks.new(client)
33
62
  end
34
63
 
35
- def create_datacollection_task(args = {})
36
- Api::Tasks::Datacollection.create(args.merge(client: client))
37
- end
38
-
39
- def create_categorization_task(args = {})
40
- Api::Tasks::Categorization.create(args.merge(client: client))
41
- end
42
-
43
- def create_comparison_task(args = {})
44
- Api::Tasks::Comparison.create(args.merge(client: client))
45
- end
46
-
47
- def create_image_recognition_task(args = {})
48
- Api::Tasks::ImageRecognition.create(args.merge(client: client))
49
- end
50
-
51
- def create_polygonannotation_task(args = {})
52
- Api::Tasks::Polygonannotation.create(args.merge(client: client))
53
- end
54
-
55
- def create_lineannotation_task(args = {})
56
- Api::Tasks::Lineannotation.create(args.merge(client: client))
57
- end
58
-
59
- def create_phone_call_task(args = {})
60
- Api::Tasks::PhoneCall.create(args.merge(client: client))
61
- end
62
-
63
- def create_transcription_task(args = {})
64
- Api::Tasks::Transcription.create(args.merge(client: client))
65
- end
66
-
67
- def create_audio_transcription_task(args = {})
68
- Api::Tasks::AudioTranscription.create(args.merge(client: client))
69
- end
70
-
71
- def create_pointannotation_task(args = {})
72
- Api::Tasks::Pointannotation.create(args.merge(client: client))
73
- end
74
-
75
- def create_segmentannotation_task(args = {})
76
- Api::Tasks::Segmentannotation.create(args.merge(client: client))
64
+ def create_task(type, args = {})
65
+ client.create_task(type, args)
77
66
  end
78
67
 
79
68
  def build_callback(params, callback_key: nil)
@@ -90,25 +79,10 @@ class Scale
90
79
  alias_method :test, :test?
91
80
  alias_method :live_mode?, :live?
92
81
  alias_method :test_mode?, :test?
93
- alias_method :create_annotation_task, :create_image_recognition_task
94
- alias_method :create_phonecall_task, :create_phone_call_task
95
- alias_method :create_audiotranscription_task, :create_audio_transcription_task
96
82
  end
97
83
 
98
84
  require 'scale/api'
99
85
  require 'scale/api/errors'
100
- require 'scale/api/callback'
101
86
  require 'scale/api/tasks'
102
- require 'scale/api/tasks/audio_transcription'
103
- require 'scale/api/tasks/base_task'
104
- require 'scale/api/tasks/datacollection'
105
- require 'scale/api/tasks/categorization'
106
- require 'scale/api/tasks/comparison'
107
- require 'scale/api/tasks/image_recognition'
108
- require 'scale/api/tasks/polygonannotation'
109
- require 'scale/api/tasks/lineannotation'
110
- require 'scale/api/tasks/phone_call'
111
- require 'scale/api/tasks/transcription'
112
- require 'scale/api/tasks/pointannotation'
113
- require 'scale/api/tasks/segmentannotation'
87
+ require 'scale/api/callback'
114
88
  require 'scale/api/task_list'
@@ -5,6 +5,8 @@ require 'json'
5
5
  class Scale
6
6
  class Api < Struct.new(:api_key, :callback_auth_key, :default_request_params, :logging)
7
7
  SCALE_API_URL = 'https://api.scaleapi.com/v1/'
8
+ SCALEAPI_GEM_INFO = Gem.loaded_specs["scaleapi"]
9
+ SCALE_RUBY_CLIENT_VERSION = SCALEAPI_GEM_INFO ? SCALEAPI_GEM_INFO.version : '0.1.1'.freeze
8
10
 
9
11
  def connection
10
12
  @connection ||= Faraday.new(:url => SCALE_API_URL) do |faraday|
@@ -20,7 +22,7 @@ class Scale
20
22
  req.url "#{SCALE_API_URL}#{url}"
21
23
  req.params.merge!(default_request_params.merge(params))
22
24
  req.headers['X-API-Client'] = "Ruby"
23
- req.headers["X-API-Client-Version"] = '0.1.0'
25
+ req.headers["X-API-Client-Version"] = SCALE_RUBY_CLIENT_VERSION
24
26
  end
25
27
 
26
28
  if response.status != 200
@@ -41,7 +43,7 @@ class Scale
41
43
  req.headers['Content-Type'] = 'application/json'
42
44
  req.body = body.to_json
43
45
  req.headers['X-API-Client'] = "Ruby"
44
- req.headers["X-API-Client-Version"] = '0.1.0'
46
+ req.headers["X-API-Client-Version"] = SCALE_RUBY_CLIENT_VERSION
45
47
  end
46
48
 
47
49
  if response.status != 200
@@ -69,7 +71,14 @@ class Scale
69
71
  rescue JSON::ParserError
70
72
  raise Scale::Api::InternalServerError
71
73
  end
74
+
75
+ def create_task(type, args = {})
76
+ response = post("task/${type}", args)
77
+ Api::Tasks::BaseTask.new(JSON.parse(response.body), self)
78
+ end
72
79
  end
73
80
  end
74
81
 
82
+ require 'scale/api/tasks'
83
+ require 'scale/api/tasks/base_task'
75
84
  require 'scale/api/errors'
@@ -10,7 +10,7 @@ class Scale
10
10
 
11
11
  if params['task']
12
12
  @task_id = params['task']['id']
13
- @task = Scale::Api::Tasks::BaseTask.from_hash(params['task'].merge('client' => client))
13
+ @task = Scale::Api::Tasks::BaseTask.new(params['task'], client)
14
14
  end
15
15
  end
16
16
 
@@ -1,15 +1,4 @@
1
1
  require 'scale/api/tasks/base_task'
2
- require 'scale/api/tasks/audio_transcription'
3
- require 'scale/api/tasks/datacollection'
4
- require 'scale/api/tasks/categorization'
5
- require 'scale/api/tasks/comparison'
6
- require 'scale/api/tasks/image_recognition'
7
- require 'scale/api/tasks/polygonannotation'
8
- require 'scale/api/tasks/lineannotation'
9
- require 'scale/api/tasks/phone_call'
10
- require 'scale/api/tasks/transcription'
11
- require 'scale/api/tasks/segmentannotation'
12
- require 'scale/api/tasks/pointannotation'
13
2
 
14
3
  class Scale
15
4
  class Api
@@ -18,24 +7,11 @@ class Scale
18
7
  extend Forwardable
19
8
  def_delegators :@docs, :each, :<<, :[], :[]=, :length, :count
20
9
  attr_accessor :client, :docs, :limit, :offset, :has_more, :params
21
- TASK_TYPES_TO_CLASSNAMES = {
22
- 'audiotranscription' => ::Scale::Api::Tasks::AudioTranscription,
23
- 'categorization' => ::Scale::Api::Tasks::Categorization,
24
- 'comparison' => ::Scale::Api::Tasks::Comparison,
25
- 'datacollection' => ::Scale::Api::Tasks::Datacollection,
26
- 'annotation' => ::Scale::Api::Tasks::ImageRecognition,
27
- 'polygonannotation' => ::Scale::Api::Tasks::Polygonannotation,
28
- 'lineannotation' => ::Scale::Api::Tasks::Lineannotation,
29
- 'phonecall' => ::Scale::Api::Tasks::PhoneCall,
30
- 'transcription' => ::Scale::Api::Tasks::Transcription,
31
- 'pointannotation' => ::Scale::Api::Tasks::Pointannotation,
32
- 'segmentannotation' => ::Scale::Api::Tasks::Segmentannotation
33
- }.freeze
34
10
 
35
11
  def initialize(client: nil, docs: [], limit: 99, offset: 0, has_more: false, params: {})
36
12
  self.client = client
37
13
  self.docs = docs.map do |doc|
38
- ::Scale::Api::Tasks::BaseTask.from_hash(doc.merge('client' => client))
14
+ ::Scale::Api::Tasks::BaseTask.new(doc, client)
39
15
  end
40
16
 
41
17
  self.limit = limit
@@ -26,24 +26,18 @@ class Scale
26
26
 
27
27
  def find(task_id)
28
28
  response = client.get("task/#{task_id}")
29
- BaseTask.from_hash(JSON.parse(response.body).merge('client' => client))
29
+ BaseTask.new(JSON.parse(response.body), client)
30
30
  end
31
31
 
32
32
  def cancel(task_id)
33
33
  response = client.post("task/#{task_id}/cancel")
34
- BaseTask.from_hash(JSON.parse(response.body).merge('client' => client))
34
+ BaseTask.new(JSON.parse(response.body), client)
35
35
  end
36
36
 
37
37
  def create(args = {})
38
38
  raise ArgumentError.new('Task type is required') if (args[:type].nil? && args['type'].nil?)
39
- klass = ::Scale::Api::TaskList::TASK_TYPES_TO_CLASSNAMES[(args[:type] || args['type']).to_s]
40
-
41
- unless klass
42
- raise ArgumentError.new('Unsupported task type. Supported task types: ' + ::Scale::Api::TaskList::TASK_TYPES_TO_CLASSNAMES.keys.join(','))
43
- end
44
-
45
- args.delete(:type)
46
- klass.create(args.merge(client: client))
39
+ type = args.delete(:type)
40
+ client.create_task(type, args)
47
41
  end
48
42
 
49
43
  alias_method :all, :list
@@ -4,28 +4,23 @@ class Scale
4
4
  class Api
5
5
  class Tasks
6
6
  class BaseTask
7
- attr_accessor :client
8
- ATTRIBUTES = %w(task_id type instruction params urgency response callback_url created_at status completed_at callback_succeeded_at metadata).freeze
9
- ATTRIBUTES.each { |attr| attr_reader attr }
10
-
11
- alias_method :id, :task_id
12
-
13
- def self.from_hash(hash)
14
- klass = ::Scale::Api::TaskList::TASK_TYPES_TO_CLASSNAMES[(hash[:type] || hash['type']).to_s] || self
15
- klass.new(hash)
7
+ def method_missing(methodId, *args, &block)
8
+ str = methodId.id2name
9
+ value = @data[str]
10
+ if value
11
+ value
12
+ else
13
+ raise ArgumentError.new("Method `#{methodId}` doesn't exist.")
14
+ end
16
15
  end
17
16
 
18
17
  def cancel!
19
18
  Tasks.new(client).cancel(id)
20
19
  end
21
20
 
22
- def initialize(json = {})
23
-
24
- ATTRIBUTES.each do |attr|
25
- instance_variable_set "@#{attr}", json[attr]
26
- end
27
-
28
- @client = (json[:client] || json['client'])
21
+ def initialize(json = {}, theClient = nil)
22
+ @client = theClient
23
+ @data = json
29
24
 
30
25
  tweak_attributes
31
26
  end
@@ -58,6 +53,14 @@ class Scale
58
53
  !!callback_succeeded_at
59
54
  end
60
55
 
56
+ def id
57
+ task_id
58
+ end
59
+
60
+ def raw_json
61
+ @data
62
+ end
63
+
61
64
  protected
62
65
 
63
66
  def tweak_attributes
@@ -4,9 +4,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "scaleapi"
7
- spec.version = "0.7.0"
7
+ spec.version = "0.8.0"
8
8
  spec.authors = ["Alexandr Wang"]
9
- spec.email = ["alex@scaleapi.com"]
9
+ spec.email = ["alex@scaleapi.com", "roy@scaleapi.com"]
10
10
 
11
11
  spec.summary = %q{Official Ruby Client for Scale API}
12
12
  spec.description = %q{Scale is an API For Human Intelligence. Get high quality results for all sorts of tasks within minutes. This is the official Ruby client.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scaleapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandr Wang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2017-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,6 +56,7 @@ description: Scale is an API For Human Intelligence. Get high quality results fo
56
56
  all sorts of tasks within minutes. This is the official Ruby client.
57
57
  email:
58
58
  - alex@scaleapi.com
59
+ - roy@scaleapi.com
59
60
  executables: []
60
61
  extensions: []
61
62
  extra_rdoc_files: []
@@ -73,18 +74,7 @@ files:
73
74
  - lib/scale/api/errors.rb
74
75
  - lib/scale/api/task_list.rb
75
76
  - lib/scale/api/tasks.rb
76
- - lib/scale/api/tasks/audio_transcription.rb
77
77
  - lib/scale/api/tasks/base_task.rb
78
- - lib/scale/api/tasks/categorization.rb
79
- - lib/scale/api/tasks/comparison.rb
80
- - lib/scale/api/tasks/datacollection.rb
81
- - lib/scale/api/tasks/image_recognition.rb
82
- - lib/scale/api/tasks/lineannotation.rb
83
- - lib/scale/api/tasks/phone_call.rb
84
- - lib/scale/api/tasks/pointannotation.rb
85
- - lib/scale/api/tasks/polygonannotation.rb
86
- - lib/scale/api/tasks/segmentannotation.rb
87
- - lib/scale/api/tasks/transcription.rb
88
78
  - scaleapi-ruby.gemspec
89
79
  homepage: https://www.scaleapi.com
90
80
  licenses:
@@ -1,26 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class AudioTranscription < BaseTask
8
- CREATE_PATH = 'task/audiotranscription'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: 'audio', attachment: nil, verbatim: false, urgency: 'day', metadata: {}, client: nil)
11
- response = client.post(CREATE_PATH, {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- verbatim: verbatim,
17
- urgency: urgency,
18
- metadata: metadata
19
- })
20
-
21
- AudioTranscription.new(JSON.parse(response.body))
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,33 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class Categorization < BaseTask
8
- CREATE_PATH = 'task/categorize'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, categories: [], layers: nil, urgency: 'day', category_ids: {}, allow_multiple: false, metadata: {}, client: nil)
11
- body = {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- categories: categories,
17
- urgency: urgency,
18
- category_ids: category_ids,
19
- allow_multiple: allow_multiple,
20
- metadata: metadata,
21
- layers: layers
22
- }
23
-
24
- body.delete(:category_ids) if category_ids.keys.count.zero?
25
- body.delete(:categories) if categories.count.zero?
26
-
27
- response = client.post(CREATE_PATH, body)
28
- Categorization.new(JSON.parse(response.body))
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,27 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class Comparison < BaseTask
8
- CREATE_PATH = 'task/comparison'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachments: [], fields: {}, urgency: 'day', choices: {}, metadata: {}, client: nil)
11
- response = client.post(CREATE_PATH, {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachments: attachments,
16
- fields: fields,
17
- choices: choices,
18
- urgency: urgency,
19
- metadata: metadata
20
- })
21
-
22
- Comparison.new(JSON.parse(response.body))
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,26 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class Datacollection < BaseTask
8
- CREATE_PATH = 'task/datacollection'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, fields: {}, urgency: 'day', metadata: {}, client: nil)
11
- response = client.post(CREATE_PATH, {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- fields: fields,
17
- urgency: urgency,
18
- metadata: metadata
19
- })
20
-
21
- Datacollection.new(JSON.parse(response.body))
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,32 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class ImageRecognition < Scale::Api::Tasks::BaseTask
8
- CREATE_PATH = 'task/annotation'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, objects_to_annotate: [], with_labels: false, min_width: nil, min_height: nil, layers: nil, examples: [], urgency: 'day', metadata: {}, annotation_attributes: nil, client: nil)
11
- response = client.post(CREATE_PATH, {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- objects_to_annotate: objects_to_annotate,
17
- with_labels: with_labels,
18
- min_width: min_width,
19
- min_height: min_height,
20
- examples: examples,
21
- urgency: urgency,
22
- metadata: metadata,
23
- layers: layers,
24
- annotation_attributes: annotation_attributes
25
- })
26
-
27
- ImageRecognition.new(JSON.parse(response.body))
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,31 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class Lineannotation < Scale::Api::Tasks::BaseTask
8
- CREATE_PATH = 'task/lineannotation'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, objects_to_annotate: [], with_labels: false, layers: nil, examples: [], urgency: 'day', splines: false, annotation_attributes: nil, metadata: {}, client: nil)
11
- response = client.post(CREATE_PATH, {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- objects_to_annotate: objects_to_annotate,
17
- with_labels: with_labels,
18
- examples: examples,
19
- urgency: urgency,
20
- metadata: metadata,
21
- layers: layers,
22
- splines: splines,
23
- annotation_attributes: annotation_attributes
24
- })
25
-
26
- Lineannotation.new(JSON.parse(response.body))
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,18 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class PhoneCall < Scale::Api::Tasks::BaseTask
8
- CREATE_PATH = 'task/phonecall'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, phone_number: nil, script: nil, entity_name: nil, attachment: nil, attachment_type: nil, fields: {}, choices: {}, urgency: 'day', metadata: {}, client: nil)
11
- message = 'Phone call tasks have been deprecated and are no longer available.'
12
- pp message
13
- raise ScaleApi::Api::BadRequest.new(message)
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,30 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class Pointannotation < Scale::Api::Tasks::BaseTask
8
- CREATE_PATH = 'task/polygonannotation'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, objects_to_annotate: [], with_labels: false, layers: nil, examples: [], urgency: 'day', metadata: {}, annotation_attributes: nil, client: nil)
11
- response = client.post(CREATE_PATH, {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- objects_to_annotate: objects_to_annotate,
17
- with_labels: with_labels,
18
- examples: examples,
19
- urgency: urgency,
20
- metadata: metadata,
21
- layers: layers,
22
- annotation_attributes: annotation_attributes
23
- })
24
-
25
- Pointannotation.new(JSON.parse(response.body))
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,30 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class Polygonannotation < Scale::Api::Tasks::BaseTask
8
- CREATE_PATH = 'task/polygonannotation'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, objects_to_annotate: [], with_labels: false, layers: nil, examples: [], urgency: 'day', metadata: {}, annotation_attributes: nil, client: nil)
11
- response = client.post(CREATE_PATH, {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- objects_to_annotate: objects_to_annotate,
17
- with_labels: with_labels,
18
- examples: examples,
19
- urgency: urgency,
20
- metadata: metadata,
21
- layers: layers,
22
- annotation_attributes: annotation_attributes
23
- })
24
-
25
- Polygonannotation.new(JSON.parse(response.body))
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,27 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class Segmentannotation < Scale::Api::Tasks::BaseTask
8
- CREATE_PATH = 'task/segmentannotation'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, attachment: nil, labels: [], allow_unlabeled: false, layers: nil, examples: [], urgency: 'day', metadata: {}, client: nil)
11
- response = client.post(CREATE_PATH, {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- labels: labels,
17
- allow_unlabeled: allow_unlabeled,
18
- urgency: urgency,
19
- metadata: metadata
20
- })
21
-
22
- Segmentannotation.new(JSON.parse(response.body))
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,30 +0,0 @@
1
- require 'json'
2
- require 'scale/api/tasks/base_task'
3
-
4
- class Scale
5
- class Api
6
- class Tasks
7
- class Transcription < BaseTask
8
- CREATE_PATH = 'task/transcription'.freeze
9
-
10
- def self.create(callback_url: nil, instruction: nil, attachment_type: nil, choices: {}, attachment: nil, fields: {}, urgency: 'day', metadata: {}, client: nil, repeatable_fields: nil)
11
- args = {
12
- callback_url: callback_url,
13
- instruction: instruction,
14
- attachment_type: attachment_type,
15
- attachment: attachment,
16
- fields: fields,
17
- choices: choices,
18
- urgency: urgency,
19
- metadata: metadata
20
- }
21
- if repeatable_fields != nil
22
- args['repeatable_fields'] = repeatable_fields
23
- end
24
- response = client.post(CREATE_PATH, args)
25
- Transcription.new(JSON.parse(response.body))
26
- end
27
- end
28
- end
29
- end
30
- end