Skip to content

Commit

Permalink
Automated Commit - Formatting Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alafanechere authored and octavia-squidington-iii committed Oct 27, 2023
1 parent 23fbc44 commit 73a2959
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 2 additions & 3 deletions airbyte-ci/connectors/base_images/base_images/bases.py
Expand Up @@ -6,7 +6,7 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import final, Type
from typing import Type, final

import dagger
import semver
Expand All @@ -19,7 +19,6 @@ class AirbyteConnectorBaseImage(ABC):
Please do not declare any Dagger with_exec instruction in this class as in the abstract class context we have no guarantee about the underlying system used in the base image.
"""


@final
def __init__(self, dagger_client: dagger.Client, version: semver.VersionInfo):
"""Initializes the Airbyte base image.
Expand All @@ -32,7 +31,7 @@ def __init__(self, dagger_client: dagger.Client, version: semver.VersionInfo):
self.version = version

# INSTANCE PROPERTIES:

@property
def name_with_tag(self) -> str:
"""Returns the full name of the Airbyte base image, with its tag.
Expand Down
17 changes: 9 additions & 8 deletions airbyte-ci/connectors/base_images/base_images/python/bases.py
Expand Up @@ -4,14 +4,15 @@

from __future__ import annotations

from typing import Final, Callable
import textwrap
from typing import Callable, Final

import dagger
from base_images import bases, published_image
from base_images import sanity_checks as base_sanity_checks
from base_images.python import sanity_checks as python_sanity_checks
from base_images.root_images import PYTHON_3_9_18
import textwrap


class AirbytePythonConnectorBaseImage(bases.AirbyteConnectorBaseImage):

Expand All @@ -20,7 +21,6 @@ class AirbytePythonConnectorBaseImage(bases.AirbyteConnectorBaseImage):
pip_cache_name: Final[str] = "pip-cache"

def install_file_based_connector_dependencies(self) -> Callable:

def download_ntlk_data() -> dagger.Directory:
nltk_python_script = textwrap.dedent(
"""
Expand All @@ -31,13 +31,14 @@ def download_ntlk_data() -> dagger.Directory:
)

return (
self.dagger_client.container().from_(self.root_image.address)
self.dagger_client.container()
.from_(self.root_image.address)
.with_exec(["python", "-m", "pip", "install", "nltk==3.8.1"], skip_entrypoint=True)
.with_new_file("/tmp/nltk_python_script.py", nltk_python_script)
.with_exec(["python", "/tmp/nltk_python_script.py"], skip_entrypoint=True)
.directory("/usr/local/nltk_data")
)

def with_tesseract_and_poppler(container: dagger.Container) -> dagger.Container:
"""
Installs Tesseract-OCR and Poppler-utils in the base image. These tools are necessary for
Expand All @@ -49,7 +50,7 @@ def with_tesseract_and_poppler(container: dagger.Container) -> dagger.Container:
)

return container

def with_file_based_connector_dependencies(container: dagger.Container) -> dagger.Container:
"""
Installs the dependencies for file-based connectors. This includes:
Expand All @@ -59,8 +60,8 @@ def with_file_based_connector_dependencies(container: dagger.Container) -> dagge
"""
container = container.with_directory("/usr/local/nltk_data", download_ntlk_data())
container = with_tesseract_and_poppler(container)
return with_file_based_connector_dependencies

return with_file_based_connector_dependencies

def get_container(self, platform: dagger.Platform) -> dagger.Container:
"""Returns the container used to build the base image.
Expand Down Expand Up @@ -112,4 +113,4 @@ async def run_sanity_checks(self, platform: dagger.Platform):
await python_sanity_checks.check_python_image_has_expected_env_vars(container)
await base_sanity_checks.check_a_command_is_available_using_version_option(container, "socat", "-V")
await base_sanity_checks.check_socat_version(container, "1.7.4.4")
await python_sanity_checks.check_file_based_connector_dependencies(container)
await python_sanity_checks.check_file_based_connector_dependencies(container)
Expand Up @@ -86,11 +86,11 @@ async def check_python_image_has_expected_env_vars(python_image_container: dagge
for expected_env_var in expected_env_vars:
await base_sanity_checks.check_env_var_with_printenv(python_image_container, expected_env_var)


async def check_file_based_connector_dependencies(python_image_container: dagger.Container):
try:
nltk_data_entries = await python_image_container.directory("/usr/share/nltk_data").entries()
except dagger.ExecError as e:
raise errors.SanityCheckError(e)
if not nltk_data_entries:
raise errors.SanityCheckError("nltk_data directory is empty")

0 comments on commit 73a2959

Please sign in to comment.