Skip to content

Commit f20dbde

Browse files
h-jootensorflower-gardener
authored andcommitted
No public description
PiperOrigin-RevId: 941349341
1 parent e09c05e commit f20dbde

28 files changed

Lines changed: 137 additions & 137 deletions

tensorflow_gnn/experimental/sampler/beam/accessors_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_string_keys(self):
6868
}
6969
layer = sampler.KeyToTfExampleAccessor(
7070
sampler.InMemStringKeyToBytesAccessor(
71-
keys_to_values=table, name='table'
71+
keys_to_values=table, name='table' # pyrefly: ignore[bad-argument-type]
7272
),
7373
features_spec={
7474
's': tf.TensorSpec([], tf.int64),

tensorflow_gnn/experimental/sampler/beam/edge_samplers_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def test_sampling_stats(self):
254254
edges_layer = sampler.UniformEdgesSampler(
255255
sampler.KeyToTfExampleAccessor(
256256
sampler.InMemStringKeyToBytesAccessor(
257-
keys_to_values={b'?': b''}, name='edges'
257+
keys_to_values={b'?': b''}, name='edges' # pyrefly: ignore[bad-argument-type]
258258
),
259259
features_spec={
260260
'#target': tf.TensorSpec([None], tf.string),
@@ -313,7 +313,7 @@ def test_missing_values(self):
313313
edges_layer = sampler.UniformEdgesSampler(
314314
sampler.KeyToTfExampleAccessor(
315315
sampler.InMemStringKeyToBytesAccessor(
316-
keys_to_values={b'?': b''}, name='edges'
316+
keys_to_values={b'?': b''}, name='edges' # pyrefly: ignore[bad-argument-type]
317317
),
318318
features_spec={
319319
'#target': tf.TensorSpec([None], tf.int64),
@@ -437,7 +437,7 @@ def test_edge_features(self, feature_name: str, shape: List[int]):
437437
edges_layer = sampler.UniformEdgesSampler(
438438
sampler.KeyToTfExampleAccessor(
439439
sampler.InMemStringKeyToBytesAccessor(
440-
keys_to_values={b'?': b''}, name='edges'
440+
keys_to_values={b'?': b''}, name='edges' # pyrefly: ignore[bad-argument-type]
441441
),
442442
features_spec={
443443
'#target': tf.TensorSpec([None], tf.string),
@@ -504,7 +504,7 @@ def test_ragged_features(self):
504504
edges_layer = sampler.UniformEdgesSampler(
505505
sampler.KeyToTfExampleAccessor(
506506
sampler.InMemStringKeyToBytesAccessor(
507-
keys_to_values={b'?': b''}, name='edges'
507+
keys_to_values={b'?': b''}, name='edges' # pyrefly: ignore[bad-argument-type]
508508
),
509509
features_spec={
510510
'neighbors': tf.TensorSpec([None], tf.int64),

tensorflow_gnn/experimental/sampler/beam/executor_lib.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ def process(
268268
self, inputs: Tuple[bytes, Tuple[str, Values]]
269269
) -> Iterator[Tuple[bytes, Values]]:
270270
example_id, (stage_id, values) = inputs
271-
inputs = []
271+
inputs = [] # pyrefly: ignore[bad-assignment]
272272
for matcher in self._stage.input_matchers:
273273
assert matcher.stage_id == stage_id, example_id
274-
inputs.append(values[matcher.output_index])
275-
yield (example_id, inputs)
274+
inputs.append(values[matcher.output_index]) # pyrefly: ignore[missing-attribute]
275+
yield (example_id, inputs) # pyrefly: ignore[invalid-yield]
276276

277277
@beam_typehints.with_input_types(
278278
Tuple[ExampleId, Iterable[Tuple[str, Values]]]
@@ -289,11 +289,11 @@ def process(
289289
) -> Iterator[Tuple[bytes, Values]]:
290290
example_id, outputs = inputs
291291
outputs = dict(outputs)
292-
inputs = []
292+
inputs = [] # pyrefly: ignore[bad-assignment]
293293
for matcher in self._stage.input_matchers:
294294
values = outputs[matcher.stage_id]
295-
inputs.append(values[matcher.output_index])
296-
yield (example_id, inputs)
295+
inputs.append(values[matcher.output_index]) # pyrefly: ignore[missing-attribute]
296+
yield (example_id, inputs) # pyrefly: ignore[invalid-yield]
297297

298298
def __init__(self, stage: pb.Stage):
299299
self._stage = stage
@@ -364,11 +364,11 @@ def __init__(
364364
def expand(
365365
self, inputs: Tuple[Dict[str, PValues], Dict[str, PFeed]]
366366
) -> PValues:
367-
inputs, feeds = inputs
367+
inputs, feeds = inputs # pyrefly: ignore[bad-assignment]
368368
return _execute(
369369
self._eval_dag,
370370
self._layers,
371-
inputs,
371+
inputs, # pyrefly: ignore[bad-argument-type]
372372
feeds=feeds,
373373
artifacts_path=self._artifacts_path,
374374
)

tensorflow_gnn/experimental/sampler/beam/executor_lib_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,16 @@ def test_any_composite(self):
214214

215215
i = tf.keras.Input([2], name='input')
216216
o = i
217-
o = tf.keras.layers.Lambda(tf.sparse.from_dense)(o)
218-
o = tf.keras.layers.Lambda(tf.math.negative)(o)
217+
o = tf.keras.layers.Lambda(tf.sparse.from_dense)(o) # pyrefly: ignore[not-callable]
218+
o = tf.keras.layers.Lambda(tf.math.negative)(o) # pyrefly: ignore[not-callable]
219219
# Add identity composite layer which splits eval data on five pieces:
220220
# <input> => <to negative sparse> => identity -> <to dense> => output.
221-
o = Identity()(o)
221+
o = Identity()(o) # pyrefly: ignore[not-callable]
222222

223223
def fn(t):
224224
return tf.sparse.to_dense(t)
225225

226-
o = tf.keras.layers.Lambda(fn)(o)
226+
o = tf.keras.layers.Lambda(fn)(o) # pyrefly: ignore[not-callable]
227227
model = tf.keras.Model(inputs=i, outputs=o)
228228
program, artifacts = sampler.create_program(model)
229229
self.assertLen(program.eval_dag.stages, 5)

tensorflow_gnn/experimental/sampler/beam/sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def node_features_accessor_factory(
135135
node_set_name: tfgnn.NodeSetName,
136136
) -> sampler.KeyToTfExampleAccessor:
137137
if not graph_schema.node_sets[node_set_name].features:
138-
return None
138+
return None # pyrefly: ignore[bad-return]
139139

140140
node_features = graph_schema.node_sets[node_set_name].features
141141

tensorflow_gnn/experimental/sampler/beam/subgraph_pipeline_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _get_sampling_model(self, ids_dtype) -> tf.keras.Model:
4444
graph_schema.node_sets['a'].description = 'node set b'
4545
graph_schema.edge_sets['a->b'].source = 'a'
4646
graph_schema.edge_sets['a->b'].target = 'b'
47-
graph_schema.edge_sets['a->a'].features['weights'].dtype = 1
47+
graph_schema.edge_sets['a->a'].features['weights'].dtype = 1 # pyrefly: ignore[bad-assignment]
4848

4949
sampling_spec = tfgnn.sampler.SamplingSpec()
5050
sampling_spec.seed_op.op_name = 'seed'
@@ -57,7 +57,7 @@ def edge_sampler_factory(sampling_op):
5757
self.assertEqual(sampling_op.edge_set_name, 'a->b')
5858
if ids_dtype == tf.string:
5959
accessor = sampler.InMemStringKeyToBytesAccessor(
60-
keys_to_values={b'a': b''}
60+
keys_to_values={b'a': b''} # pyrefly: ignore[bad-argument-type]
6161
)
6262
else:
6363
accessor = sampler.InMemIntegerKeyToBytesAccessor(

tensorflow_gnn/experimental/sampler/beam/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,21 @@ def parse_tf_example(
257257
`[c.numpy() for c in [*rt.flat_values, *rt.nested_row_lengths()]]`.
258258
"""
259259
if spec.HasField('tensor'):
260-
spec = spec.tensor
260+
spec = spec.tensor # pyrefly: ignore[bad-assignment]
261261
return [
262262
_parse_tf_feature(
263263
example,
264264
name,
265-
get_np_dtype(spec.dtype),
266-
tuple(dim.size for dim in spec.shape.dim),
265+
get_np_dtype(spec.dtype), # pyrefly: ignore[missing-attribute]
266+
tuple(dim.size for dim in spec.shape.dim), # pyrefly: ignore[missing-attribute]
267267
)
268268
]
269269
elif spec.HasField('ragged_tensor'):
270-
spec = spec.ragged_tensor
271-
dtype = get_np_dtype(spec.dtype)
272-
ragged_rank = spec.ragged_rank
273-
row_splits_dtype = get_np_dtype(spec.row_splits_dtype)
274-
shape = tuple(dim.size for dim in spec.shape.dim)
270+
spec = spec.ragged_tensor # pyrefly: ignore[bad-assignment]
271+
dtype = get_np_dtype(spec.dtype) # pyrefly: ignore[missing-attribute]
272+
ragged_rank = spec.ragged_rank # pyrefly: ignore[missing-attribute]
273+
row_splits_dtype = get_np_dtype(spec.row_splits_dtype) # pyrefly: ignore[missing-attribute]
274+
shape = tuple(dim.size for dim in spec.shape.dim) # pyrefly: ignore[missing-attribute]
275275

276276
flat_value = _parse_tf_feature(example, name, dtype, shape[ragged_rank:])
277277

tensorflow_gnn/experimental/sampler/beam/utils_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def test_dense_slice(
134134
limit: int,
135135
expected: np.ndarray,
136136
):
137-
value = [value]
138-
expected = [expected]
139-
actual = utils.ragged_slice(value, start, limit)
137+
value = [value] # pyrefly: ignore[bad-assignment]
138+
expected = [expected] # pyrefly: ignore[bad-assignment]
139+
actual = utils.ragged_slice(value, start, limit) # pyrefly: ignore[bad-argument-type]
140140
tf.nest.map_structure(self.assertAllEqual, actual, expected)
141141

142142
@parameterized.named_parameters([
@@ -194,9 +194,9 @@ def as_value(r: tf.RaggedTensor) -> List[np.ndarray]:
194194
lambda t: t.numpy(), [r.flat_values, *r.nested_row_lengths()]
195195
)
196196

197-
value = as_value(value)
198-
expected = as_value(expected)
199-
actual = utils.ragged_slice(value, start, limit)
197+
value = as_value(value) # pyrefly: ignore[bad-assignment]
198+
expected = as_value(expected) # pyrefly: ignore[bad-assignment]
199+
actual = utils.ragged_slice(value, start, limit) # pyrefly: ignore[bad-argument-type]
200200
tf.nest.map_structure(self.assertAllEqual, actual, expected)
201201

202202

tensorflow_gnn/graph/adjacency.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ def _merge_batch_to_components(
199199
assert isinstance(flat_adj, HyperAdjacency)
200200

201201
def flatten_indices(node_tag_key, index: Field) -> Field:
202-
node_set_name = self.spec._metadata[node_tag_key] # pylint: disable=protected-access
203-
return utils.flatten_indices(index, num_edges_per_example,
204-
num_nodes_per_example[node_set_name])
202+
node_set_name = self.spec._metadata[node_tag_key] # pylint: disable=protected-access # pyrefly: ignore[unsupported-operation]
203+
return utils.flatten_indices(index, num_edges_per_example, # pyrefly: ignore[bad-argument-type]
204+
num_nodes_per_example[node_set_name]) # pyrefly: ignore[bad-argument-type, bad-index]
205205

206206
new_data = {
207207
node_tag_key: flatten_indices(node_tag_key, index)
@@ -324,7 +324,7 @@ def get_index_specs_dict(
324324

325325
def node_set_name(self, node_set_tag: IncidentNodeTag) -> NodeSetName:
326326
"""Returns a node set name for the given node set tag."""
327-
return self._metadata[_node_tag_to_index_key(node_set_tag)]
327+
return self._metadata[_node_tag_to_index_key(node_set_tag)] # pyrefly: ignore[bad-return, unsupported-operation]
328328

329329
@property
330330
def total_size(self) -> Optional[int]:
@@ -477,7 +477,7 @@ class AdjacencySpec(HyperAdjacencySpec):
477477
"""A type spec for `tfgnn.Adjacency`."""
478478

479479
@classmethod
480-
def from_incident_node_sets(
480+
def from_incident_node_sets( # pyrefly: ignore[bad-override]
481481
cls,
482482
source_node_set: NodeSetName,
483483
target_node_set: NodeSetName,
@@ -602,25 +602,25 @@ def check_compatibility(tag_0, name_0, index_0, tag_i, name_i, index_i):
602602

603603
raise ValueError(err_message)
604604

605-
indices = sorted(list(indices.items()), key=lambda i: i[0])
605+
indices = sorted(list(indices.items()), key=lambda i: i[0]) # pyrefly: ignore[bad-assignment]
606606
tag_0, (name_0, index_0) = indices[0]
607607
check_index(tag_0, name_0, index_0)
608-
for tag_i, (name_i, index_i) in indices[1:]:
608+
for tag_i, (name_i, index_i) in indices[1:]: # pyrefly: ignore[bad-index]
609609
check_index(tag_i, name_i, index_i)
610610
check_compatibility(tag_0, name_0, index_0, tag_i, name_i, index_i)
611611

612612
# Apply identity operations to all index tensors to ensure that assertions are
613613
# executed in the graph mode.
614614
if not assert_ops:
615615
result = {
616-
node_tag: (node_set, index) for node_tag, (node_set, index) in indices
616+
node_tag: (node_set, index) for node_tag, (node_set, index) in indices # pyrefly: ignore[not-iterable]
617617
}
618618
else:
619619
assert allow_tf_assertions
620620
with tf.control_dependencies(assert_ops):
621621
result = {
622622
node_tag: (node_set, tf.identity(index))
623-
for node_tag, (node_set, index) in indices
623+
for node_tag, (node_set, index) in indices # pyrefly: ignore[not-iterable]
624624
}
625625

626626
return result

tensorflow_gnn/graph/batching_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def get_next_state(state: _ScanState,
145145
def exceeds_budget(state: _ScanState,
146146
graph_tensor: gt.GraphTensor) -> tf.Tensor:
147147
budget = _set_min_nodes_per_component(state.budget_left,
148-
min_nodes_per_component)
148+
min_nodes_per_component) # pyrefly: ignore[bad-argument-type]
149149
within_budget = padding_ops.satisfies_size_constraints(graph_tensor, budget)
150150
return tf.math.logical_not(within_budget)
151151

@@ -631,9 +631,9 @@ def _set_min_nodes_per_component(
631631

632632
return SizeConstraints(
633633
total_num_components=size_constraints.total_num_components,
634-
total_num_nodes=size_constraints.total_num_nodes.copy(),
635-
total_num_edges=size_constraints.total_num_edges.copy(),
636-
min_nodes_per_component=min_nodes_per_component.copy())
634+
total_num_nodes=size_constraints.total_num_nodes.copy(), # pyrefly: ignore[missing-attribute]
635+
total_num_edges=size_constraints.total_num_edges.copy(), # pyrefly: ignore[missing-attribute]
636+
min_nodes_per_component=min_nodes_per_component.copy()) # pyrefly: ignore[missing-attribute]
637637

638638

639639
def _make_room_for_padding(
@@ -876,4 +876,4 @@ def restored_generator():
876876
yield value
877877

878878
return tf.data.Dataset.from_generator(
879-
restored_generator, output_signature=relaxed_spec)
879+
restored_generator, output_signature=relaxed_spec) # pyrefly: ignore[bad-argument-type]

0 commit comments

Comments
 (0)