quapp-common 0.0.13.dev2__tar.gz → 0.0.13.dev4__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.
- {quapp_common-0.0.13.dev2/quapp_common.egg-info → quapp_common-0.0.13.dev4}/PKG-INFO +1 -1
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/pyproject.toml +1 -1
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/provider_tag.py +1 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/sdk.py +1 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/util/response_utils.py +43 -2
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4/quapp_common.egg-info}/PKG-INFO +1 -1
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/LICENSE +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/README.md +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/async_tasks/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/async_tasks/async_invocation_task.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/async_tasks/async_task.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/async_tasks/export_circuit_task.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/async_tasks/post_processing_task.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/invocation.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/job_fetcher.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/job_fetching.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/job_manager.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/bridge.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/callback/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/callback/update_job_metadata.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/circuit_adapter.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/device/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/device/device_selection.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/dispatcher.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/result_serializer.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/config/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/config/logging_config.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/config/thread_config.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/async_task/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/async_task/circuit_export/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/async_task/circuit_export/backend_holder.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/async_task/circuit_export/circuit_holder.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/backend/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/backend/backend_information.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/callback/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/callback/callback_url.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/device/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/device/circuit_running_option.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/promise/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/promise/post_processing_promise.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/promise/promise.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/request/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/request/invocation_request.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/request/job_fetching_request.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/request/request.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/response/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/response/authentication.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/response/custom_header.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/response/job_response.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/base_enum.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/http_header.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/invocation_step.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/language.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/media_type.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/processing_unit.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/status/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/status/job_status.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/status/status_code.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/token_type.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/factory/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/factory/device_factory.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/factory/handler_factory.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/factory/provider_factory.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/handler/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/handler/handler.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/device/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/device/custom_device.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/device/device.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/invocation.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/provider/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/provider/provider.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/util/__init__.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/util/file_utils.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/util/http_utils.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/util/json_parser_utils.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common.egg-info/SOURCES.txt +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common.egg-info/dependency_links.txt +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common.egg-info/requires.txt +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common.egg-info/top_level.txt +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/setup.cfg +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/tests/test_circuit_adapter.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/tests/test_json_parser_utils.py +0 -0
- {quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/tests/test_result_serializer.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quapp-common"
|
|
7
|
-
version = "0.0.13.
|
|
7
|
+
version = "0.0.13.dev4"
|
|
8
8
|
description = "Quapp common library supporting Quapp Platform for Quantum Computing"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "CITYNOW Co. Ltd. ", email = "corp@citynow.vn" }]
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# response_utils.py
|
|
3
3
|
# Copyright © CITYNOW Co. Ltd. All rights reserved.
|
|
4
4
|
|
|
5
|
+
import json
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
5
8
|
from .http_utils import CUSTOM_HEADER_VALUE
|
|
6
9
|
from ..component.backend.job_fetcher import JobFetcher
|
|
7
10
|
from ..data.promise.post_processing_promise import PostProcessingPromise
|
|
@@ -97,6 +100,33 @@ def build_done_job_response(fetcher: JobFetcher = None,
|
|
|
97
100
|
status_code=StatusCode.DONE)
|
|
98
101
|
|
|
99
102
|
|
|
103
|
+
def _humanize_exception(exception: Exception) -> Optional[str]:
|
|
104
|
+
"""
|
|
105
|
+
Return a short, user-friendly explanation for common input-related
|
|
106
|
+
exceptions raised by a function handler, or None when there is no
|
|
107
|
+
friendlier form.
|
|
108
|
+
|
|
109
|
+
Rationale: the raw ``str`` of some exceptions is cryptic for end users --
|
|
110
|
+
most notably ``KeyError``, whose ``str`` is just the repr of the missing
|
|
111
|
+
key (e.g. ``str(KeyError('Q'))`` -> ``"'Q'"``). Classifying the common
|
|
112
|
+
cases lets us surface an actionable, plain-language message instead. Full
|
|
113
|
+
technical detail (traceback, step, exception type) stays in the function
|
|
114
|
+
logs -- it is not surfaced to the end user here.
|
|
115
|
+
"""
|
|
116
|
+
if isinstance(exception, KeyError):
|
|
117
|
+
# KeyError.args[0] is the missing key itself (not quoted).
|
|
118
|
+
key = exception.args[0] if exception.args else exception
|
|
119
|
+
return f"Missing required input field: '{key}'."
|
|
120
|
+
|
|
121
|
+
if isinstance(exception, json.JSONDecodeError):
|
|
122
|
+
return "Input is not valid JSON."
|
|
123
|
+
|
|
124
|
+
if isinstance(exception, IndexError):
|
|
125
|
+
return "An input field has fewer items than expected."
|
|
126
|
+
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
|
|
100
130
|
def build_error_job_response(exception: Exception,
|
|
101
131
|
job_response: JobResponse = None,
|
|
102
132
|
fetcher: JobFetcher = None,
|
|
@@ -148,8 +178,19 @@ def build_error_job_response(exception: Exception,
|
|
|
148
178
|
post_promise)
|
|
149
179
|
job_response.status_code = StatusCode.ERROR
|
|
150
180
|
job_response.job_status = JobStatus.ERROR.value
|
|
151
|
-
|
|
152
|
-
|
|
181
|
+
|
|
182
|
+
# User-facing message: plain language, no internal jargon / step names.
|
|
183
|
+
# Full technical detail (traceback, step, exception type) is emitted to the
|
|
184
|
+
# function logs via logger.exception(exc_info=True) at each call site, where
|
|
185
|
+
# the dev team can inspect it -- it does NOT belong in the user response.
|
|
186
|
+
# The `message` argument (internal step label like "Error when prepare
|
|
187
|
+
# circuit") is intentionally NOT surfaced to the user.
|
|
188
|
+
hint = _humanize_exception(exception)
|
|
189
|
+
job_response.job_result = {
|
|
190
|
+
'message' : hint or 'The function raised an error while running. '
|
|
191
|
+
'Please check the function logs for details.',
|
|
192
|
+
'exception': str(exception),
|
|
193
|
+
}
|
|
153
194
|
return job_response
|
|
154
195
|
|
|
155
196
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/async_tasks/async_task.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/__init__.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/invocation.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/job_fetcher.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/job_fetching.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/backend/job_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/callback/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/circuit_adapter.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/device/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/component/result_serializer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/async_task/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/callback/__init__.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/callback/callback_url.py
RENAMED
|
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
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/response/__init__.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/response/authentication.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/response/custom_header.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/data/response/job_response.py
RENAMED
|
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
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/status/job_status.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/enum/status/status_code.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/factory/device_factory.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/factory/handler_factory.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/factory/provider_factory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/device/custom_device.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/provider/__init__.py
RENAMED
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/model/provider/provider.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common/util/json_parser_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{quapp_common-0.0.13.dev2 → quapp_common-0.0.13.dev4}/quapp_common.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|