Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e14a8a2036 | |||
| 7bd3322733 | |||
| ccce2c703e | |||
| 7df35ed05d | |||
| b2e22f7353 | |||
| 559ef90d61 | |||
| fcd85a609d | |||
| 3e14a8660e | |||
| 33760bd764 | |||
| 3011ca46cd | |||
| 9881070425 | |||
| ce24fd8126 |
52
pdm.lock
generated
52
pdm.lock
generated
@@ -5,7 +5,7 @@
|
||||
groups = ["default", "dev", "lint", "nb", "tests"]
|
||||
strategy = ["inherit_metadata"]
|
||||
lock_version = "4.5.0"
|
||||
content_hash = "sha256:c3fd178d5c4736852fff59e2e4c5e3565b0fb80bf29ec5979e1e9c78d452ee1f"
|
||||
content_hash = "sha256:f2a2abd891603796228b21bfeb7a00fd998964fe9303a9e4e5971f63925261e8"
|
||||
|
||||
[[metadata.targets]]
|
||||
requires_python = ">=3.11"
|
||||
@@ -591,6 +591,17 @@ files = [
|
||||
{file = "dopt_basics-0.1.3.tar.gz", hash = "sha256:22ba30cbd385cb8929cb6a13fe01e253cd7d9617ef637e41609f2468691450e8"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "et-xmlfile"
|
||||
version = "2.0.0"
|
||||
requires_python = ">=3.8"
|
||||
summary = "An implementation of lxml.xmlfile for the standard library"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "et_xmlfile-2.0.0-py3-none-any.whl", hash = "sha256:7a91720bc756843502c3b7504c77b8fe44217c85c537d85037f0f536151b2caa"},
|
||||
{file = "et_xmlfile-2.0.0.tar.gz", hash = "sha256:dab3f4764309081ce75662649be815c4c9081e88f0837825f90fd28317d4da54"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "execnet"
|
||||
version = "2.1.1"
|
||||
@@ -1450,6 +1461,20 @@ files = [
|
||||
{file = "nvidia_nccl_cu12-2.25.1-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:362aed5963fb9ea2ed2f264409baae30143498fd0e5c503aeaa1badd88cdc54a"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openpyxl"
|
||||
version = "3.1.5"
|
||||
requires_python = ">=3.8"
|
||||
summary = "A Python library to read/write Excel 2010 xlsx/xlsm files"
|
||||
groups = ["dev"]
|
||||
dependencies = [
|
||||
"et-xmlfile",
|
||||
]
|
||||
files = [
|
||||
{file = "openpyxl-3.1.5-py2.py3-none-any.whl", hash = "sha256:5282c12b107bffeef825f4617dc029afaf41d0ea60823bbb665ef3079dc79de2"},
|
||||
{file = "openpyxl-3.1.5.tar.gz", hash = "sha256:cf0e3cf56142039133628b5acffe8ef0c12bc902d2aadd3e0fe5878dc08d1050"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "overrides"
|
||||
version = "7.7.0"
|
||||
@@ -1571,6 +1596,31 @@ files = [
|
||||
{file = "pexpect-4.9.0.tar.gz", hash = "sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pip"
|
||||
version = "25.1.1"
|
||||
requires_python = ">=3.9"
|
||||
summary = "The PyPA recommended tool for installing Python packages."
|
||||
groups = ["default"]
|
||||
files = [
|
||||
{file = "pip-25.1.1-py3-none-any.whl", hash = "sha256:2913a38a2abf4ea6b64ab507bd9e967f3b53dc1ede74b01b0931e1ce548751af"},
|
||||
{file = "pip-25.1.1.tar.gz", hash = "sha256:3de45d411d308d5054c2168185d8da7f9a2cd753dbac8acbfa88a8909ecd9077"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pip-system-certs"
|
||||
version = "5.2"
|
||||
requires_python = ">=3.10"
|
||||
summary = "Automatically configures Python to use system certificates via truststore"
|
||||
groups = ["default"]
|
||||
dependencies = [
|
||||
"pip>=24.2",
|
||||
]
|
||||
files = [
|
||||
{file = "pip_system_certs-5.2-py3-none-any.whl", hash = "sha256:e6ef3e106d4d02313e33955c2bcc4c2b143b2da07ef91e28a6805a0c1c512126"},
|
||||
{file = "pip_system_certs-5.2.tar.gz", hash = "sha256:80b776b5cf17191bf99d313699b7fce2fdb84eb7bbb225fd134109a82706406f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "platformdirs"
|
||||
version = "4.3.6"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
[project]
|
||||
name = "delta-barth"
|
||||
version = "0.5.9"
|
||||
version = "0.5.12"
|
||||
description = "workflows and pipelines for the Python-based Plugin of Delta Barth's ERP system"
|
||||
authors = [
|
||||
{name = "Florian Förster", email = "f.foerster@d-opt.com"},
|
||||
]
|
||||
dependencies = ["scikit-learn>=1.6.1", "pandas>=2.2.3", "xgboost>=2.1.4", "joblib>=1.4.2", "typing-extensions>=4.12.2", "requests>=2.32.3", "pydantic>=2.10.6", "dopt-basics>=0.1.3", "SQLAlchemy>=2.0.39", "psutil>=7.0.0"]
|
||||
dependencies = ["scikit-learn>=1.6.1", "pandas>=2.2.3", "xgboost>=2.1.4", "joblib>=1.4.2", "typing-extensions>=4.12.2", "requests>=2.32.3", "pydantic>=2.10.6", "dopt-basics>=0.1.3", "SQLAlchemy>=2.0.39", "psutil>=7.0.0", "pip-system-certs>=5.2"]
|
||||
requires-python = ">=3.11"
|
||||
readme = "README.md"
|
||||
license = {text = "LicenseRef-Proprietary"}
|
||||
@@ -74,7 +74,7 @@ directory = "reports/coverage"
|
||||
|
||||
|
||||
[tool.bumpversion]
|
||||
current_version = "0.5.9"
|
||||
current_version = "0.5.12"
|
||||
parse = """(?x)
|
||||
(?P<major>0|[1-9]\\d*)\\.
|
||||
(?P<minor>0|[1-9]\\d*)\\.
|
||||
@@ -147,6 +147,7 @@ dev = [
|
||||
"bump-my-version>=1.1.1",
|
||||
"nox>=2025.2.9",
|
||||
"tomli-w>=1.2.0",
|
||||
"openpyxl>=3.1.5",
|
||||
]
|
||||
nb = [
|
||||
"jupyterlab>=4.3.5",
|
||||
|
||||
@@ -1 +1,73 @@
|
||||
pdm build -d build/
|
||||
pdm build --no-sdist -d build/
|
||||
|
||||
# Configuration
|
||||
$sourceDir = ".\build"
|
||||
$destDir = "..\01_releases\runtime"
|
||||
$packagePrefix = "delta_barth-"
|
||||
$packageSuffix = "-py3-none-any.whl"
|
||||
|
||||
# Ensure destination exists
|
||||
if (-not (Test-Path $destDir)) {
|
||||
New-Item -ItemType Directory -Path $destDir | Out-Null
|
||||
}
|
||||
|
||||
# === Build Regex Pattern ===
|
||||
$escapedSuffix = [regex]::Escape($packageSuffix)
|
||||
|
||||
# Match versions like 1.2.3 or 1.2.3.beta or 1.2.3.beta1
|
||||
# Capture the full version as one string, including the optional pre-release after a dot
|
||||
$pattern = "^$packagePrefix(?<version>\d+\.\d+\.\d+(?:\.[a-zA-Z0-9\-]+)?)$escapedSuffix$"
|
||||
|
||||
Write-Host "Using pattern: $pattern"
|
||||
|
||||
# === Get and Filter Files ===
|
||||
$allFiles = Get-ChildItem -Path $sourceDir -File
|
||||
$matchingFiles = @()
|
||||
|
||||
foreach ($file in $allFiles) {
|
||||
if ($file.Name -match $pattern) {
|
||||
$version = $Matches['version']
|
||||
$matchingFiles += [PSCustomObject]@{
|
||||
File = $file
|
||||
Version = $version
|
||||
}
|
||||
Write-Host "Matched: $($file.Name) -> Version: $version"
|
||||
} else {
|
||||
Write-Host "No match: $($file.Name)"
|
||||
}
|
||||
}
|
||||
|
||||
if ($matchingFiles.Count -eq 0) {
|
||||
Write-Host "No matching package files found."
|
||||
return
|
||||
}
|
||||
|
||||
# === Convert version strings to sortable format ===
|
||||
function Convert-VersionForSort($v) {
|
||||
# Split by dot: e.g., 1.2.3.beta -> [1, 2, 3, "beta"]
|
||||
$parts = $v -split '\.'
|
||||
|
||||
$major = [int]$parts[0]
|
||||
$minor = [int]$parts[1]
|
||||
$patch = [int]$parts[2]
|
||||
$pre = if ($parts.Count -gt 3) { $parts[3] } else { "~" } # "~" to ensure stable > prerelease
|
||||
|
||||
return [PSCustomObject]@{
|
||||
Major = $major
|
||||
Minor = $minor
|
||||
Patch = $patch
|
||||
Pre = $pre
|
||||
}
|
||||
}
|
||||
|
||||
# === Sort by semantic version + pre-release ===
|
||||
$latest = $matchingFiles | Sort-Object {
|
||||
Convert-VersionForSort $_.Version
|
||||
} -Descending | Select-Object -First 1
|
||||
|
||||
# === Copy and rename to .zip ===
|
||||
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($latest.File.Name)
|
||||
$newFileName = "$baseName.zip"
|
||||
$destPath = Join-Path $destDir $newFileName
|
||||
|
||||
Copy-Item -Path $latest.File.FullName -Destination $destPath
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import pip_system_certs.wrapt_requests
|
||||
|
||||
pip_system_certs.wrapt_requests.inject_truststore()
|
||||
|
||||
@@ -192,6 +192,9 @@ def _process_sales(
|
||||
|
||||
DATE_FEAT: Final[str] = "buchungs_datum"
|
||||
SALES_FEAT: Final[str] = "betrag"
|
||||
|
||||
data[DATE_FEAT] = pd.to_datetime(data[DATE_FEAT], errors="coerce")
|
||||
data = data.dropna(subset=["buchungs_datum"])
|
||||
df_filter = data[(data["betrag"] > 0)]
|
||||
df_cust = df_filter.copy()
|
||||
df_cust = df_cust.sort_values(by=DATE_FEAT).reset_index()
|
||||
@@ -436,7 +439,7 @@ def pipeline_sales_forecast(
|
||||
pipe = _process_sales(
|
||||
pipe,
|
||||
min_num_data_points=SALES_MIN_NUM_DATAPOINTS,
|
||||
base_num_data_points_months=SESSION.cfg.forecast.threshold_month_data_points,
|
||||
base_num_data_points_months=session.cfg.forecast.threshold_month_data_points,
|
||||
)
|
||||
if pipe.statistics is not None:
|
||||
res = _write_sales_forecast_stats_wrapped(pipe.statistics)
|
||||
|
||||
@@ -279,6 +279,28 @@ def test_process_sales_Success(sales_data_real_preproc):
|
||||
assert pipe.statistics.xgb_params is not None
|
||||
|
||||
|
||||
@pytest.mark.forecast
|
||||
def test_process_sales_InvalidDates(sales_data_real_preproc):
|
||||
false_date = Datetime(2519, 6, 30)
|
||||
data = sales_data_real_preproc.copy()
|
||||
data = data.iloc[:20, :]
|
||||
data["buchungs_datum"] = data["buchungs_datum"].astype(object)
|
||||
data.at[0, "buchungs_datum"] = false_date
|
||||
assert data["buchungs_datum"].dtype.char == "O"
|
||||
assert len(data) == 20
|
||||
pipe = PipeResult(data, STATUS_HANDLER.SUCCESS)
|
||||
pipe = fc._process_sales(
|
||||
pipe,
|
||||
min_num_data_points=36,
|
||||
base_num_data_points_months=36,
|
||||
)
|
||||
assert pipe.status != STATUS_HANDLER.SUCCESS
|
||||
assert pipe.status == STATUS_HANDLER.pipe_states.TOO_FEW_POINTS
|
||||
assert pipe.data is None
|
||||
assert pipe.results is None
|
||||
assert pipe.statistics is not None
|
||||
|
||||
|
||||
@pytest.mark.forecast
|
||||
def test_process_sales_FailTooFewPoints(sales_data_real_preproc):
|
||||
data = sales_data_real_preproc.copy()
|
||||
@@ -432,6 +454,7 @@ def test_export_on_fail():
|
||||
|
||||
@patch("delta_barth.session.CFG_HOT_RELOAD", False)
|
||||
def test_pipeline_sales_forecast_SuccessDbWrite(exmpl_api_sales_prognosis_resp, session):
|
||||
assert session.cfg.forecast.threshold_month_data_points is not None
|
||||
date = Datetime(2023, 8, 15)
|
||||
company_ids = [5661, 1027, 1024]
|
||||
with (
|
||||
@@ -442,7 +465,7 @@ def test_pipeline_sales_forecast_SuccessDbWrite(exmpl_api_sales_prognosis_resp,
|
||||
):
|
||||
get_mock.return_value = exmpl_api_sales_prognosis_resp, STATUS_HANDLER.SUCCESS
|
||||
sess_mock.cfg.forecast.threshold_month_data_points = 1
|
||||
result = fc.pipeline_sales_forecast(None, company_ids, date) # type: ignore
|
||||
result = fc.pipeline_sales_forecast(session, company_ids, date) # type: ignore
|
||||
assert result.status == STATUS_HANDLER.SUCCESS
|
||||
assert len(result.response.daten) > 0
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ def test_get_sales_prognosis_data_Success(session):
|
||||
resp, status = requests_.get_sales_prognosis_data(session, None, date)
|
||||
assert status.code == 0
|
||||
assert len(resp.daten) > 0
|
||||
date = Datetime(2030, 1, 1)
|
||||
date = Datetime(2520, 1, 1)
|
||||
resp, status = requests_.get_sales_prognosis_data(session, None, date)
|
||||
assert status.code == 0
|
||||
assert len(resp.daten) == 0
|
||||
@@ -25,7 +25,7 @@ def test_get_sales_prognosis_data_Success(session):
|
||||
resp, status = requests_.get_sales_prognosis_data(session, company_ids, date)
|
||||
assert status.code == 0
|
||||
assert len(resp.daten) > 0
|
||||
date = Datetime(2030, 1, 1)
|
||||
date = Datetime(2520, 1, 1)
|
||||
resp, status = requests_.get_sales_prognosis_data(session, company_ids, date)
|
||||
assert status.code == 0
|
||||
assert len(resp.daten) == 0
|
||||
|
||||
Reference in New Issue
Block a user