Skip to content

Added config parameter #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion textractor/textractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import uuid
from PIL import Image
from copy import deepcopy
from botocore.config import Config
from typing import List, Union
from textractcaller import (
call_textract,
Expand Down Expand Up @@ -79,17 +80,21 @@ class Textractor:
:type profile_name: str, optional
:param kms_key_id: Customer's AWS KMS key (cryptographic key)
:type kms_key_id: str, optional
:param config: Botocore Config object to add additional configurations
:type config: botocore.config.Config, optional
"""

def __init__(
self,
profile_name: str = None,
region_name: str = None,
kms_key_id: str = "",
config: Config = None,
):
self.profile_name = profile_name
self.region_name = region_name
self.kms_key_id = kms_key_id
self.config = config

if self.profile_name is not None:
self.session = boto3.session.Session(profile_name=self.profile_name)
Expand All @@ -103,7 +108,11 @@ def __init__(
raise InputError(
"Unable to initiate Textractor. Either profile_name or region requires an input parameter."
)
if self.region_name is not None:
if self.region_name is not None and self.config is not None:
self.textract_client = self.session.client(
"textract", region_name=self.region_name, config=self.config
)
elif self.region_name is not None:
self.textract_client = self.session.client(
"textract", region_name=self.region_name
)
Expand Down