Skip to content

Commit 3188ec8

Browse files
💥 ♻️ uniformize syntaxes with other SDKs
1 parent 0dec523 commit 3188ec8

File tree

100 files changed

+533
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+533
-701
lines changed
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Code Samples
1+
name: Smoke Test
22

33
on:
44
workflow_call:
@@ -9,12 +9,13 @@ env:
99
MINDEE_ACCOUNT_SE_TESTS: ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }}
1010
MINDEE_API_KEY_SE_TESTS: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
1111
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
12-
MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
13-
MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}
14-
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
15-
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
16-
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
17-
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
12+
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
13+
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
14+
MINDEE_V2_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
15+
MINDEE_V2_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
16+
MINDEE_V2_FAILURE_WEBHOOK_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FAILURE_WEBHOOK_ID }}
17+
MINDEE_V2_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
18+
MINDEE_V2_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
1819

1920
jobs:
2021
test:
@@ -44,7 +45,7 @@ jobs:
4445
env:
4546
MINDEE_LOG_LEVEL: DEBUG
4647
run: |
47-
./spec/test_code_samples_v1.sh
48+
./spec/test_code_samples_v1.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }}
4849
4950
- name: Tests V2 code samples
5051
env:

.github/workflows/cron.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ on:
55
- cron: '0 0 * * *'
66

77
jobs:
8-
test_code_samples:
9-
uses: mindee/mindee-api-ruby/.github/workflows/_test-code-samples.yml@main
8+
test-smoke:
9+
uses: mindee/mindee-api-ruby/.github/workflows/_test-smoke.yml@main
1010
secrets: inherit

.github/workflows/publish-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
types: [ published ]
66

77
jobs:
8-
publish_docs:
8+
publish-docs:
99
uses: mindee/mindee-api-ruby/.github/workflows/_publish-docs.yml@main
1010
secrets: inherit
11-
publish_guide:
11+
publish-guide:
1212
uses: mindee/mindee-api-ruby/.github/workflows/_publish-guide.yml@main
13-
needs: publish_docs
13+
needs: publish-docs
1414
secrets: inherit
15-
publish_code:
15+
publish-code:
1616
uses: mindee/mindee-api-ruby/.github/workflows/_publish-code.yml@main
1717
secrets: inherit

.github/workflows/pull-request.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ permissions:
88
pull-requests: read
99

1010
jobs:
11-
static_analysis:
11+
static-analysis:
1212
uses: ./.github/workflows/_static-analysis.yml
13-
test_units:
13+
test-units:
1414
uses: ./.github/workflows/_test-units.yml
15-
needs: static_analysis
15+
needs: static-analysis
1616
secrets: inherit
17-
test_integrations:
17+
test-integrations:
1818
uses: ./.github/workflows/_test-integrations.yml
19-
needs: test_units
19+
needs: test-units
2020
secrets: inherit
21-
test_code_samples:
22-
uses: ./.github/workflows/_test-code-samples.yml
23-
needs: test_units
21+
test-smoke:
22+
uses: ./.github/workflows/_test-smoke.yml
23+
needs: test-units
2424
secrets: inherit

.github/workflows/push-main-branch.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
- main
77

88
jobs:
9-
static_analysis:
9+
static-analysis:
1010
uses: mindee/mindee-api-ruby/.github/workflows/_static-analysis.yml@main
11-
test_units:
11+
test-units:
1212
uses: mindee/mindee-api-ruby/.github/workflows/_test-units.yml@main
13-
needs: static_analysis
13+
needs: static-analysis
1414
secrets: inherit
1515
tag:
1616
uses: mindee/client-lib-actions/.github/workflows/tag-version.yml@main
17-
needs: test_units
17+
needs: test-units
1818
release:
1919
uses: mindee/client-lib-actions/.github/workflows/create-release.yml@main
2020
needs: tag

docs/code_samples/v2_extraction.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ model_id = 'MY_MODEL_ID'
1111
mindee_client = Mindee::ClientV2.new(api_key: api_key)
1212

1313
# Set inference parameters
14-
inference_params = {
14+
extraction_params = {
1515
# ID of the model, required.
1616
model_id: model_id,
1717

@@ -35,7 +35,7 @@ input_source = Mindee::Input::Source::PathInputSource.new(input_path)
3535
response = mindee_client.enqueue_and_get_result(
3636
Mindee::V2::Product::Extraction::Extraction,
3737
input_source,
38-
inference_params
38+
extraction_params
3939
)
4040

4141
# Print a brief summary of the parsed data

docs/code_samples/v2_extraction_webhook.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ model_id = 'MY_MODEL_ID'
1010
# Init a new client
1111
mindee_client = Mindee::ClientV2.new(api_key: api_key)
1212

13-
inference_params = {
13+
extraction_params = {
1414
# ID of the model, required.
1515
model_id: model_id,
1616
# Add any number of webhook IDs here.
@@ -36,7 +36,7 @@ input_source = Mindee::Input::Source::PathInputSource.new(input_path)
3636
response = mindee_client.enqueue(
3737
Mindee::V2::Product::Extraction::Extraction,
3838
input_source,
39-
inference_params
39+
extraction_params
4040
)
4141

4242
# Print the job ID

lib/mindee/client_v2.rb

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,27 @@ def initialize(api_key: '')
1919
@mindee_api = Mindee::HTTP::MindeeApiV2.new(api_key: api_key)
2020
end
2121

22-
# Retrieves an inference.
23-
# @param inference_id [String]
24-
# @return [Mindee::Parsing::V2::InferenceResponse]
25-
def get_inference(inference_id)
26-
@mindee_api.req_get_inference(inference_id)
27-
end
28-
2922
# Retrieves a result from a given queue or URL to the result.
3023
# @param product [Class<Mindee::V2::Product::BaseProduct>] The return class.
3124
# @param resource [String] ID of the inference or URL to the result.
32-
# @return [Mindee::Parsing::V2::BaseResponse]
25+
# @return [Mindee::V2::Parsing::BaseResponse]
3326
def get_result(product, resource)
3427
@mindee_api.req_get_result(product, resource)
3528
end
3629

3730
# Retrieves an inference from a given queue or URL to the job.
3831
# @param job_id [String] ID of the job.
39-
# @return [Mindee::Parsing::V2::JobResponse]
32+
# @return [Mindee::V2::Parsing::JobResponse]
4033
def get_job(job_id)
4134
@mindee_api.req_get_job(job_id)
4235
end
4336

44-
# Enqueue a document for async parsing.
45-
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
46-
# The source of the input document (local file or URL).
47-
# @param params [Hash, InferenceParameters]
48-
# @return [Mindee::Parsing::V2::JobResponse]
49-
def enqueue_inference(input_source, params, disable_redundant_warnings: false)
50-
unless disable_redundant_warnings
51-
warn '[DEPRECATION] `enqueue_inference` is deprecated; use `enqueue` instead.', uplevel: 1
52-
end
53-
normalized_params = normalize_parameters(Input::InferenceParameters, params)
54-
enqueue(Mindee::Parsing::V2::Inference, input_source, normalized_params)
55-
end
56-
5737
# Enqueue a document for async parsing.
5838
# @param product [Class<Mindee::V2::Product::BaseProduct>] The return class.
5939
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
6040
# The source of the input document (local file or URL).
61-
# @param params [Hash, InferenceParameters] Parameters for the inference.
62-
# @return [Mindee::Parsing::V2::JobResponse]
41+
# @param params [Hash, Input::BaseParameters] Parameters for the inference.
42+
# @return [Mindee::V2::Parsing::JobResponse]
6343
def enqueue(
6444
product,
6545
input_source,
@@ -77,8 +57,8 @@ def enqueue(
7757
# @param product [Class<Mindee::V2::Product::BaseProduct>] The return class.
7858
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
7959
# The source of the input document (local file or URL).
80-
# @param params [Hash, InferenceParameters] Parameters for the inference.
81-
# @return [Mindee::Parsing::Common::ApiResponse]
60+
# @param params [Hash, Input::BaseParameters] Parameters for the inference.
61+
# @return [Parsing::BaseResponse]
8262
def enqueue_and_get_result(
8363
product,
8464
input_source,
@@ -130,26 +110,7 @@ def enqueue_and_get_result(
130110
"Asynchronous parsing request timed out after #{sec_count} seconds"
131111
end
132112

133-
# Enqueue a document for async parsing and automatically try to retrieve it.
134-
# @param input_source [Mindee::Input::Source::LocalInputSource, Mindee::Input::Source::URLInputSource]
135-
# The source of the input document (local file or URL).
136-
# @param params [Hash, InferenceParameters] Parameters for the inference.
137-
# @return [Mindee::Parsing::V2::InferenceResponse]
138-
def enqueue_and_get_inference(input_source, params, disable_redundant_warnings: false)
139-
unless disable_redundant_warnings
140-
warn '[DEPRECATION] `enqueue_and_get_inference` is deprecated; use `enqueue_and_get_result` instead.',
141-
uplevel: 1
142-
end
143-
144-
response = enqueue_and_get_result(Mindee::Parsing::V2::Inference, input_source, params)
145-
unless response.is_a?(Mindee::Parsing::V2::InferenceResponse)
146-
raise TypeError, "Invalid response type \"#{response.class}\""
147-
end
148-
149-
response
150-
end
151-
152-
# If needed, converts the parsing options provided as a hash into a proper InferenceParameters object.
113+
# If needed, converts the parsing options provided as a hash into a proper BaseParameters subclass object.
153114
# @param params [Hash, Class<BaseParameters>] Params.
154115
# @return [BaseParameters]
155116
def normalize_parameters(param_class, params)

lib/mindee/errors/mindee_http_error_v2.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
require_relative 'mindee_error'
4-
require_relative '../parsing/v2/error_item'
4+
require_relative '../v2/parsing/error_item'
55

66
module Mindee
77
module Errors
@@ -18,9 +18,9 @@ class MindeeHTTPErrorV2 < MindeeError
1818
# @return [Array<ErrorItem>] A list of explicit error details.
1919
attr_reader :errors
2020

21-
# @param http_error [Hash, Mindee::Parsing::V2::ErrorResponse]
21+
# @param http_error [Hash, Mindee::V2::Parsing::ErrorResponse]
2222
def initialize(http_error)
23-
if http_error.is_a?(Parsing::V2::ErrorResponse)
23+
if http_error.is_a?(V2::Parsing::ErrorResponse)
2424
http_error = { 'detail' => http_error.detail,
2525
'status' => http_error.status,
2626
'title' => http_error.title,
@@ -33,7 +33,7 @@ def initialize(http_error)
3333
@code = http_error['code']
3434
@errors = if http_error.key?('errors')
3535
http_error['errors'].map do |error|
36-
Mindee::Parsing::V2::ErrorItem.new(error)
36+
Mindee::V2::Parsing::ErrorItem.new(error)
3737
end
3838
else
3939
[]

lib/mindee/http/api_settings_v2.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ApiSettingsV2
1414
# V2 base URL default environment key name.
1515
MINDEE_V2_BASE_URL_ENV_NAME = 'MINDEE_V2_BASE_URL'
1616
# V2 base URL default value.
17-
MINDEE_V2_BASE_URL_DEFAULT = 'https://api-v2.mindee.net/v2'
17+
MINDEE_V2_BASE_URL_DEFAULT = 'https://api-v2.mindee.net'
1818

1919
# HTTP request timeout default environment key name.
2020
MINDEE_V2_REQUEST_TIMEOUT_ENV_NAME = 'MINDEE_V2_REQUEST_TIMEOUT'

0 commit comments

Comments
 (0)