Save local fertigungski changes
This commit is contained in:
1 parent
e9f9cf6f3c
commit
5452dc035b
2 files changed
+119
No files matched your search
@@ -128,10 +128,25 @@ def _parser() -> argparse.ArgumentParser:
|
||||
monthly.add_argument("--meter")
|
||||
monthly.add_argument("--month", required=True, help="YYYY-MM")
|
||||
monthly.add_argument("--db-secrets-file", type=Path, default=Path("secrets/postgres.env"))
|
||||
|
||||
channel_material = runners.add_parser(
|
||||
"channel-material-poll", help="Continuously poll channel-level material consumption"
|
||||
)
|
||||
channel_material.add_argument("--config", type=Path, required=True)
|
||||
channel_material.add_argument("--poll-interval-seconds", type=float, default=10.0)
|
||||
channel_material.add_argument(
|
||||
"--state-directory", type=Path, default=Path("data/state/channel-material")
|
||||
)
|
||||
channel_material.add_argument("--secrets-file", type=Path, default=Path("secrets/enlyze.env"))
|
||||
channel_material.add_argument("--once", action="store_true", help="Run one poll cycle and exit")
|
||||
efficiency = runners.add_parser("material-efficiency", help="Persist ERP feedback KPI points")
|
||||
efficiency.add_argument("--config", type=Path, required=True)
|
||||
efficiency.add_argument("--secrets-file", type=Path, default=Path("secrets/enlyze.env"))
|
||||
efficiency.add_argument("--erp-secrets-file", type=Path, default=Path("secrets/erp.env"))
|
||||
downtime = runners.add_parser("downtime-reconcile", help="Reconcile ENLYZE downtime events")
|
||||
downtime.add_argument("--config", type=Path, required=True)
|
||||
downtime.add_argument("--secrets-file", type=Path, default=Path("secrets/enlyze.env"))
|
||||
downtime.add_argument("--erp-secrets-file", type=Path, default=Path("secrets/erp.env"))
|
||||
return parser
|
||||
|
||||
|
||||
@@ -174,6 +189,35 @@ def _run_material(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def _run_channel_material(args: argparse.Namespace) -> int:
|
||||
from production_analytics.calculations.channel_config import load_channel_material_calculation
|
||||
from production_analytics.calculations.config import CalculationConfigError
|
||||
from production_analytics.enlyze.exploration import ConfigurationError
|
||||
from production_analytics.service.channel_material_runtime import build_channel_material_runner
|
||||
|
||||
try:
|
||||
calculation = load_channel_material_calculation(args.config)
|
||||
runner = build_channel_material_runner(
|
||||
calculation,
|
||||
poll_interval_seconds=args.poll_interval_seconds,
|
||||
state_directory=args.state_directory,
|
||||
secrets_file=args.secrets_file,
|
||||
)
|
||||
if args.once:
|
||||
runner.run_once()
|
||||
else:
|
||||
runner.run()
|
||||
except (CalculationConfigError, ConfigurationError) as exc:
|
||||
print(f"Config/startup error: {exc}", file=sys.stderr)
|
||||
return 2
|
||||
except KeyboardInterrupt:
|
||||
return 0
|
||||
except Exception as exc:
|
||||
print(f"Startup/runtime error: {type(exc).__name__}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def _run_material_efficiency(args: argparse.Namespace) -> int:
|
||||
from production_analytics.calculations.config import CalculationConfigError
|
||||
from production_analytics.enlyze.exploration import ConfigurationError
|
||||
@@ -263,13 +307,32 @@ def _run_monthly_report(args: argparse.Namespace) -> int:
|
||||
return 2
|
||||
|
||||
|
||||
def _run_downtime(args: argparse.Namespace) -> int:
|
||||
from production_analytics.service.downtime_runtime import build_downtime_runner
|
||||
|
||||
try:
|
||||
build_downtime_runner(
|
||||
args.config,
|
||||
secrets_file=args.secrets_file,
|
||||
erp_secrets_file=args.erp_secrets_file,
|
||||
).run()
|
||||
except Exception as exc:
|
||||
print(f"Config/startup/runtime error: {type(exc).__name__}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
args = _parser().parse_args(argv)
|
||||
if args.namespace == "run":
|
||||
if args.command == "channel-material-poll":
|
||||
return _run_channel_material(args)
|
||||
if args.command == "material-efficiency":
|
||||
return _run_material_efficiency(args)
|
||||
if args.command == "power-meter":
|
||||
return _run_power_meter(args)
|
||||
if args.command == "downtime-reconcile":
|
||||
return _run_downtime(args)
|
||||
return _run_material(args)
|
||||
if args.namespace == "report":
|
||||
return _run_monthly_report(args)
|
||||
|
||||
Reference in new issue
Block a user