Skip to content

Commit

Permalink
Set up Github Action tests & lints
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Siedlaczek <[email protected]>
  • Loading branch information
Michal Siedlaczek authored and elshize committed Jan 5, 2023
1 parent 391f06d commit 53b0780
Show file tree
Hide file tree
Showing 10 changed files with 670 additions and 594 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lints

on:
workflow_dispatch:
push:
branches:
- main
pull_request:

jobs:
build:

runs-on: "ubuntu-22.04"

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: Pylint
run: |
poetry run pylint ibm_data_engine
- name: Formatting (black)
run: |
poetry run black --check ibm_data_engine
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: Build package
run: poetry build
- name: Publish package
run: poetry publish -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Unit tests

on:
workflow_dispatch:
push:
branches:
- main
pull_request:

jobs:
build:

strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
runner: ["ubuntu-22.04", "windows-2022", "macos-12"]

runs-on: ${{ matrix.runner }}

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: Test with pytest
run: |
poetry run pytest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ cython_debug/

# End of https://www.toptal.com/developers/gitignore/api/python

.pylintrc
pyrightconfig.json
.envrc
.python-version
6 changes: 6 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[MESSAGES CONTROL]
disable=too-few-public-methods,
too-many-instance-attributes

[FORMAT]
good-names=T,F,df,k,tf,b,k1,db,fs,fv
22 changes: 13 additions & 9 deletions ibm_data_engine/data_engine_offline_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def pull_latest_from_table_or_query(
join_key_columns: List[str],
feature_name_columns: List[str],
timestamp_field: str,
created_timestamp_column: Optional[str],
created_timestamp_column: Optional[str], # pylint: disable=unused-argument
start_date: datetime,
end_date: datetime,
) -> RetrievalJob:
Expand All @@ -423,7 +423,8 @@ def retrieve_df():
where_clause = _where(join_key_columns, aliases=("de_a", "de_b"))
sql_query = (
f"SELECT {fields} FROM {data_source.get_table_query_string()} as de_a "
f"JOIN ({inner()}) as de_b WHERE {where_clause} AND de_a.{timestamp_field} = de_b.timestamp"
f"JOIN ({inner()}) as de_b WHERE {where_clause} "
f"AND de_a.{timestamp_field} = de_b.timestamp"
)
return _sql_builder(config).run_sql(sql_query)

Expand Down Expand Up @@ -508,6 +509,7 @@ def _upload_entity_df(
return copy_to

elif isinstance(entity_df, str):
# pylint: disable=fixme
# TODO: If the entity_df is a string (SQL query), create a table out of it
raise NotImplementedError

Expand All @@ -517,23 +519,24 @@ def _upload_entity_df(

def _get_entity_schema(
entity_df: Union[pd.DataFrame, str],
config: RepoConfig,
config: RepoConfig, # pylint: disable=unused-argument
) -> Dict[str, np.dtype]:
if isinstance(entity_df, pd.DataFrame):
return dict(zip(entity_df.columns, entity_df.dtypes))

elif isinstance(entity_df, str):
if isinstance(entity_df, str):
# If the entity_df is a string (SQL query)
# TODO:provide implementation for string entity
# pylint: disable=fixme
# TODO: provide implementation for string entity
raise NotImplementedError
else:
raise InvalidEntityType(type(entity_df))

raise InvalidEntityType(type(entity_df))


def _get_entity_df_event_timestamp_range(
entity_df: Union[pd.DataFrame, str],
entity_df_event_timestamp_col: str,
config: RepoConfig,
config: RepoConfig, # pylint: disable=unused-argument
) -> Tuple[datetime, datetime]:
if isinstance(entity_df, pd.DataFrame):
entity_df_event_timestamp = entity_df.loc[:, entity_df_event_timestamp_col].infer_objects()
Expand All @@ -545,7 +548,8 @@ def _get_entity_df_event_timestamp_range(
)
elif isinstance(entity_df, str):
# If the entity_df is a string (SQL query), determine range
# TODO:provide implementation for string query
# pylint: disable=fixme
# TODO: provide implementation for string query
raise NotImplementedError
else:
raise InvalidEntityType(type(entity_df))
Expand Down
Loading

0 comments on commit 53b0780

Please sign in to comment.