Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Sourcery refactored main branch #1

wants to merge 2 commits into from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented May 12, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from sarvex May 12, 2023 06:12
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -178 to -179
# Make sure to sync the versions of common dependencies (absl-py, numpy,
# six, and protobuf) with TF.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 178-217 refactored with the following changes:

This removes the following comments ( why? ):

# Make sure to sync the versions of common dependencies (absl-py, numpy,
# six, and protobuf) with TF.

raise ValueError("Could not guess file format for: {}".format(filename))
raise ValueError(f"Could not guess file format for: {filename}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function guess_file_format refactored with the following changes:

return match.group(1) if match else file_pattern
return match[1] if match else file_pattern
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_base_filename refactored with the following changes:

Comment on lines -72 to -76
match = re.fullmatch(r"(.*)@(\d+)", file_pattern)
if not match:
if match := re.fullmatch(r"(.*)@(\d+)", file_pattern):
return "{}-?????-of-{:05d}".format(match[1], int(match[2]))
else:
return file_pattern
num_shards = int(match.group(2))
return "{}-?????-of-{:05d}".format(match.group(1), num_shards)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function expand_sharded_pattern refactored with the following changes:

Comment on lines -92 to +107
# TODO(blais): Eventually support file suffixes.
match = re.fullmatch(r"(.*)@(\d+)", pattern)
if match:
if match := re.fullmatch(r"(.*)@(\d+)", pattern):
# Beam would unpack automatically for internal containers, but we need this
# for the open source implementation of the Beam runner.
return dict(file_path_prefix=match.group(1),
num_shards=int(match.group(2)),
shard_name_template="-SSSSS-of-NNNNN")
return dict(
file_path_prefix=match[1],
num_shards=int(match[2]),
shard_name_template="-SSSSS-of-NNNNN",
)
if match := re.fullmatch(r"(.*)-(?:\d|\?){5}-of-(\d{5})", pattern):
return dict(
file_path_prefix=match[1],
num_shards=int(match[2]),
shard_name_template="-SSSSS-of-NNNNN",
)
else:
match = re.fullmatch(r"(.*)-(?:\d|\?){5}-of-(\d{5})", pattern)
if match:
return dict(file_path_prefix=match.group(1),
num_shards=int(match.group(2)),
shard_name_template="-SSSSS-of-NNNNN")
else:
return dict(file_path_prefix=pattern,
num_shards=None, shard_name_template="")
return dict(file_path_prefix=pattern,
num_shards=None, shard_name_template="")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_sharded_pattern_args refactored with the following changes:

This removes the following comments ( why? ):

# TODO(blais): Eventually support file suffixes.

Comment on lines -823 to +824
node_sets_spec = _ifnone(node_sets_spec, dict())
edge_sets_spec = _ifnone(edge_sets_spec, dict())
node_sets_spec = _ifnone(node_sets_spec, {})
edge_sets_spec = _ifnone(edge_sets_spec, {})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GraphTensorSpec.from_piece_specs refactored with the following changes:

if node_sets:
return first_by_name(node_sets)
return context
return first_by_name(node_sets) if node_sets else context
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _get_indicative_graph_entity refactored with the following changes:

Comment on lines -928 to +926
if isinstance(data, Mapping):
self._data = data
else:
self._data = dict(data)
self._data = data if isinstance(data, Mapping) else dict(data)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _ImmutableMapping.__init__ refactored with the following changes:

Comment on lines -232 to +233
result.update(
_flatten_graph_field_specs(graph_spec.context_spec,
f'{prefix}{gc.CONTEXT}/'))
result |= _flatten_graph_field_specs(graph_spec.context_spec,
f'{prefix}{gc.CONTEXT}/')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _ refactored with the following changes:

Comment on lines -252 to +251
result.update(_prefix_keys(node_set_spec.features_spec, prefix))
result |= _prefix_keys(node_set_spec.features_spec, prefix)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _ refactored with the following changes:

@sonarcloud
Copy link

sonarcloud bot commented May 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

sarvex pushed a commit that referenced this pull request May 30, 2023
This is work-in-progress

PiperOrigin-RevId: 491067724
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant