pam-python 0.2.19__py3-none-any.whl → 0.2.20__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pam/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """PAM Data Plugin framework."""
2
2
 
3
- __version__ = "0.2.19"
3
+ __version__ = "0.2.20"
@@ -127,6 +127,7 @@ class DataInputV2:
127
127
  datasets: tuple[DataInputV2Dataset, ...]
128
128
  run_complete: bool
129
129
  next: str
130
+ missing_contacts: DataInputV2File | None = None
130
131
 
131
132
  def iter_population_rows(self) -> Iterator[dict[str, str]]:
132
133
  """Stream the population file for this customer-aligned logical page."""
@@ -210,6 +211,15 @@ def parse_data_input_v2(input_files: list[str]) -> DataInputV2:
210
211
  if contact_count > max_contacts_per_batch:
211
212
  raise ValueError("V2 population contact_count exceeds configured batch maximum")
212
213
 
214
+ missing_contacts = None
215
+ if "missing_contacts" in manifest:
216
+ missing_contacts = _parse_and_verify_file(
217
+ manifest["missing_contacts"],
218
+ files_by_name,
219
+ declared_names,
220
+ population_format,
221
+ )
222
+
213
223
  raw_datasets = manifest.get("datasets")
214
224
  if not isinstance(raw_datasets, list) or len(raw_datasets) > V2_MAX_DATASETS:
215
225
  raise ValueError("V2 manifest datasets must be a list of at most five items")
@@ -283,6 +293,7 @@ def parse_data_input_v2(input_files: list[str]) -> DataInputV2:
283
293
  max_contacts_per_batch=max_contacts_per_batch,
284
294
  time_window=time_window,
285
295
  population=population_file,
296
+ missing_contacts=missing_contacts,
286
297
  datasets=tuple(datasets),
287
298
  run_complete=_required_bool(manifest, "run_complete"),
288
299
  next=_required_optional_string(manifest, "next"),
pam/task_manager.py CHANGED
@@ -9,6 +9,7 @@ import math
9
9
  import os
10
10
  import time
11
11
  import threading
12
+ import uuid
12
13
  from typing import Dict, TYPE_CHECKING
13
14
  from pam.utils import log
14
15
  from pam.api import API
@@ -453,34 +454,31 @@ class TaskManager(ITaskManager):
453
454
  return response
454
455
 
455
456
  def service_upload_report(self, service: Service, file_path):
456
- """
457
- Uploads a report file asynchronously and logs the response.
458
- """
459
- endpoint = service.request.response_api
460
-
461
- def handle_report_response(response):
462
- """Logs the response after the report upload completes."""
463
- if response is None:
464
- log(f"Response from report upload to {endpoint}: None")
465
- return
466
- try:
467
- response_data = response.json()
468
- except ValueError:
469
- response_data = response.text
470
- log(f"Response from report upload to {endpoint}: {response_data}")
471
-
472
- def upload_wrapper():
473
- """Wrapper for the report upload to handle response logging."""
474
- response = self.api.http_upload(
475
- endpoint,
476
- file_path,
477
- {"token": service.request.token},
478
- )
479
- handle_report_response(response)
480
-
481
- log(f"Uploading Report to: {endpoint}")
482
- http_thread = threading.Thread(target=upload_wrapper)
483
- http_thread.start()
457
+ """Wait for PAM to enqueue a legacy report; propagate delivery failures."""
458
+ trace_id = uuid.uuid4().hex
459
+ started = time.monotonic()
460
+ log(f"report_delivery_started trace_id={trace_id} service={service.request.service_name} "
461
+ f"report_file={Path(file_path).name}")
462
+ response = self.api.http_upload(
463
+ service.request.response_api,
464
+ file_path,
465
+ {"token": service.request.token, "report_delivery_id": trace_id},
466
+ )
467
+ status = response.status_code if response is not None else None
468
+ if response is None or not 200 <= status < 300:
469
+ log(f"report_delivery_failed trace_id={trace_id} http_status={status}")
470
+ raise RuntimeError(f"Report delivery failed trace_id={trace_id} http_status={status}")
471
+ try:
472
+ body = response.json()
473
+ except ValueError:
474
+ body = {}
475
+ stage = body.get("stage", "accepted_unconfirmed") if isinstance(body, dict) else "accepted_unconfirmed"
476
+ log(f"report_delivery_response trace_id={trace_id} http_status={status} "
477
+ f"stage={stage} elapsed_s={time.monotonic() - started:.3f}")
478
+ # Older PAM deployments only acknowledge receipt. Do not report that as
479
+ # successful publication: the new endpoint explicitly confirms enqueue.
480
+ if not isinstance(body, dict) or body.get("report_delivery_id") != trace_id or stage != "tracker_queued":
481
+ raise RuntimeError(f"Report delivery was not confirmed; update PAM first trace_id={trace_id}")
484
482
 
485
483
  def service_publish_report_pointer_v2(
486
484
  self,
@@ -680,3 +680,13 @@ Prefer streaming/chunked/incremental processing whenever possible.
680
680
  - Treat Polars lazy queries as the default compute path.
681
681
  - Use Pandas only when the selected service template or an integration requires it.
682
682
  - Prefer streaming or incremental durable steps when a query cannot stay in memory.
683
+
684
+ ### Missing contacts in V2 input
685
+
686
+ `data.missing_contacts` is an optional verified `DataInputV2File` with one `id`
687
+ column, using the same CSV or Parquet format as population. Read it with
688
+ `scan_polars()` or `read_pandas()`; `iter_csv_rows()` is CSV-only. Older
689
+ manifests expose `None`, while a present zero-row file is valid. These IDs are
690
+ excluded from population and configured datasets. Their absence does not prove
691
+ deletion; plugin developers decide whether and how to handle them. Read the
692
+ file before page cleanup. Do not treat it as a configured dataset position.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pam-python
3
- Version: 0.2.19
3
+ Version: 0.2.20
4
4
  Summary: Pam Python Library
5
5
  Author-email: Narongrit Kanhanoi <narongrit@pams.ai>
6
6
  Project-URL: Homepage, https://github.com/heart/pam-python
@@ -1,4 +1,4 @@
1
- pam/__init__.py,sha256=FJm-IRTRlhqCfc4j3SOZSm0M6COGOUIQWtufhNDjpAA,57
1
+ pam/__init__.py,sha256=KdW64FpMxu2aAx-3gs199l6f7BdAIK_OkLhszvC_MM0,57
2
2
  pam/api.py,sha256=nfsq9OLHutitRMqwkoi3mD0gZ3EfMUzN2rwmS9gpVpY,8198
3
3
  pam/cli.py,sha256=Ip4kYNbZ49WAkcMN4SuNc2qXxDeagOzJwE7GSb-BYlE,13831
4
4
  pam/datetime_utils.py,sha256=sDFxNRR46FsO61p-EzhmIRS6ARnfMPRquKee_RcQ_3E,664
@@ -9,12 +9,12 @@ pam/result_batch_uploader.py,sha256=xw4b-q7i52CoCjvQtQ8EgfBrrqAl1zEl6sTO-wIvFPc,
9
9
  pam/server.py,sha256=auok-4Ls3fTnRS-_sQHt0SHQIOLW1NPwk8B_tmmZwI0,8191
10
10
  pam/service.py,sha256=nH8dupZWFr8-Ab00S9UJvaJfqNd-_6qvKMQMzTiWibc,9416
11
11
  pam/sqlite.py,sha256=0bEUnb17V_Z6N6u843MYyGQnigaAuMx6FUckeWifn8I,2585
12
- pam/task_manager.py,sha256=iNXm5gFwl8ybijd36RedZpkj7J9TEF6ZRLTpReHgPQs,20681
12
+ pam/task_manager.py,sha256=psO6RRd_n-PgEGp0OwOfuHG-TMOYrq4YajKwhv9PqZU,21188
13
13
  pam/temp_file_utils.py,sha256=noMyF4SZ17AWtZcRkZtNtdObRWzykAMxeFr-WkOEQi4,9450
14
14
  pam/tester_task.py,sha256=SKRIut-kksIVWSMwzquqi7MxrZyTO6x2ggqlnRsVJQ4,11967
15
15
  pam/utils.py,sha256=-pfnQ00Ib-IXvrMz4S5lTlO36PtSaJoQOhwXpwet8h4,1744
16
16
  pam/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- pam/models/data_input_v2.py,sha256=0mkZHPjb0RLmc-v4W5Su8_bAw-3U5qL-YU1yF5Z-oCI,17536
17
+ pam/models/data_input_v2.py,sha256=XiLLOPziIo016dC-OfDUgASLkn6oU09HRCcsvNx3Rhg,17888
18
18
  pam/models/request_command.py,sha256=6QBJyQfu75bMfhqBUILE1chvhjRdZ8WHWiBbX3k8K5s,14211
19
19
  pam/models/sqlite_download.py,sha256=7JMWwLp_5LSCMR5Ppk1RgbgcOaX_2LmRFrJiADAnIfs,678
20
20
  pam/reports/__init__.py,sha256=vdAzsUN0bmYPGjqKveg9HjNWe_MnBZj3b42TsDBE6_w,2368
@@ -51,7 +51,7 @@ pam/reports/transport.py,sha256=iDm63RQnPfhCJ1zFbr1uAVYHz3ondNfp2scz21JAnL8,2111
51
51
  pam/reports/treemap.py,sha256=W_VwxbiRMSvkNpY2z1HfbZtGKWXNr6FdbVdI0grVesw,4251
52
52
  pam/templates/buildcmd/pamb,sha256=58GCN59ysvHGNhPvTD3nkF4aLg-kM1WfWmH7CL3eQVo,530
53
53
  pam/templates/buildcmd/pamb-base.sh,sha256=Q0DkbeHtPx33PIjc68EeI7ZIwBOLlwcSmPhpxALXxVY,518
54
- pam/templates/init/AGENT.md,sha256=yOtdr5aSsqPbjh7gWbyfoFYnCZ7opVSF9ol0LbONCTw,27030
54
+ pam/templates/init/AGENT.md,sha256=36J7Si-C7n_als111-iRaH6-iQbqFtdFpN0JTGwNUA4,27601
55
55
  pam/templates/init/REPORTS-th.md,sha256=VdGUFvxU0Zl6pYKgFHIC6U8pmQJcz4JFM7_QYbcXblc,36196
56
56
  pam/templates/init/REPORTS.md,sha256=LCMXW1SLRpOz2yWYM5Pp_B7H90E_X_aQ9vXYvHhEJgc,49868
57
57
  pam/templates/init/dockerignore.tmpl,sha256=Ht1eCgQLqalEwpUjih0FQavzhYJbT2jH-FP4btM3960,52
@@ -73,9 +73,9 @@ pam/templates/service/pandas/service_class.tmpl,sha256=qaq9tqRhxogWQlqi09dbX5vLu
73
73
  pam/templates/service/polars/functions.tmpl,sha256=7Qlwsd5Q1vdkOvXHtlltjb2oS-i7JuNKPor2iNDSsQg,701
74
74
  pam/templates/service/polars/service.test.tmpl,sha256=nC6VoauZMYy_UTTXxxergfWbXvUD_VWwpM7-7A3aKqE,6881
75
75
  pam/templates/service/polars/service_class.tmpl,sha256=jMGeruXduu0eBB7FPDEkZu8b4mSIO3uRt5TiDuNq5T4,3688
76
- pam_python-0.2.19.dist-info/licenses/LICENSE.txt,sha256=yeHD2-gzrkkET2ZkMe22WyUGpDjlwTrqA4POb0FoZi4,1138
77
- pam_python-0.2.19.dist-info/METADATA,sha256=y4WkR7ZBdQWvV2GkxmuoaBiSNZmLmUHX2-jzd12KYPM,10116
78
- pam_python-0.2.19.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
79
- pam_python-0.2.19.dist-info/entry_points.txt,sha256=xqYpsIqvNlO0j8elZc02bDwR-12dLK9FU2B1ACsLYxw,37
80
- pam_python-0.2.19.dist-info/top_level.txt,sha256=0EOjbyc3hQyzjhn6iyMgsEseqA66Xz0p27iBN7G7W1w,4
81
- pam_python-0.2.19.dist-info/RECORD,,
76
+ pam_python-0.2.20.dist-info/licenses/LICENSE.txt,sha256=yeHD2-gzrkkET2ZkMe22WyUGpDjlwTrqA4POb0FoZi4,1138
77
+ pam_python-0.2.20.dist-info/METADATA,sha256=l8sFUyXDsXS9GU9GVnhN9DcIRolP9POSLkXYR0-hkVI,10116
78
+ pam_python-0.2.20.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
79
+ pam_python-0.2.20.dist-info/entry_points.txt,sha256=xqYpsIqvNlO0j8elZc02bDwR-12dLK9FU2B1ACsLYxw,37
80
+ pam_python-0.2.20.dist-info/top_level.txt,sha256=0EOjbyc3hQyzjhn6iyMgsEseqA66Xz0p27iBN7G7W1w,4
81
+ pam_python-0.2.20.dist-info/RECORD,,