-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from DanielAvdar/dev-2
Dev 2
- Loading branch information
Showing
22 changed files
with
661 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,15 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
rev: v5.0.0 | ||
hooks: | ||
- id: debug-statements | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: no-commit-to-branch | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.1.4 | ||
rev: v0.8.4 | ||
hooks: | ||
- id: ruff-format | ||
args: [ --preview ] | ||
args: [ --preview, --config=pyproject.toml ] | ||
- id: ruff | ||
args: [ --preview, --fix] | ||
|
||
- repo: local | ||
hooks: | ||
- id: mypy | ||
name: mypy | ||
entry: mypy | ||
language: python | ||
types: [ python ] | ||
args: [ --config-file, pyproject.toml ] | ||
args: [ --preview, --fix,--unsafe-fixes, --config=pyproject.toml ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.PHONY: help | ||
.PHONY: default | ||
default: install | ||
|
||
install: | ||
poetry install --all-extras | ||
# poetry run pre-commit autoupdate | ||
poetry run pre-commit install | ||
|
||
test: | ||
poetry run pytest | ||
|
||
check: | ||
poetry run pre-commit run --all-files | ||
mypy: | ||
poetry run mypy . --config-file pyproject.toml | ||
coverage: | ||
poetry run pytest --cov=ml_orchestrator --cov-report=xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
from pandas_pyarrow.mappers import reverse_create_mapper | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
|
||
def convert_to_numpy(df: pd.DataFrame) -> pd.DataFrame: | ||
cols = df.columns | ||
dtypes = df.dtypes | ||
df_ = df.copy() | ||
for col, dtype in zip(cols, dtypes): | ||
if repr(dtype).startswith("timestamp"): | ||
dt_format = "[" + repr(dtype).split("[")[1] | ||
df_[col] = df_[col].values.astype(f"datetime64{dt_format}") | ||
elif repr(dtype).startswith("halffloat"): | ||
df_[col] = df_[col].values.astype("float16") | ||
elif repr(dtype).startswith("duration"): | ||
td_format = "[" + repr(dtype).split("[")[1] | ||
df_[col] = df_[col].values.astype(f"timedelta64{td_format}") | ||
elif repr(dtype).startswith("string"): | ||
df_[col] = df_[col].values.astype("object") | ||
return df_.convert_dtypes() | ||
values = df.values | ||
r_mapper = reverse_create_mapper() | ||
pyarrow_types = df.dtypes | ||
numpy_types = dict() | ||
for col, dtype in pyarrow_types.items(): | ||
if "pyarrow" in repr(dtype): | ||
numpy_types[col] = r_mapper[repr(dtype)] if "bool" not in repr(dtype) else bool | ||
|
||
else: | ||
numpy_types[col] = dtype | ||
|
||
new_df = pd.DataFrame(values, columns=df.columns, dtype=object).fillna(np.nan).astype(numpy_types) | ||
return new_df |
Oops, something went wrong.