nvidia-nat 1.4.0a20251105__py3-none-any.whl → 1.4.0a20251106__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.
@@ -13,6 +13,8 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
+ import fnmatch
17
+
16
18
  import pandas as pd
17
19
 
18
20
  from nat.data_models.dataset_handler import EvalFilterConfig
@@ -24,6 +26,7 @@ class DatasetFilter:
24
26
  - If a allowlist is provided, only keep rows matching the filter values.
25
27
  - If a denylist is provided, remove rows matching the filter values.
26
28
  - If the filter column does not exist in the DataFrame, the filtering is skipped for that column.
29
+ - Supports Unix shell-style wildcards (``*``, ``?``, ``[seq]``, ``[!seq]``) for string matching.
27
30
 
28
31
  This is a utility class that is dataset agnostic and can be used to filter any DataFrame based on the provided
29
32
  filter configuration.
@@ -33,6 +36,33 @@ class DatasetFilter:
33
36
 
34
37
  self.filter_config = filter_config
35
38
 
39
+ @staticmethod
40
+ def _match_wildcard_patterns(series: pd.Series, patterns: list[str | int | float]) -> pd.Series:
41
+ """
42
+ Match series values against wildcard patterns and exact values.
43
+
44
+ Args:
45
+ series (pd.Series): pandas Series to match against
46
+ patterns (list[str | int | float]): List of patterns/values
47
+
48
+ Returns:
49
+ pd.Series: Boolean Series indicating matches
50
+ """
51
+ # Convert series to string for pattern matching
52
+ str_series = series.astype(str)
53
+
54
+ # Initialize boolean mask
55
+ matches = pd.Series([False] * len(series), index=series.index)
56
+
57
+ # Check each pattern using fnmatch with list comprehension to avoid lambda capture
58
+ for pattern in patterns:
59
+ pattern_str = str(pattern)
60
+ pattern_matches = pd.Series([fnmatch.fnmatch(val, pattern_str) for val in str_series],
61
+ index=str_series.index)
62
+ matches |= pattern_matches
63
+
64
+ return matches
65
+
36
66
  def apply_filters(self, df) -> pd.DataFrame:
37
67
 
38
68
  filtered_df = df.copy()
@@ -41,12 +71,14 @@ class DatasetFilter:
41
71
  if self.filter_config.allowlist:
42
72
  for column, values in self.filter_config.allowlist.field.items():
43
73
  if column in filtered_df.columns:
44
- filtered_df = filtered_df[filtered_df[column].isin(values)]
74
+ matches = self._match_wildcard_patterns(filtered_df[column], values)
75
+ filtered_df = filtered_df[matches]
45
76
 
46
77
  # Apply denylist (remove specified rows)
47
78
  if self.filter_config.denylist:
48
79
  for column, values in self.filter_config.denylist.field.items():
49
80
  if column in filtered_df.columns:
50
- filtered_df = filtered_df[~filtered_df[column].isin(values)]
81
+ matches = self._match_wildcard_patterns(filtered_df[column], values)
82
+ filtered_df = filtered_df[~matches]
51
83
 
52
84
  return filtered_df
nat/utils/__init__.py CHANGED
@@ -29,7 +29,8 @@ async def run_workflow(*,
29
29
  config: "Config | None" = None,
30
30
  config_file: "StrPath | None" = None,
31
31
  prompt: str,
32
- to_type: type[_T] = str) -> _T:
32
+ to_type: type[_T] = str,
33
+ session_kwargs: dict[str, typing.Any] | None = None) -> _T:
33
34
  """
34
35
  Wrapper to run a workflow given either a config or a config file path and a prompt, returning the result in the
35
36
  type specified by the `to_type`.
@@ -66,7 +67,10 @@ async def run_workflow(*,
66
67
 
67
68
  config = load_config(config_file)
68
69
 
70
+ session_kwargs = session_kwargs or {}
71
+
69
72
  async with WorkflowBuilder.from_config(config=config) as workflow_builder:
70
- workflow = SessionManager(await workflow_builder.build())
71
- async with workflow.run(prompt) as runner:
72
- return await runner.result(to_type=to_type)
73
+ session_manager = SessionManager(await workflow_builder.build())
74
+ async with session_manager.session(**session_kwargs) as session:
75
+ async with session.run(prompt) as runner:
76
+ return await runner.result(to_type=to_type)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nvidia-nat
3
- Version: 1.4.0a20251105
3
+ Version: 1.4.0a20251106
4
4
  Summary: NVIDIA NeMo Agent toolkit
5
5
  Author: NVIDIA Corporation
6
6
  Maintainer: NVIDIA Corporation
@@ -167,7 +167,7 @@ nat/eval/runtime_event_subscriber.py,sha256=9MVgZLKvpnThHINaPbszPYDWnJ61sntS09YZ
167
167
  nat/eval/usage_stats.py,sha256=r8Zr3bIy2qXU1BgVKXr_4mr7bG0hte3BPNQLSgZvg8M,1376
168
168
  nat/eval/dataset_handler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
169
169
  nat/eval/dataset_handler/dataset_downloader.py,sha256=ZaNohbRSvoHPWIj0C_FqyJnhQKoTBk_uZF7ijjfk6vE,4641
170
- nat/eval/dataset_handler/dataset_filter.py,sha256=HrK0m3SQnPX6zOcKwJwYMrD9O-f6aOw8Vo3j9RKszqE,2115
170
+ nat/eval/dataset_handler/dataset_filter.py,sha256=8ul9j8XvMJG28k2NoiTzGhN6l8pq58Y1T22uuW_m1rk,3397
171
171
  nat/eval/dataset_handler/dataset_handler.py,sha256=my28rKvQiiRN_h2TJz6fdKeMOjP3LC3_e2aJNnPPYhE,18159
172
172
  nat/eval/evaluator/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
173
173
  nat/eval/evaluator/base_evaluator.py,sha256=5WaVGhCGzkynCJyQdxRv7CtqLoUpr6B4O8tilP_gb3g,3232
@@ -441,7 +441,7 @@ nat/tool/memory_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
441
441
  nat/tool/memory_tools/add_memory_tool.py,sha256=N400PPvI37NUCMh5KcuoAL8khK8ecUQyfenahfjzbHQ,3368
442
442
  nat/tool/memory_tools/delete_memory_tool.py,sha256=zMllkpC0of9qFPNuG9vkVOoydRblOViCQf0uSbqz0sE,2461
443
443
  nat/tool/memory_tools/get_memory_tool.py,sha256=fcW6QE7bMZrpNK62et3sTw_QZ8cV9lXfEuDsm1-05bE,2768
444
- nat/utils/__init__.py,sha256=WRO5RDryn6mChA2gwDVERclaei7LGPwrEMCUSliZI7k,2653
444
+ nat/utils/__init__.py,sha256=v6KZnvq8gT1VK-P_g5zHgoq9lhD4wvGwqCyb67aBkTo,2859
445
445
  nat/utils/callable_utils.py,sha256=EIao6NhHRFEoBqYRC7aWoFqhlr2LeFT0XK-ac0coF9E,2475
446
446
  nat/utils/debugging_utils.py,sha256=6M4JhbHDNDnfmSRGmHvT5IgEeWSHBore3VngdE_PMqc,1332
447
447
  nat/utils/decorators.py,sha256=AoMip9zmqrZm5wovZQytNvzFfIlS3PQxSYcgYeoLhxA,8240
@@ -475,10 +475,10 @@ nat/utils/reactive/base/observer_base.py,sha256=6BiQfx26EMumotJ3KoVcdmFBYR_fnAss
475
475
  nat/utils/reactive/base/subject_base.py,sha256=UQOxlkZTIeeyYmG5qLtDpNf_63Y7p-doEeUA08_R8ME,2521
476
476
  nat/utils/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
477
477
  nat/utils/settings/global_settings.py,sha256=9JaO6pxKT_Pjw6rxJRsRlFCXdVKCl_xUKU2QHZQWWNM,7294
478
- nvidia_nat-1.4.0a20251105.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
479
- nvidia_nat-1.4.0a20251105.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
480
- nvidia_nat-1.4.0a20251105.dist-info/METADATA,sha256=et1fcmaVq-vji3uL9r4yjQQm1NQpEwfBZBi-1_fmqV4,10248
481
- nvidia_nat-1.4.0a20251105.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
482
- nvidia_nat-1.4.0a20251105.dist-info/entry_points.txt,sha256=4jCqjyETMpyoWbCBf4GalZU8I_wbstpzwQNezdAVbbo,698
483
- nvidia_nat-1.4.0a20251105.dist-info/top_level.txt,sha256=lgJWLkigiVZuZ_O1nxVnD_ziYBwgpE2OStdaCduMEGc,8
484
- nvidia_nat-1.4.0a20251105.dist-info/RECORD,,
478
+ nvidia_nat-1.4.0a20251106.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
479
+ nvidia_nat-1.4.0a20251106.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
480
+ nvidia_nat-1.4.0a20251106.dist-info/METADATA,sha256=9XCqENxlxWaybvsuRfN2Ak3clvHfVp8r5qaMNl4qSmQ,10248
481
+ nvidia_nat-1.4.0a20251106.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
482
+ nvidia_nat-1.4.0a20251106.dist-info/entry_points.txt,sha256=4jCqjyETMpyoWbCBf4GalZU8I_wbstpzwQNezdAVbbo,698
483
+ nvidia_nat-1.4.0a20251106.dist-info/top_level.txt,sha256=lgJWLkigiVZuZ_O1nxVnD_ziYBwgpE2OStdaCduMEGc,8
484
+ nvidia_nat-1.4.0a20251106.dist-info/RECORD,,