Skip to content

Commit e857dd1

Browse files
committed
log_batch_payload_size was renamed to log_batch_payload_limit as it was originally supposed
1 parent 0629c39 commit e857dd1

File tree

5 files changed

+67
-36
lines changed

5 files changed

+67
-36
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Changed
5+
- `log_batch_payload_size` was renamed to `log_batch_payload_limit` as it was originally supposed, by @HardNorth
46

57
## [5.6.6]
68
### Added

reportportal_client/__init__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"""This package is the base package for ReportPortal client."""
1515

1616
import sys
17+
import warnings
1718
from typing import Optional, Tuple, TypedDict, Union
1819

1920
# noinspection PyUnreachableCode
@@ -120,14 +121,25 @@ def create_client(
120121
execution.
121122
:return: ReportPortal Client instance.
122123
"""
124+
my_kwargs = kwargs.copy()
125+
if "log_batch_payload_size" in my_kwargs:
126+
warnings.warn(
127+
message="Your agent is using `log_batch_payload_size` property which was introduced by mistake. "
128+
"The real property name is `log_batch_payload_limit`. Please consider Agent version update.",
129+
category=DeprecationWarning,
130+
stacklevel=2,
131+
)
132+
if "log_batch_payload_limit" not in my_kwargs:
133+
my_kwargs["log_batch_payload_limit"] = my_kwargs.pop("log_batch_payload_size")
134+
123135
if client_type is ClientType.SYNC:
124-
return RPClient(endpoint, project, **kwargs)
136+
return RPClient(endpoint, project, **my_kwargs)
125137
if client_type is ClientType.ASYNC:
126-
return AsyncRPClient(endpoint, project, **kwargs)
138+
return AsyncRPClient(endpoint, project, **my_kwargs)
127139
if client_type is ClientType.ASYNC_THREAD:
128-
return ThreadedRPClient(endpoint, project, **kwargs)
140+
return ThreadedRPClient(endpoint, project, **my_kwargs)
129141
if client_type is ClientType.ASYNC_BATCHED:
130-
return BatchedRPClient(endpoint, project, **kwargs)
142+
return BatchedRPClient(endpoint, project, **my_kwargs)
131143
raise ValueError(f"Unknown ReportPortal Client type requested: {client_type}")
132144

133145

reportportal_client/client.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class RPClient(RP):
390390
__launch_uuid: str
391391
use_own_launch: bool
392392
log_batch_size: int
393-
log_batch_payload_size: int
393+
log_batch_payload_limit: int
394394
__project: str
395395
api_key: Optional[str]
396396
oauth_uri: Optional[str]
@@ -470,7 +470,7 @@ def __init__(
470470
max_pool_size: int = 50,
471471
launch_uuid: str = None,
472472
http_timeout: Union[float, Tuple[float, float]] = (10, 10),
473-
log_batch_payload_size: int = MAX_LOG_BATCH_PAYLOAD_SIZE,
473+
log_batch_payload_limit: int = MAX_LOG_BATCH_PAYLOAD_SIZE,
474474
mode: str = "DEFAULT",
475475
launch_uuid_print: bool = False,
476476
print_output: OutputType = OutputType.STDOUT,
@@ -487,31 +487,31 @@ def __init__(
487487
) -> None:
488488
"""Initialize the class instance with arguments.
489489
490-
:param endpoint: Endpoint of the ReportPortal service.
491-
:param project: Project name to report to.
492-
:param api_key: Authorization API key.
493-
:param oauth_uri: OAuth 2.0 token endpoint URI (for OAuth authentication).
494-
:param oauth_username: Username for OAuth 2.0 authentication.
495-
:param oauth_password: Password for OAuth 2.0 authentication.
496-
:param oauth_client_id: OAuth 2.0 client ID.
497-
:param oauth_client_secret: OAuth 2.0 client secret (optional).
498-
:param oauth_scope: OAuth 2.0 scope (optional).
499-
:param log_batch_size: Option to set the maximum number of logs that can be processed in one
500-
batch.
501-
:param is_skipped_an_issue: Option to mark skipped tests as not 'To Investigate' items on the
502-
server side.
503-
:param verify_ssl: Option to skip ssl verification.
504-
:param retries: Number of retry attempts to make in case of connection / server errors.
505-
:param max_pool_size: Option to set the maximum number of connections to save the pool.
506-
:param launch_uuid: A launch UUID to use instead of starting own one.
507-
:param http_timeout: A float in seconds for connect and read timeout. Use a Tuple to
508-
specific connect and read separately.
509-
:param log_batch_payload_size: Maximum size in bytes of logs that can be processed in one batch.
510-
:param mode: Launch mode, all Launches started by the client will be in that mode.
511-
:param launch_uuid_print: Print Launch UUID into passed TextIO or by default to stdout.
512-
:param print_output: Set output stream for Launch UUID printing.
513-
:param log_batcher: Use existing LogBatcher instance instead of creation of own one.
514-
:param truncate_attributes: Truncate test item attributes to default maximum length.
490+
:param endpoint: Endpoint of the ReportPortal service.
491+
:param project: Project name to report to.
492+
:param api_key: Authorization API key.
493+
:param oauth_uri: OAuth 2.0 token endpoint URI (for OAuth authentication).
494+
:param oauth_username: Username for OAuth 2.0 authentication.
495+
:param oauth_password: Password for OAuth 2.0 authentication.
496+
:param oauth_client_id: OAuth 2.0 client ID.
497+
:param oauth_client_secret: OAuth 2.0 client secret (optional).
498+
:param oauth_scope: OAuth 2.0 scope (optional).
499+
:param log_batch_size: Option to set the maximum number of logs that can be processed in one
500+
batch.
501+
:param is_skipped_an_issue: Option to mark skipped tests as not 'To Investigate' items on the
502+
server side.
503+
:param verify_ssl: Option to skip ssl verification.
504+
:param retries: Number of retry attempts to make in case of connection / server errors.
505+
:param max_pool_size: Option to set the maximum number of connections to save the pool.
506+
:param launch_uuid: A launch UUID to use instead of starting own one.
507+
:param http_timeout: A float in seconds for connect and read timeout. Use a Tuple to
508+
specific connect and read separately.
509+
:param log_batch_payload_limit: Maximum size in bytes of logs that can be processed in one batch.
510+
:param mode: Launch mode, all Launches started by the client will be in that mode.
511+
:param launch_uuid_print: Print Launch UUID into passed TextIO or by default to stdout.
512+
:param print_output: Set output stream for Launch UUID printing.
513+
:param log_batcher: Use existing LogBatcher instance instead of creation of own one.
514+
:param truncate_attributes: Truncate test item attributes to default maximum length.
515515
"""
516516
set_current(self)
517517
self.api_v1, self.api_v2 = "v1", "v2"
@@ -533,8 +533,8 @@ def __init__(
533533
self.__launch_uuid = launch_id
534534
self.use_own_launch = not bool(self.__launch_uuid)
535535
self.log_batch_size = log_batch_size
536-
self.log_batch_payload_size = log_batch_payload_size
537-
self._log_batcher = log_batcher or LogBatcher(self.log_batch_size, self.log_batch_payload_size)
536+
self.log_batch_payload_limit = log_batch_payload_limit
537+
self._log_batcher = log_batcher or LogBatcher(self.log_batch_size, self.log_batch_payload_limit)
538538
self.verify_ssl = verify_ssl
539539
self.retries = retries
540540
self.max_pool_size = max_pool_size
@@ -1016,7 +1016,7 @@ def clone(self) -> "RPClient":
10161016
max_pool_size=self.max_pool_size,
10171017
launch_uuid=self.__launch_uuid,
10181018
http_timeout=self.http_timeout,
1019-
log_batch_payload_size=self.log_batch_payload_size,
1019+
log_batch_payload_limit=self.log_batch_payload_limit,
10201020
mode=self.mode,
10211021
log_batcher=self._log_batcher,
10221022
oauth_uri=self.oauth_uri,

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_clone():
155155
and cloned.launch_uuid == kwargs["launch_id"]
156156
and cloned.launch_id == kwargs["launch_id"]
157157
and cloned.http_timeout == kwargs["http_timeout"]
158-
and cloned.log_batch_payload_size == kwargs["log_batch_payload_size"]
158+
and cloned.log_batch_payload_limit == kwargs["log_batch_payload_size"]
159159
and cloned.mode == kwargs["mode"]
160160
)
161161
assert cloned._item_stack.qsize() == 1 and client.current_item() == cloned.current_item()
@@ -430,7 +430,7 @@ def test_clone_with_oauth():
430430
and cloned.launch_uuid == kwargs["launch_id"]
431431
and cloned.launch_id == kwargs["launch_id"]
432432
and cloned.http_timeout == kwargs["http_timeout"]
433-
and cloned.log_batch_payload_size == kwargs["log_batch_payload_size"]
433+
and cloned.log_batch_payload_limit == kwargs["log_batch_payload_size"]
434434
and cloned.mode == kwargs["mode"]
435435
)
436436
assert cloned._item_stack.qsize() == 1 and client.current_item() == cloned.current_item()

tests/test_client_factory.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,20 @@
2929
def test_client_factory_types(requested_type: ClientType, expected_type):
3030
result = create_client(requested_type, "http://endpoint", "default_personal", api_key="test_api_key")
3131
assert isinstance(result, expected_type)
32+
33+
34+
def test_client_factory_payload_size_warning():
35+
payload_size = 123
36+
with pytest.warns(DeprecationWarning) as warnings:
37+
# noinspection PyArgumentList
38+
client = create_client(
39+
ClientType.SYNC,
40+
"http://endpoint",
41+
"default_personal",
42+
api_key="test_api_key",
43+
log_batch_payload_size=payload_size,
44+
)
45+
assert "Your agent is using `log_batch_payload_size` property" in warnings[0].message.args[0]
46+
47+
# noinspection PyUnresolvedReferences
48+
assert client.log_batch_payload_limit == payload_size

0 commit comments

Comments
 (0)