diff --git a/Makefile b/Makefile index 74cf60e..3f6c8ac 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: build + ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) format: @@ -11,4 +13,8 @@ lint: cd ${ROOT_DIR}; mypy feast_hive/ tests/ cd ${ROOT_DIR}; isort feast_hive/ tests/ --check-only cd ${ROOT_DIR}; flake8 feast_hive/ tests/ - cd ${ROOT_DIR}; black --check feast_hive tests \ No newline at end of file + cd ${ROOT_DIR}; black --check feast_hive tests + +build: + rm -rf dist/* + python setup.py sdist bdist_wheel \ No newline at end of file diff --git a/README.md b/README.md index 541b164..608eaf1 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ For more details, can check [this Feast issue](https://github.com/feast-dev/feas ## Todo List - [DONE, v0.1.1] ~~I am working on the first workable version, think it will be released in a couple of days.~~ -- Allow custom hive conf when connect to a HiveServer2 -- It only supports `insert into` for uploading entity_df for now, which will be a little inefficient. In next version, I will provide some extra parameters for users who are able to provide WebHDFS address. +- [DONE, v0.1.2] ~~Allow custom hive conf when connect to a HiveServer2~~ +- It currently supports `insert into` for uploading entity_df, which is a little inefficient, gonna add extra parameters for people who are able to provide HDFS address in next version (for uploading to HDFS). ## Quickstart @@ -48,8 +48,11 @@ provider: local offline_store: type: feast_hive.HiveOfflineStore host: localhost - port: 10000 # default is `10000` - database: default # default is `default` + port: 10000 # optional, default is `10000` + database: default # optional, default is `default` + hive_conf: # optional, hive conf overlay + hive.join.cache.size: 14797 + hive.exec.max.dynamic.partitions: 779 ... # other parameters online_store: ... diff --git a/feast_hive/hive.py b/feast_hive/hive.py index 75a3db0..65228e3 100644 --- a/feast_hive/hive.py +++ b/feast_hive/hive.py @@ -7,6 +7,7 @@ import pyarrow as pa from pydantic import StrictBool, StrictInt, StrictStr from pytz import utc +from six import reraise from feast import FeatureView from feast.data_source import DataSource @@ -102,6 +103,14 @@ def cursor(self) -> ImpalaCursor: else: return self.real_conn.cursor() + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.close() + if exc_type is not None: + reraise(exc_type, exc_val, exc_tb) + class HiveOfflineStore(OfflineStore): @staticmethod diff --git a/setup.py b/setup.py index 5fd2e0a..3499b5c 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ setup( name="feast-hive", - version="0.1.1", + version="0.1.2", author="Benn Ma", author_email="bennmsg@gmail.com", description="Hive support for Feast offline store", diff --git a/tests/test_all.py b/tests/test_all.py index ca1bfb1..260e0e4 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -1,10 +1,10 @@ import contextlib import os -import uuid -from pathlib import Path import random import time +import uuid from datetime import datetime +from pathlib import Path from tempfile import TemporaryDirectory from typing import Union, Iterator, Tuple, Any, Dict @@ -509,7 +509,7 @@ def test_hive_config(pytestconfig): "hive.exec.max.dynamic.partitions": 779, } offline_store = HiveOfflineStoreConfig(**options) - with contextlib.closing(feast_hive_module.HiveConnection(offline_store)) as conn: + with feast_hive_module.HiveConnection(offline_store) as conn: with conn.cursor() as cursor: cursor.execute("SET hive.join.cache.size") expected = ("hive.join.cache.size=14797",)