HsbcJone commented on code in PR #1386:
URL: https://github.com/apache/flink-agents/pull/1386#discussion_r4613527402
##########
python/flink_agents/runtime/flink_runner_context.py:
##########
@@ -397,8 +398,12 @@ def __await__(self) -> Any:
parallelism = self._ctx.config.get(
AgentExecutionOptions.ASYNC_BATCH_PARALLELISM
)
- timeout_ms =
self._ctx.config.get(AgentExecutionOptions.ASYNC_BATCH_TIMEOUT_MS)
- deadline = time.monotonic() + timeout_ms / 1000 if timeout_ms > 0 else
None
+ timeout =
self._ctx.config.get(AgentExecutionOptions.ASYNC_BATCH_TIMEOUT)
+ timeout_seconds = positive_seconds(timeout)
+ deadline = (
+ time.monotonic() + timeout_seconds if timeout_seconds is not None
else None
+ )
+ timeout_label = format_duration(timeout) if deadline is not None else
None
Review Comment:
The async batch now passes the original `timedelta` into the sliding-window
loop. `format_duration` runs only when the deadline has already stopped the
batch and the timeout error is built. A finished batch no longer formats the
duration. The timeout test still expects `Async batch execution timed out after
100 ms`.
##########
plan/src/main/java/org/apache/flink/agents/plan/AgentConfiguration.java:
##########
@@ -156,6 +173,9 @@ public <T> T get(ConfigOption<T> option) {
Class<T> targetType = option.getType();
if (targetType.isAssignableFrom(rawValue.getClass())) {
+ if (Duration.class.equals(targetType)) {
Review Comment:
`AgentConfiguration.get` now handles a `Duration` option before the generic
assignable-type check. A stored `Duration` and stored text both go through
`DurationUtils.parse`, then the option's own precision rule.
`storedDurationAndTextShareAlignmentChecks` rejects both
`Duration.ofNanos(500)` placed in the map and `"500 ns"`, and it accepts a
microsecond-aligned `Duration.ofNanos(1_500_000)`.
##########
python/flink_agents/plan/configuration.py:
##########
@@ -109,29 +128,41 @@ def get(self, option: ConfigOption) -> Any:
option.get_key(), option.get_type(), option.get_default_value()
)
+ def _put(self, key: str, value: Any) -> None:
+ self.conf_data[key] = value
+
@override
def set_str(self, key: str, value: str) -> None:
- self.conf_data[key] = value
+ self._put(key, value)
@override
def set_int(self, key: str, value: int) -> None:
- self.conf_data[key] = value
+ self._put(key, value)
@override
def set_float(self, key: str, value: float) -> None:
- self.conf_data[key] = value
+ self._put(key, value)
@override
def set_bool(self, key: str, value: bool) -> None:
- self.conf_data[key] = value
+ self._put(key, value)
@override
def set(self, option: ConfigOption, value: Any) -> None:
- self.conf_data[option.get_key()] = (
- _serialize_targets(value)
- if option.get_key() == _TRACE_LOG_TARGETS_KEY
- else value
- )
+ if option.get_key() == _TRACE_LOG_TARGETS_KEY:
+ stored = _serialize_targets(value)
+ elif option.get_type() is timedelta:
Review Comment:
`_parse_duration_option` now parses, wraps a parse error with the
configuration key, and validates. The getter returns that `timedelta`. The
setter formats it and stores the canonical text.
##########
python/flink_agents/plan/tests/compatibility/check_java_python_config_options_parity.py:
##########
@@ -110,6 +110,28 @@ def _normalize_java_collection(value: Any) -> Any:
return value
+def _java_enum_name(java_value: Any) -> Any:
Review Comment:
The parity check now converts an enum default with
`python_config_type[java_default.name()]` when the declared Python type is an
`Enum`. Duration, list, and primitive branches are unchanged. The
`getClass().isEnum()` probe and the swallowed Py4J errors are gone.
Fake-gateway tests cover seconds/nanos conversion, enum mapping, and a gateway
error from `name()` propagating. I also ran
`check_java_python_config_options_parity.py` against the built API jar, and it
passed.
##########
plan/src/main/java/org/apache/flink/agents/plan/AgentConfiguration.java:
##########
@@ -180,6 +208,59 @@ public <T> T get(ConfigOption<T> option) {
}
}
+ private void putValue(String key, Object value) {
Review Comment:
`putValue()` and `_put()` are removed. Primitive setters assign the map
directly. Duration parsing and validation stay on the duration get and set
paths.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]