feat: move report artifacts to OSS storage
This commit is contained in:
@@ -11,7 +11,8 @@ from pathlib import Path
|
||||
from typing import Optional, Sequence, Tuple
|
||||
|
||||
from company_reports.contracts import COMPANY_NAMES, ErrorCode, RESULT_SCHEMA_VERSION
|
||||
from company_reports.publishing import ArtifactToolBuilder, AtomicReportPublisher
|
||||
from arr_web.processing_runtime import compose_object_store
|
||||
from company_reports.publishing import OpenpyxlWorkbookBuilder, AtomicReportPublisher
|
||||
from company_reports.repository import DatabaseConfig, PostgresReportRepository, RepositoryError
|
||||
from company_reports.service import CompanyReportService, RunRequest, write_batch_result
|
||||
|
||||
@@ -69,14 +70,6 @@ def _parser() -> SafeArgumentParser:
|
||||
"--output-root",
|
||||
help="controlled output root inside the project",
|
||||
)
|
||||
generate.add_argument(
|
||||
"--node-binary",
|
||||
help="deprecated compatibility option; ignored by the openpyxl builder",
|
||||
)
|
||||
generate.add_argument(
|
||||
"--artifact-tool-module",
|
||||
help="deprecated compatibility option; ignored by the openpyxl builder",
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
@@ -110,23 +103,21 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
|
||||
output_root = output_root.resolve()
|
||||
config = DatabaseConfig.from_environment()
|
||||
repository = PostgresReportRepository(config)
|
||||
builder = ArtifactToolBuilder(
|
||||
PROJECT_ROOT / "company_reports" / "xlsx" / "build_workbook.mjs",
|
||||
node_binary=args.node_binary,
|
||||
artifact_tool_module=(
|
||||
Path(args.artifact_tool_module).expanduser()
|
||||
if args.artifact_tool_module
|
||||
else None
|
||||
),
|
||||
)
|
||||
publisher = AtomicReportPublisher(PROJECT_ROOT, output_root)
|
||||
service = CompanyReportService(
|
||||
repository,
|
||||
builder,
|
||||
publisher,
|
||||
output_root / ".staging",
|
||||
)
|
||||
result = service.run(request)
|
||||
storage_runtime = compose_object_store()
|
||||
try:
|
||||
service = CompanyReportService(
|
||||
repository,
|
||||
OpenpyxlWorkbookBuilder(),
|
||||
AtomicReportPublisher(
|
||||
PROJECT_ROOT,
|
||||
output_root,
|
||||
object_store=storage_runtime.object_store,
|
||||
),
|
||||
output_root / ".staging",
|
||||
)
|
||||
result = service.run(request)
|
||||
finally:
|
||||
storage_runtime.close()
|
||||
result_path = (
|
||||
output_root
|
||||
/ f"{year:04d}"
|
||||
|
||||
Reference in New Issue
Block a user