Skip to content

Commit

Permalink
fixing the integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Abdul Hameed <ahameed@redhat.com>
  • Loading branch information
redhatHameed committed Jun 12, 2024
1 parent e34b070 commit 08c2616
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
2 changes: 0 additions & 2 deletions sdk/python/requirements/py3.10-ci-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@ multidict==6.0.5
# yarl
multipledispatch==1.0.0
# via ibis-framework
multiprocess==0.70.16
# via feast (setup.py)
mypy==1.10.0
# via
# feast (setup.py)
Expand Down
2 changes: 0 additions & 2 deletions sdk/python/requirements/py3.11-ci-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,6 @@ multidict==6.0.5
# yarl
multipledispatch==1.0.0
# via ibis-framework
multiprocess==0.70.16
# via feast (setup.py)
mypy==1.10.0
# via
# feast (setup.py)
Expand Down
2 changes: 0 additions & 2 deletions sdk/python/requirements/py3.9-ci-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ multidict==6.0.5
# yarl
multipledispatch==1.0.0
# via ibis-framework
multiprocess==0.70.16
# via feast (setup.py)
mypy==1.10.0
# via
# feast (setup.py)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import logging
import os.path
import shutil
import subprocess
import tempfile
import uuid
from pathlib import Path
from typing import Any, Dict, List, Optional

import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
import yaml
from minio import Minio
from multiprocess import Process
from testcontainers.core.generic import DockerContainer
from testcontainers.core.waiting_utils import wait_for_logs
from testcontainers.minio import MinioContainer

from feast import FeatureStore, FileSource, RepoConfig
from feast import FileSource, RepoConfig
from feast.data_format import DeltaFormat, ParquetFormat
from feast.data_source import DataSource
from feast.feature_logging import LoggingDestination
Expand All @@ -24,14 +27,15 @@
SavedDatasetFileStorage,
)
from feast.infra.offline_stores.remote import RemoteOfflineStoreConfig
from feast.offline_server import start_server
from feast.repo_config import FeastConfigBaseModel, RegistryConfig
from feast.wait import wait_retry_backoff # noqa: E402
from tests.integration.feature_repos.universal.data_source_creator import (
DataSourceCreator,
)
from tests.utils.http_server import check_port_open, free_port # noqa: E402

logger = logging.getLogger(__name__)


class FileDataSourceCreator(DataSourceCreator):
files: List[Any]
Expand Down Expand Up @@ -363,31 +367,44 @@ class RemoteOfflineStoreDataSourceCreator(FileDataSourceCreator):
def __init__(self, project_name: str, *args, **kwargs):
super().__init__(project_name)
self.server_port: int = 0
self.proc: Process = None
self.proc = None

def setup(self, registry: RegistryConfig):
parent_offline_config = super().create_offline_store_config()

fs = FeatureStore(
config=RepoConfig(
project=self.project_name,
provider="local",
offline_store=parent_offline_config,
registry=registry.path,
entity_key_serialization_version=2,
)
config = RepoConfig(
project=self.project_name,
provider="local",
offline_store=parent_offline_config,
registry=registry.path,
entity_key_serialization_version=2,
)

repo_path = Path(tempfile.mkdtemp())
with open(repo_path / "feature_store.yaml", "w") as outfile:
yaml.dump(config.dict(by_alias=True), outfile)
repo_path = str(repo_path.resolve())

self.server_port = free_port()
host = "0.0.0.0"
self.proc = Process(
target=start_server,
args=(fs, host, self.server_port),
cmd = [
"feast",
"-c" + repo_path,
"serve_offline",
"--host",
host,
"--port",
str(self.server_port),
]
self.proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
self.proc.start()

_time_out_sec: int = 60
# Wait for server to start
wait_retry_backoff(
lambda: (None, check_port_open(host, self.server_port)),
timeout_secs=10,
timeout_secs=_time_out_sec,
timeout_msg=f"Unable to start the feast server in {_time_out_sec} seconds for remote online store type, port={self.server_port}",
)
return "grpc+tcp://{}:{}".format(host, self.server_port)

Expand Down
6 changes: 3 additions & 3 deletions sdk/python/tests/utils/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


def free_port():
sock = socket.socket()
sock.bind(("", 0))
return sock.getsockname()[1]
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.bind(("", 0))
return sock.getsockname()[1]


def check_port_open(host, port) -> bool:
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@
"mock==2.0.0",
"moto<5",
"mypy>=1.4.1",
"multiprocess>=0.70.16",
"urllib3>=1.25.4,<3",
"psutil==5.9.0",
"py>=1.11.0", # https://github.com/pytest-dev/pytest/issues/10420
Expand Down

0 comments on commit 08c2616

Please sign in to comment.