chalkruntime 3.35.4__tar.gz → 3.35.6__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.
Files changed (113) hide show
  1. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/PKG-INFO +1 -1
  2. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/overlay_graph.py +9 -1
  3. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/protograph_deserializer.py +52 -7
  4. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/server/entrypoint.py +8 -1
  5. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime.egg-info/PKG-INFO +1 -1
  6. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime.egg-info/SOURCES.txt +1 -0
  7. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/pyproject.toml +1 -1
  8. chalkruntime-3.35.6/tests/test_captured_global_function_refs.py +75 -0
  9. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/README.md +0 -0
  10. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/__init__.py +0 -0
  11. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/constants.py +0 -0
  12. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/dataframe/__init__.py +0 -0
  13. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/dataframe/dataframe.py +0 -0
  14. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/dataframe/lazyframe.py +0 -0
  15. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/exc/__init__.py +0 -0
  16. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/exc/failed_argument.py +0 -0
  17. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/exc/resolver_errors.py +0 -0
  18. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/exc/wrapped_resolver_exception.py +0 -0
  19. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/__init__.py +0 -0
  20. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/chalk_overload.py +0 -0
  21. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/convert_chalkpy_underscore.py +0 -0
  22. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/feature.py +0 -0
  23. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/filter_conversion.py +0 -0
  24. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/global_graph.py +0 -0
  25. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/graph.py +0 -0
  26. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/graph_impl.py +0 -0
  27. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/graph_proxy.py +0 -0
  28. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/graph_state.py +0 -0
  29. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/jinja_parser.py +0 -0
  30. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/materializations.py +0 -0
  31. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/maybe_named_collection.py +0 -0
  32. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/named_query.py +0 -0
  33. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/nearest_neighbor.py +0 -0
  34. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/prompt_service.py +0 -0
  35. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/protograph_serializer.py +0 -0
  36. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/resolver.py +0 -0
  37. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/singletons.py +0 -0
  38. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/sklearn_model_parser.py +0 -0
  39. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/stream_resolver.py +0 -0
  40. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/underscore.py +0 -0
  41. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/underscore_codec_info.py +0 -0
  42. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/underscore_operation_registry.py +0 -0
  43. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/graph/variables.py +0 -0
  44. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/heaptrack_launcher.py +0 -0
  45. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/incrementalization/__init__.py +0 -0
  46. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/incrementalization/group_incrementalizer.py +0 -0
  47. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/incrementalization/incrementalizer.py +0 -0
  48. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/__init__.py +0 -0
  49. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/batch_result_collector.py +0 -0
  50. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/bound_invoker.py +0 -0
  51. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/bound_invoker_cache.py +0 -0
  52. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/general_bound_invoker.py +0 -0
  53. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/no_arg_scalar_invoker.py +0 -0
  54. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/one_to_one_invoker.py +0 -0
  55. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/overlay_features.py +0 -0
  56. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/parse_external_resolver.py +0 -0
  57. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/partition_batch.py +0 -0
  58. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/query_execution_parameters.py +0 -0
  59. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/resolver_args_builder.py +0 -0
  60. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/resolver_input.py +0 -0
  61. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/resolver_input_upload.py +0 -0
  62. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/resolver_output_metadata.py +0 -0
  63. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/resolver_raw_output_parsing.py +0 -0
  64. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/resolver_result.py +0 -0
  65. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/resolver_runner.py +0 -0
  66. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/sample.py +0 -0
  67. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/validator.py +0 -0
  68. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/invoker/vectorized_hasmany_sampler.py +0 -0
  69. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/loader/__init__.py +0 -0
  70. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/loader/converter.py +0 -0
  71. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/loader/importer.py +0 -0
  72. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/memray_launcher.py +0 -0
  73. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/metadata.py +0 -0
  74. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/py.typed +0 -0
  75. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/server/__init__.py +0 -0
  76. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/server/branch_model_endpoint_config.py +0 -0
  77. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/server/config.py +0 -0
  78. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/server/env_helper.py +0 -0
  79. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/server/remote_python_function_registry_client.py +0 -0
  80. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/server/service.py +0 -0
  81. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/sql_rewriter/__init__.py +0 -0
  82. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/sql_rewriter/composed_rewriter.py +0 -0
  83. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/sql_rewriter/contextual_query_rewriter.py +0 -0
  84. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/sql_rewriter/filter_query_rewriter.py +0 -0
  85. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/sql_rewriter/identity_rewriter.py +0 -0
  86. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/sql_rewriter/query_rewriter.py +0 -0
  87. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/sql_rewriter/query_rewriter_helper.py +0 -0
  88. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/__init__.py +0 -0
  89. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/converter_utils.py +0 -0
  90. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/exc.py +0 -0
  91. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/message_parsing.py +0 -0
  92. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/resolver_utils.py +0 -0
  93. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/streaming_invoker_kernel/__init__.py +0 -0
  94. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/streaming_invoker_kernel/local_streaming_invoker_kernel.py +0 -0
  95. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/types.py +0 -0
  96. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/streaming/window_keys.py +0 -0
  97. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/utils/__init__.py +0 -0
  98. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/utils/async_helpers.py +0 -0
  99. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/utils/contextvars.py +0 -0
  100. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/utils/datadog.py +0 -0
  101. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/utils/internal_pl_utils.py +0 -0
  102. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/utils/posix_file_lock.py +0 -0
  103. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/utils/tracing.py +0 -0
  104. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/utils/viztracer_profiling.py +0 -0
  105. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime/valgrind_launcher.py +0 -0
  106. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime.egg-info/dependency_links.txt +0 -0
  107. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime.egg-info/requires.txt +0 -0
  108. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/chalkruntime.egg-info/top_level.txt +0 -0
  109. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/setup.cfg +0 -0
  110. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/setup.py +0 -0
  111. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/tests/test_branch_model_endpoint_config.py +0 -0
  112. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/tests/test_graph_cache.py +0 -0
  113. {chalkruntime-3.35.4 → chalkruntime-3.35.6}/tests/test_posix_file_lock.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chalkruntime
3
- Version: 3.35.4
3
+ Version: 3.35.6
4
4
  Summary: Runtime support library for Chalk AI
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -68,9 +68,17 @@ def add_overlay_to_graph(graph: ResolvedGraphImpl, overlay: graph_pb2.OverlayGra
68
68
  list(overlay.feature_sets) + dummy_feature_sets, graph, ctx, is_externally_defined=True
69
69
  )
70
70
 
71
+ captured_global_values = {captured.id: captured.value for captured in overlay.captured_global_values}
72
+
71
73
  # Convert new resolvers
72
74
  resolvers = [
73
- FromProtoConverter.convert_resolver(r, graph=graph, is_externally_defined=True) for r in overlay.resolvers
75
+ FromProtoConverter.convert_resolver(
76
+ r,
77
+ graph=graph,
78
+ is_externally_defined=True,
79
+ captured_global_values=captured_global_values,
80
+ )
81
+ for r in overlay.resolvers
74
82
  ]
75
83
  ctx.upsert_resolvers(resolvers, replace_on_conflict=False)
76
84
 
@@ -1574,7 +1574,11 @@ class FromProtoConverter:
1574
1574
 
1575
1575
  @classmethod
1576
1576
  def convert_stream_resolver(
1577
- cls, r: pb.StreamResolver, graph: ResolvedGraph, stream_sources: Dict[Tuple[str, str | None], StreamSource]
1577
+ cls,
1578
+ r: pb.StreamResolver,
1579
+ graph: ResolvedGraph,
1580
+ stream_sources: Dict[Tuple[str, str | None], StreamSource],
1581
+ captured_global_values: Mapping[str, pb.FunctionReferenceCapturedGlobal] | None = None,
1578
1582
  ) -> StreamResolverParsed:
1579
1583
  # Resolver outputs
1580
1584
  outputs: list[TResolverFeatureType] = []
@@ -1817,7 +1821,10 @@ class FromProtoConverter:
1817
1821
  resource_hint=None,
1818
1822
  resource_group=r.resource_group if r.HasField("resource_group") else None,
1819
1823
  function_definition=r.function.function_definition,
1820
- function_captured_globals=FromProtoConverter.convert_function_captured_globals(r.function.captured_globals),
1824
+ function_captured_globals=FromProtoConverter.convert_function_captured_globals(
1825
+ r.function.captured_globals,
1826
+ captured_global_values=captured_global_values,
1827
+ ),
1821
1828
  filename=r.function.file_name,
1822
1829
  fqn=r.fqn,
1823
1830
  module=r.function.module,
@@ -1896,7 +1903,12 @@ class FromProtoConverter:
1896
1903
  raise ValueError(f"Unsupported variant type for StreamResolverParam: '{type_name}'")
1897
1904
 
1898
1905
  @staticmethod
1899
- def convert_resolver(r: pb.Resolver, graph: ResolvedGraph, is_externally_defined: bool) -> ResolverParsed:
1906
+ def convert_resolver(
1907
+ r: pb.Resolver,
1908
+ graph: ResolvedGraph,
1909
+ is_externally_defined: bool,
1910
+ captured_global_values: Mapping[str, pb.FunctionReferenceCapturedGlobal] | None = None,
1911
+ ) -> ResolverParsed:
1900
1912
  parsed_inputs = FromProtoConverter._parse_inputs(
1901
1913
  r.inputs,
1902
1914
  graph,
@@ -2049,7 +2061,10 @@ class FromProtoConverter:
2049
2061
  return resolver_cls(
2050
2062
  function_definition=r.function.function_definition,
2051
2063
  source_line=source_line,
2052
- function_captured_globals=FromProtoConverter.convert_function_captured_globals(r.function.captured_globals),
2064
+ function_captured_globals=FromProtoConverter.convert_function_captured_globals(
2065
+ r.function.captured_globals,
2066
+ captured_global_values=captured_global_values,
2067
+ ),
2053
2068
  filename=r.function.file_name,
2054
2069
  fqn=r.fqn,
2055
2070
  module=r.function.module,
@@ -2091,6 +2106,7 @@ class FromProtoConverter:
2091
2106
  def convert_function_captured_globals(
2092
2107
  cls,
2093
2108
  captured_globals: Iterable[pb.FunctionReferenceCapturedGlobal],
2109
+ captured_global_values: Mapping[str, pb.FunctionReferenceCapturedGlobal] | None = None,
2094
2110
  ) -> Mapping[str, FunctionCapturedGlobal]:
2095
2111
  """
2096
2112
  Converts a list of protograph `FunctionReferenceCapturedGlobal` values into the equivalent Chalkpy type.
@@ -2154,7 +2170,10 @@ class FromProtoConverter:
2154
2170
  elif captured_global.HasField("function"):
2155
2171
  if not captured_global.global_name:
2156
2172
  continue
2157
- inner_captured = cls.convert_function_captured_globals(captured_global.function.captured_globals)
2173
+ inner_captured = cls.convert_function_captured_globals(
2174
+ captured_global.function.captured_globals,
2175
+ captured_global_values=captured_global_values,
2176
+ )
2158
2177
  src_ref = captured_global.source_reference if captured_global.HasField("source_reference") else None
2159
2178
  out[captured_global.global_name] = FunctionCapturedGlobalFunction(
2160
2179
  source=captured_global.function.source,
@@ -2165,6 +2184,18 @@ class FromProtoConverter:
2165
2184
  source_line_start=src_ref.range.start.line if src_ref else None,
2166
2185
  source_line_end=src_ref.range.end.line if src_ref else None,
2167
2186
  )
2187
+ elif captured_global.HasField("value_ref"):
2188
+ if not captured_global.global_name or captured_global_values is None:
2189
+ continue
2190
+ referenced_value = captured_global_values.get(captured_global.value_ref.id)
2191
+ if referenced_value is None:
2192
+ continue
2193
+ out.update(
2194
+ cls.convert_function_captured_globals(
2195
+ [referenced_value],
2196
+ captured_global_values=captured_global_values,
2197
+ )
2198
+ )
2168
2199
  elif captured_global.HasField("variable"):
2169
2200
  out[captured_global.global_name] = FunctionCapturedGlobalVariable(
2170
2201
  name=captured_global.variable.name,
@@ -2187,6 +2218,10 @@ class FromProtoConverter:
2187
2218
  def convert_graph(
2188
2219
  cls, pb_graph: pb.Graph, source_secrets: sources_pb.SourceSecrets | None = None
2189
2220
  ) -> ResolvedGraphImpl:
2221
+ captured_global_values: dict[str, pb.FunctionReferenceCapturedGlobal] = {
2222
+ captured_value.id: captured_value.value
2223
+ for captured_value in getattr(pb_graph, "captured_global_values", ())
2224
+ }
2190
2225
  sql_sources: list[BaseSQLSource] = [
2191
2226
  cls.convert_data_source(x, source_secrets) for x in pb_graph.database_sources_v2
2192
2227
  ]
@@ -2212,14 +2247,24 @@ class FromProtoConverter:
2212
2247
  list(pb_graph.feature_sets), resolved_graph, ctx, is_externally_defined=False
2213
2248
  )
2214
2249
  converted_resolvers = [
2215
- FromProtoConverter.convert_resolver(r, graph=resolved_graph, is_externally_defined=False)
2250
+ FromProtoConverter.convert_resolver(
2251
+ r,
2252
+ graph=resolved_graph,
2253
+ is_externally_defined=False,
2254
+ captured_global_values=captured_global_values,
2255
+ )
2216
2256
  for r in pb_graph.resolvers
2217
2257
  ]
2218
2258
 
2219
2259
  ctx.upsert_resolvers(converted_resolvers, replace_on_conflict=False)
2220
2260
 
2221
2261
  converted_stream_resolvers = [
2222
- cls.convert_stream_resolver(r, graph=resolved_graph, stream_sources=stream_sources_dict)
2262
+ cls.convert_stream_resolver(
2263
+ r,
2264
+ graph=resolved_graph,
2265
+ stream_sources=stream_sources_dict,
2266
+ captured_global_values=captured_global_values,
2267
+ )
2223
2268
  for r in pb_graph.stream_resolvers
2224
2269
  ]
2225
2270
  ctx.upsert_resolvers(converted_stream_resolvers, replace_on_conflict=False)
@@ -375,8 +375,12 @@ def _import_and_validate_graph(
375
375
  # 5. Capture explicit values of any function-captured global variables
376
376
  with safe_trace("get_function_capture_global_variable_values"):
377
377
  resolver_captured_global_variables: dict[bytes, types_pb.CodeVariable] = {}
378
+ captured_global_values = {
379
+ captured_value.id: captured_value.value
380
+ for captured_value in getattr(proto_export.graph, "captured_global_values", ())
381
+ }
378
382
  # Recursively collect variables from all captured globals, including those
379
- # nested inside helper functions (FunctionGlobalCapturedFunction).
383
+ # nested inside shared captured global values.
380
384
  globals_to_visit: list[FunctionReferenceCapturedGlobal] = [
381
385
  glbl for r in proto_export.graph.resolvers for glbl in r.function.captured_globals
382
386
  ]
@@ -390,6 +394,9 @@ def _import_and_validate_graph(
390
394
  )
391
395
  elif glbl.HasField("function"):
392
396
  globals_to_visit.extend(glbl.function.captured_globals)
397
+ elif glbl.HasField("value_ref"):
398
+ if glbl.value_ref.id in captured_global_values:
399
+ globals_to_visit.append(captured_global_values[glbl.value_ref.id])
393
400
  variable_values = get_variables(resolver_captured_global_variables.values())
394
401
 
395
402
  return ImportGraphResult.make_successful(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chalkruntime
3
- Version: 3.35.4
3
+ Version: 3.35.6
4
4
  Summary: Runtime support library for Chalk AI
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -144,5 +144,6 @@ chalkruntime/utils/posix_file_lock.py
144
144
  chalkruntime/utils/tracing.py
145
145
  chalkruntime/utils/viztracer_profiling.py
146
146
  tests/test_branch_model_endpoint_config.py
147
+ tests/test_captured_global_function_refs.py
147
148
  tests/test_graph_cache.py
148
149
  tests/test_posix_file_lock.py
@@ -42,7 +42,7 @@ name = "chalkruntime"
42
42
  description = "Runtime support library for Chalk AI"
43
43
  readme = "README.md"
44
44
  requires-python = ">=3.10"
45
- version = "3.35.4"
45
+ version = "3.35.6"
46
46
 
47
47
 
48
48
  [tool.deptry]
@@ -0,0 +1,75 @@
1
+ from chalk._gen.chalk.graph.v1 import graph_pb2
2
+ from chalk.features.resolver import FunctionCapturedGlobalFunction, FunctionCapturedGlobalVariable
3
+
4
+ from chalkruntime.graph.protograph_deserializer import FromProtoConverter
5
+
6
+
7
+ def test_convert_function_captured_globals_resolves_value_refs() -> None:
8
+ converted = FromProtoConverter.convert_function_captured_globals(
9
+ [
10
+ graph_pb2.FunctionReferenceCapturedGlobal(
11
+ global_name="helper",
12
+ value_ref=graph_pb2.FunctionGlobalCapturedValueRef(id="helper-id"),
13
+ )
14
+ ],
15
+ captured_global_values={
16
+ "helper-id": graph_pb2.FunctionReferenceCapturedGlobal(
17
+ global_name="helper",
18
+ function=graph_pb2.FunctionGlobalCapturedFunction(
19
+ name="helper",
20
+ module="test_module",
21
+ source="def helper():\n return GLOBAL_VALUE\n",
22
+ captured_globals=[
23
+ graph_pb2.FunctionReferenceCapturedGlobal(
24
+ global_name="GLOBAL_VALUE",
25
+ value_ref=graph_pb2.FunctionGlobalCapturedValueRef(id="global-value-id"),
26
+ )
27
+ ],
28
+ ),
29
+ ),
30
+ "global-value-id": graph_pb2.FunctionReferenceCapturedGlobal(
31
+ global_name="GLOBAL_VALUE",
32
+ variable=graph_pb2.FunctionGlobalCapturedVariable(
33
+ name="GLOBAL_VALUE",
34
+ module="test_module",
35
+ ),
36
+ ),
37
+ },
38
+ )
39
+
40
+ helper = converted["helper"]
41
+ assert isinstance(helper, FunctionCapturedGlobalFunction)
42
+ assert helper.name == "helper"
43
+ assert helper.module == "test_module"
44
+ assert helper.source == "def helper():\n return GLOBAL_VALUE\n"
45
+ assert helper.captured_globals is not None
46
+
47
+ global_value = helper.captured_globals["GLOBAL_VALUE"]
48
+ assert isinstance(global_value, FunctionCapturedGlobalVariable)
49
+ assert global_value.name == "GLOBAL_VALUE"
50
+ assert global_value.module == "test_module"
51
+
52
+
53
+ def test_convert_function_captured_globals_resolves_variable_value_refs() -> None:
54
+ converted = FromProtoConverter.convert_function_captured_globals(
55
+ [
56
+ graph_pb2.FunctionReferenceCapturedGlobal(
57
+ global_name="GLOBAL_VALUE",
58
+ value_ref=graph_pb2.FunctionGlobalCapturedValueRef(id="global-value-id"),
59
+ )
60
+ ],
61
+ captured_global_values={
62
+ "global-value-id": graph_pb2.FunctionReferenceCapturedGlobal(
63
+ global_name="GLOBAL_VALUE",
64
+ variable=graph_pb2.FunctionGlobalCapturedVariable(
65
+ name="GLOBAL_VALUE",
66
+ module="test_module",
67
+ ),
68
+ )
69
+ },
70
+ )
71
+
72
+ global_value = converted["GLOBAL_VALUE"]
73
+ assert isinstance(global_value, FunctionCapturedGlobalVariable)
74
+ assert global_value.name == "GLOBAL_VALUE"
75
+ assert global_value.module == "test_module"
File without changes
File without changes
File without changes