pam-python 0.1.28__tar.gz → 0.1.30__tar.gz
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_python-0.1.28 → pam_python-0.1.30}/PKG-INFO +1 -1
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/cli.py +2 -5
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/interface_task_manager.py +2 -2
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/service.py +9 -5
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/task_manager.py +14 -3
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/service/service.test.tmpl +1 -1
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/tester_task.py +17 -4
- {pam_python-0.1.28 → pam_python-0.1.30}/pam_python.egg-info/PKG-INFO +1 -1
- {pam_python-0.1.28 → pam_python-0.1.30}/setup.py +1 -1
- {pam_python-0.1.28 → pam_python-0.1.30}/LICENSE.txt +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/README.md +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/__init__.py +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/api.py +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/models/__init__.py +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/models/request_command.py +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/server.py +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/sqlite.py +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/temp_file_utils.py +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/buildcmd/pamb +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/buildcmd/pamb-base.sh +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/docker/Dockerfile +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/init/dockerignore.tmpl +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/init/gitignore.tmpl +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/init/main.tmpl +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/init/pylintrc.tmpl +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/init/run_unit_test.bat +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/init/run_unit_test.ps1 +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/init/run_unit_test.sh +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/service/functions.tmpl +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/service/service.yaml +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/templates/service/service_class.tmpl +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam/utils.py +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam_python.egg-info/SOURCES.txt +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam_python.egg-info/dependency_links.txt +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam_python.egg-info/entry_points.txt +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam_python.egg-info/requires.txt +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/pam_python.egg-info/top_level.txt +0 -0
- {pam_python-0.1.28 → pam_python-0.1.30}/setup.cfg +0 -0
|
@@ -3,8 +3,7 @@ import sys
|
|
|
3
3
|
import re
|
|
4
4
|
import shutil
|
|
5
5
|
import subprocess
|
|
6
|
-
import
|
|
7
|
-
|
|
6
|
+
import importlib.resources as resources
|
|
8
7
|
|
|
9
8
|
def main():
|
|
10
9
|
args = sys.argv[1:]
|
|
@@ -40,13 +39,11 @@ def to_pascal_case(input_string: str) -> str:
|
|
|
40
39
|
|
|
41
40
|
return pascal_case
|
|
42
41
|
|
|
43
|
-
|
|
44
42
|
def cpy(src, dest):
|
|
45
|
-
template_dir =
|
|
43
|
+
template_dir = resources.files("pam") / "templates"
|
|
46
44
|
src_file = os.path.join(template_dir, src)
|
|
47
45
|
shutil.copy(src_file, dest)
|
|
48
46
|
|
|
49
|
-
|
|
50
47
|
def replace_template_content(service_name, class_name, file_name):
|
|
51
48
|
file_path = os.path.join(service_name, file_name)
|
|
52
49
|
with open(file_path, 'r+', encoding='utf-8') as file:
|
|
@@ -18,7 +18,7 @@ class ITaskManager(ABC):
|
|
|
18
18
|
pass
|
|
19
19
|
|
|
20
20
|
@abstractmethod
|
|
21
|
-
def service_request_data(self, service: Service, page):
|
|
21
|
+
def service_request_data(self, service: Service, page, filter_contact_ids=None):
|
|
22
22
|
pass
|
|
23
23
|
|
|
24
24
|
@abstractmethod
|
|
@@ -30,7 +30,7 @@ class ITaskManager(ABC):
|
|
|
30
30
|
pass
|
|
31
31
|
|
|
32
32
|
@abstractmethod
|
|
33
|
-
def service_upload_result(self, service: Service, file_path):
|
|
33
|
+
def service_upload_result(self, service: Service, file_path, options=None):
|
|
34
34
|
pass
|
|
35
35
|
|
|
36
36
|
@abstractmethod
|
|
@@ -2,7 +2,7 @@ from abc import abstractmethod
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
import json
|
|
5
|
-
from typing import TYPE_CHECKING, Union
|
|
5
|
+
from typing import TYPE_CHECKING, Union, Optional, List
|
|
6
6
|
import pandas as pd
|
|
7
7
|
import dask.dataframe as dd
|
|
8
8
|
from pam.utils import log, deep_convert_numbers_to_strings, get_adapter_id
|
|
@@ -29,13 +29,17 @@ class Service:
|
|
|
29
29
|
return get_adapter_id(self.request.response_api)
|
|
30
30
|
|
|
31
31
|
# == REQUEST DATA ===
|
|
32
|
-
def _request_data(self, page: str = "") -> None:
|
|
32
|
+
def _request_data(self, page: str = "", filter_contact_ids: Optional[List[str]] = None) -> None:
|
|
33
33
|
"""Requests data for the specified page."""
|
|
34
34
|
log(f"{self.request.service_name}: Requesting data for page={page}")
|
|
35
|
-
self.task_manager.service_request_data(self, page)
|
|
35
|
+
self.task_manager.service_request_data(self, page, filter_contact_ids)
|
|
36
36
|
|
|
37
37
|
# == UPLOAD RESULT ===
|
|
38
|
-
def _upload_result(
|
|
38
|
+
def _upload_result(
|
|
39
|
+
self,
|
|
40
|
+
df: Union[pd.DataFrame, dd.DataFrame],
|
|
41
|
+
options: Optional[dict] = None,
|
|
42
|
+
) -> str:
|
|
39
43
|
"""
|
|
40
44
|
Uploads the result DataFrame to a temporary file and notifies the task manager.
|
|
41
45
|
"""
|
|
@@ -56,7 +60,7 @@ class Service:
|
|
|
56
60
|
try:
|
|
57
61
|
df.to_csv(tmp_file_name, index=False)
|
|
58
62
|
log(f"{self.request.service_name}: Uploading result file: {tmp_file_name}")
|
|
59
|
-
self.task_manager.service_upload_result(self, tmp_file_name)
|
|
63
|
+
self.task_manager.service_upload_result(self, tmp_file_name, options)
|
|
60
64
|
except Exception as e:
|
|
61
65
|
log(f"Failed to upload result file: {e}")
|
|
62
66
|
raise
|
|
@@ -127,7 +127,7 @@ class TaskManager(ITaskManager):
|
|
|
127
127
|
self._remove_service(token)
|
|
128
128
|
|
|
129
129
|
# ==== Service Callbacks ====
|
|
130
|
-
def service_request_data(self, service: Service, page):
|
|
130
|
+
def service_request_data(self, service: Service, page, filter_contact_ids=None):
|
|
131
131
|
"""
|
|
132
132
|
Makes an asynchronous request for data from a service.
|
|
133
133
|
Logs the response without blocking the main thread.
|
|
@@ -135,6 +135,8 @@ class TaskManager(ITaskManager):
|
|
|
135
135
|
endpoint = service.request.data_api
|
|
136
136
|
token = service.request.token
|
|
137
137
|
json_data = {"page": page, "token": token}
|
|
138
|
+
if filter_contact_ids is not None:
|
|
139
|
+
json_data["filter_contact_ids"] = filter_contact_ids
|
|
138
140
|
|
|
139
141
|
def handle_response(response):
|
|
140
142
|
"""Logs the response from the API."""
|
|
@@ -225,11 +227,20 @@ class TaskManager(ITaskManager):
|
|
|
225
227
|
log(f"{service.request.service_name}: Exception while uploading sqlite: {e}")
|
|
226
228
|
return ""
|
|
227
229
|
|
|
228
|
-
def service_upload_result(self, service: Service, file_path):
|
|
230
|
+
def service_upload_result(self, service: Service, file_path, options=None):
|
|
229
231
|
"""
|
|
230
232
|
Uploads a result file asynchronously and logs the response.
|
|
231
233
|
"""
|
|
232
234
|
endpoint = service.request.response_api
|
|
235
|
+
payload = None
|
|
236
|
+
if options is not None:
|
|
237
|
+
payload = {}
|
|
238
|
+
if "is_realtime" in options:
|
|
239
|
+
is_realtime = options.get("is_realtime")
|
|
240
|
+
payload["is_realtime"] = str(is_realtime).lower() if isinstance(is_realtime, bool) else is_realtime
|
|
241
|
+
if "is_priority" in options:
|
|
242
|
+
is_priority = options.get("is_priority")
|
|
243
|
+
payload["is_priority"] = str(is_priority).lower() if isinstance(is_priority, bool) else is_priority
|
|
233
244
|
|
|
234
245
|
def handle_upload_response(response):
|
|
235
246
|
"""Logs the response after the upload completes."""
|
|
@@ -241,7 +252,7 @@ class TaskManager(ITaskManager):
|
|
|
241
252
|
|
|
242
253
|
def upload_wrapper():
|
|
243
254
|
"""Wrapper for the upload to handle response logging."""
|
|
244
|
-
response = self.api.http_upload(endpoint, file_path)
|
|
255
|
+
response = self.api.http_upload(endpoint, file_path, payload)
|
|
245
256
|
handle_upload_response(response)
|
|
246
257
|
|
|
247
258
|
log(f"Uploading Result to: {endpoint}")
|
|
@@ -35,7 +35,7 @@ def create_mock_csv(page, mockDir):
|
|
|
35
35
|
df.to_csv(file_name, index=False)
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
def on_request_data(page) -> Tuple[List[str], bool, str]:
|
|
38
|
+
def on_request_data(page, filter_contact_ids=None) -> Tuple[List[str], bool, str]:
|
|
39
39
|
if page is None or page == "" :
|
|
40
40
|
page = "1"
|
|
41
41
|
|
|
@@ -4,7 +4,7 @@ from pam.interface_task_manager import ITaskManager
|
|
|
4
4
|
from pam.service import Service
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
RequestDataCallbackType = Callable[
|
|
7
|
+
RequestDataCallbackType = Callable[..., Tuple[List[str], bool, str]]
|
|
8
8
|
RequestSqliteCallbackType = Callable[[str, bool], Tuple[str]]
|
|
9
9
|
UploadSqliteCallbackType = Callable[[str, bool, str], Tuple[str]]
|
|
10
10
|
UploadResultCallbackType = Callable[[str], None]
|
|
@@ -81,16 +81,23 @@ class TesterTask(ITaskManager):
|
|
|
81
81
|
while not self.is_exit:
|
|
82
82
|
pass
|
|
83
83
|
|
|
84
|
-
def service_request_data(self, service: Service, page: str):
|
|
84
|
+
def service_request_data(self, service: Service, page: str, filter_contact_ids: Optional[List[str]] = None):
|
|
85
85
|
"""
|
|
86
86
|
Simulate a service data request.
|
|
87
87
|
|
|
88
88
|
:param service: The service requesting data.
|
|
89
89
|
:param page: The page identifier for the data request.
|
|
90
|
+
:param filter_contact_ids: Optional list of contact IDs to filter the request.
|
|
90
91
|
"""
|
|
91
92
|
if self.request_data_callback is not None:
|
|
92
93
|
try:
|
|
93
|
-
|
|
94
|
+
if filter_contact_ids is None:
|
|
95
|
+
files, is_end, next_page = self.request_data_callback(page)
|
|
96
|
+
else:
|
|
97
|
+
try:
|
|
98
|
+
files, is_end, next_page = self.request_data_callback(page, filter_contact_ids)
|
|
99
|
+
except TypeError:
|
|
100
|
+
files, is_end, next_page = self.request_data_callback(page)
|
|
94
101
|
req = RequestCommand(
|
|
95
102
|
sqlite_download="",
|
|
96
103
|
sqlite_upload="",
|
|
@@ -128,12 +135,18 @@ class TesterTask(ITaskManager):
|
|
|
128
135
|
else:
|
|
129
136
|
print("Upload sqlite callback is not set.")
|
|
130
137
|
|
|
131
|
-
def service_upload_result(
|
|
138
|
+
def service_upload_result(
|
|
139
|
+
self,
|
|
140
|
+
service: Service,
|
|
141
|
+
file_path: str,
|
|
142
|
+
options: Optional[dict] = None,
|
|
143
|
+
):
|
|
132
144
|
"""
|
|
133
145
|
Simulate a service result upload.
|
|
134
146
|
|
|
135
147
|
:param service: The service uploading the result.
|
|
136
148
|
:param file_path: The path of the file being uploaded.
|
|
149
|
+
:param options: Optional upload options (e.g. is_realtime, is_priority).
|
|
137
150
|
"""
|
|
138
151
|
if self.upload_result_callback is not None:
|
|
139
152
|
try:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|