Skip to content

Commit cbda73d

Browse files
authored
fix: publish and dev versions (#359)
* fix: publish, versions, tests
1 parent 5af8a05 commit cbda73d

File tree

68 files changed

+262
-196
lines changed

Some content is hidden

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

68 files changed

+262
-196
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ jobs:
99
Pipeline:
1010
if: github.ref == 'refs/heads/master'
1111

12-
runs-on: ubuntu-22.04
13-
container: quintoandar/python-3-7-java
12+
runs-on: ubuntu-latest
1413

1514
steps:
1615
- uses: actions/checkout@v2

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ VERSION := $(shell grep __version__ setup.py | head -1 | cut -d \" -f2 | cut -d
99
.PHONY: environment
1010
## create virtual environment for butterfree
1111
environment:
12-
@pyenv install -s 3.7.13
13-
@pyenv virtualenv 3.7.13 butterfree
12+
@pyenv install -s 3.9.19
13+
@pyenv virtualenv 3.9.19 butterfree
1414
@pyenv local butterfree
1515
@PYTHONPATH=. python -m pip install --upgrade pip
1616

butterfree/_cli/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from butterfree._cli import migrate
44

5-
app = typer.Typer()
5+
app = typer.Typer(no_args_is_help=True)
66
app.add_typer(migrate.app, name="migrate")
77

88
if __name__ == "__main__":

butterfree/_cli/migrate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
from butterfree.migrations.database_migration import ALLOWED_DATABASE
1717
from butterfree.pipelines import FeatureSetPipeline
1818

19-
app = typer.Typer(help="Apply the automatic migrations in a database.")
19+
app = typer.Typer(
20+
help="Apply the automatic migrations in a database.", no_args_is_help=True
21+
)
2022

2123
logger = __logger("migrate", True)
2224

@@ -89,7 +91,7 @@ def __fs_objects(path: str) -> Set[FeatureSetPipeline]:
8991
instances.add(value)
9092

9193
logger.info("Creating instances...")
92-
return set(value() for value in instances)
94+
return set(value() for value in instances) # type: ignore
9395

9496

9597
PATH = typer.Argument(

butterfree/clients/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Holds connection clients."""
2+
23
from butterfree.clients.abstract_client import AbstractClient
34
from butterfree.clients.cassandra_client import CassandraClient
45
from butterfree.clients.spark_client import SparkClient

butterfree/clients/abstract_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Abstract class for database clients."""
2+
23
from abc import ABC, abstractmethod
3-
from typing import Any
4+
from typing import Any, Optional
45

56

67
class AbstractClient(ABC):
@@ -25,7 +26,7 @@ def sql(self, query: str) -> Any:
2526
pass
2627

2728
@abstractmethod
28-
def get_schema(self, table: str, database: str = None) -> Any:
29+
def get_schema(self, table: str, database: Optional[str] = None) -> Any:
2930
"""Returns desired table schema.
3031
3132
Attributes:

butterfree/clients/cassandra_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""CassandraClient entity."""
2+
23
from ssl import CERT_REQUIRED, PROTOCOL_TLSv1
34
from typing import Dict, List, Optional
45

@@ -102,7 +103,9 @@ def sql(self, query: str) -> ResponseFuture:
102103
"""
103104
return self.conn.execute(query)
104105

105-
def get_schema(self, table: str, database: str = None) -> List[Dict[str, str]]:
106+
def get_schema(
107+
self, table: str, database: Optional[str] = None
108+
) -> List[Dict[str, str]]:
106109
"""Returns desired table schema.
107110
108111
Attributes:

butterfree/clients/spark_client.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def read(
6969

7070
return df_reader.format(format).load(path=path, **options) # type: ignore
7171

72-
def read_table(self, table: str, database: str = None) -> DataFrame:
72+
def read_table(self, table: str, database: Optional[str] = None) -> DataFrame:
7373
"""Use the SparkSession.read interface to read a metastore table.
7474
7575
Args:
@@ -179,9 +179,9 @@ def write_table(
179179
database: Optional[str],
180180
table_name: str,
181181
path: str,
182-
format_: str = None,
183-
mode: str = None,
184-
partition_by: List[str] = None,
182+
format_: Optional[str] = None,
183+
mode: Optional[str] = None,
184+
partition_by: Optional[List[str]] = None,
185185
**options: Any,
186186
) -> None:
187187
"""Receive a spark DataFrame and write it as a table in metastore.
@@ -231,7 +231,10 @@ def create_temporary_view(dataframe: DataFrame, name: str) -> Any:
231231
return dataframe.writeStream.format("memory").queryName(name).start()
232232

233233
def add_table_partitions(
234-
self, partitions: List[Dict[str, Any]], table: str, database: str = None
234+
self,
235+
partitions: List[Dict[str, Any]],
236+
table: str,
237+
database: Optional[str] = None,
235238
) -> None:
236239
"""Add partitions to an existing table.
237240
@@ -259,9 +262,11 @@ def add_table_partitions(
259262
key_values_expr = [
260263
", ".join(
261264
[
262-
"{} = {}".format(k, v)
263-
if not isinstance(v, str)
264-
else "{} = '{}'".format(k, v)
265+
(
266+
"{} = {}".format(k, v)
267+
if not isinstance(v, str)
268+
else "{} = '{}'".format(k, v)
269+
)
265270
for k, v in partition.items()
266271
]
267272
)
@@ -314,7 +319,9 @@ def _convert_schema(self, schema: DataFrame) -> List[Dict[str, str]]:
314319

315320
return converted_schema
316321

317-
def get_schema(self, table: str, database: str = None) -> List[Dict[str, str]]:
322+
def get_schema(
323+
self, table: str, database: Optional[str] = None
324+
) -> List[Dict[str, str]]:
318325
"""Returns desired table schema.
319326
320327
Attributes:

butterfree/configs/db/cassandra_config.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Holds configurations to read and write with Spark to Cassandra DB."""
2+
23
from typing import Any, Dict, List, Optional
34

45
from butterfree.configs import environment
@@ -32,18 +33,18 @@ class CassandraConfig(AbstractWriteConfig):
3233

3334
def __init__(
3435
self,
35-
username: str = None,
36-
password: str = None,
37-
host: str = None,
38-
keyspace: str = None,
39-
mode: str = None,
40-
format_: str = None,
41-
stream_processing_time: str = None,
42-
stream_output_mode: str = None,
43-
stream_checkpoint_path: str = None,
44-
read_consistency_level: str = None,
45-
write_consistency_level: str = None,
46-
local_dc: str = None,
36+
username: Optional[str] = None,
37+
password: Optional[str] = None,
38+
host: Optional[str] = None,
39+
keyspace: Optional[str] = None,
40+
mode: Optional[str] = None,
41+
format_: Optional[str] = None,
42+
stream_processing_time: Optional[str] = None,
43+
stream_output_mode: Optional[str] = None,
44+
stream_checkpoint_path: Optional[str] = None,
45+
read_consistency_level: Optional[str] = None,
46+
write_consistency_level: Optional[str] = None,
47+
local_dc: Optional[str] = None,
4748
):
4849
self.username = username
4950
self.password = password

butterfree/configs/db/kafka_config.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Holds configurations to read and write with Spark to Kafka."""
2+
23
from typing import Any, Dict, List, Optional
34

45
from butterfree.configs import environment
@@ -25,13 +26,13 @@ class KafkaConfig(AbstractWriteConfig):
2526

2627
def __init__(
2728
self,
28-
kafka_topic: str = None,
29-
kafka_connection_string: str = None,
30-
mode: str = None,
31-
format_: str = None,
32-
stream_processing_time: str = None,
33-
stream_output_mode: str = None,
34-
stream_checkpoint_path: str = None,
29+
kafka_topic: Optional[str] = None,
30+
kafka_connection_string: Optional[str] = None,
31+
mode: Optional[str] = None,
32+
format_: Optional[str] = None,
33+
stream_processing_time: Optional[str] = None,
34+
stream_output_mode: Optional[str] = None,
35+
stream_checkpoint_path: Optional[str] = None,
3536
):
3637
self.kafka_topic = kafka_topic
3738
self.kafka_connection_string = kafka_connection_string
@@ -147,4 +148,4 @@ def translate(self, schema: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
147148
Kafka schema.
148149
149150
"""
150-
pass
151+
return [{}]

0 commit comments

Comments
 (0)