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 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented May 15, 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 Nourollah May 15, 2023 07:14
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.

Sourcery timed out performing refactorings.

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

version += "+" + sha[:7]
version += f"+{sha[:7]}"
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_version refactored with the following changes:

Comment on lines -101 to +102
match = re.match(r"^\s*URL\s+(https:\/\/.+)$", line)
if match:
url = match.group(1)
yield url
if match := re.match(r"^\s*URL\s+(https:\/\/.+)$", line):
yield match[1]
Copy link
Author

Choose a reason for hiding this comment

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

Function _parse_url refactored with the following changes:

Comment on lines -147 to +145
with open("README.md") as f:
long_description = f.read()

long_description = Path("README.md").read_text()
Copy link
Author

Choose a reason for hiding this comment

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

Function _main refactored with the following changes:

  • Simplify basic file reads with pathlib (path-read)

Comment on lines -68 to +78
w = []
base_workflow_name = f"{prefix}binary_{os_type}_{btype}_py{python_version}_{cu_version}"
w.append(generate_base_workflow(base_workflow_name, python_version, cu_version, filter_branch, os_type, btype))

w = [
generate_base_workflow(
base_workflow_name,
python_version,
cu_version,
filter_branch,
os_type,
btype,
)
]
Copy link
Author

Choose a reason for hiding this comment

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

Function build_workflow_pair refactored with the following changes:

Comment on lines -143 to +150
d["subfolder"] = "" if os_type == "macos" else cu_version + "/"
d["subfolder"] = "" if os_type == "macos" else f"{cu_version}/"
Copy link
Author

Choose a reason for hiding this comment

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

Function generate_upload_workflow refactored with the following changes:

file_text = speaker_id + "-" + chapter_id + self.base_dataset._ext_txt
file_text = f"{speaker_id}-{chapter_id}{self.base_dataset._ext_txt}"
Copy link
Author

Choose a reason for hiding this comment

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

Function CustomDataset._target_length refactored with the following changes:

Comment on lines -197 to -204
dataloader = torch.utils.data.DataLoader(
return torch.utils.data.DataLoader(
dataset,
batch_size=None,
collate_fn=self._train_collate_fn,
num_workers=10,
shuffle=True,
)
return dataloader
Copy link
Author

Choose a reason for hiding this comment

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

Function LibriSpeechRNNTModule.train_dataloader refactored with the following changes:

Comment on lines -219 to -225
dataloader = torch.utils.data.DataLoader(
return torch.utils.data.DataLoader(
dataset,
batch_size=None,
collate_fn=self._valid_collate_fn,
num_workers=10,
)
return dataloader
Copy link
Author

Choose a reason for hiding this comment

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

Function LibriSpeechRNNTModule.val_dataloader refactored with the following changes:

dataloader = torch.utils.data.DataLoader(dataset, batch_size=1, collate_fn=self._test_collate_fn)
return dataloader
return torch.utils.data.DataLoader(
dataset, batch_size=1, collate_fn=self._test_collate_fn
)
Copy link
Author

Choose a reason for hiding this comment

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

Function LibriSpeechRNNTModule.test_dataloader refactored with the following changes:

Comment on lines -161 to -168
dataloader = torch.utils.data.DataLoader(
return torch.utils.data.DataLoader(
dataset,
batch_size=None,
collate_fn=self._train_collate_fn,
num_workers=10,
shuffle=True,
)
return dataloader
Copy link
Author

Choose a reason for hiding this comment

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

Function MuSTCRNNTModule.train_dataloader refactored with the following changes:

Comment on lines -172 to -178
dataloader = torch.utils.data.DataLoader(
return torch.utils.data.DataLoader(
dataset,
batch_size=None,
collate_fn=self._valid_collate_fn,
num_workers=10,
)
return dataloader
Copy link
Author

Choose a reason for hiding this comment

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

Function MuSTCRNNTModule.val_dataloader refactored with the following changes:

dataloader = torch.utils.data.DataLoader(dataset, batch_size=1, collate_fn=self._test_collate_fn)
return dataloader
return torch.utils.data.DataLoader(
dataset, batch_size=1, collate_fn=self._test_collate_fn
)
Copy link
Author

Choose a reason for hiding this comment

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

Function MuSTCRNNTModule.test_common_dataloader refactored with the following changes:

Comment on lines -187 to +188
dataloader = torch.utils.data.DataLoader(dataset, batch_size=1, collate_fn=self._test_collate_fn)
return dataloader
return torch.utils.data.DataLoader(
dataset, batch_size=1, collate_fn=self._test_collate_fn
)
Copy link
Author

Choose a reason for hiding this comment

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

Function MuSTCRNNTModule.test_he_dataloader refactored with the following changes:

Comment on lines -192 to +194
dataloader = torch.utils.data.DataLoader(dataset, batch_size=1, collate_fn=self._test_collate_fn)
return dataloader
return torch.utils.data.DataLoader(
dataset, batch_size=1, collate_fn=self._test_collate_fn
)
Copy link
Author

Choose a reason for hiding this comment

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

Function MuSTCRNNTModule.dev_dataloader refactored with the following changes:

assert len(idx_target_lengths) > 0
assert idx_target_lengths
Copy link
Author

Choose a reason for hiding this comment

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

Function CustomDataset.__init__ refactored with the following changes:

Comment on lines -51 to +52
else:
scaling_factor = self.anneal_factor ** (self._step_count - self.force_anneal_step)
return [scaling_factor * base_lr for base_lr in self.base_lrs]
scaling_factor = self.anneal_factor ** (self._step_count - self.force_anneal_step)
return [scaling_factor * base_lr for base_lr in self.base_lrs]
Copy link
Author

Choose a reason for hiding this comment

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

Function WarmupLR.get_lr refactored with the following changes:

Comment on lines -73 to +72
nbest_batch = list(zip(hypos_str, hypos_score, hypos_ids))

return nbest_batch
return list(zip(hypos_str, hypos_score, hypos_ids))
Copy link
Author

Choose a reason for hiding this comment

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

Function post_process_hypos refactored with the following changes:

file_text = speaker_id + "-" + chapter_id + librispeech_dataset._ext_txt
file_text = f"{speaker_id}-{chapter_id}{librispeech_dataset._ext_txt}"
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_sample_lengths refactored with the following changes:

Comment on lines -167 to -173
dataloader = torch.utils.data.DataLoader(
return torch.utils.data.DataLoader(
dataset,
num_workers=self.num_workers,
batch_size=None,
shuffle=self.train_shuffle,
)
return dataloader
Copy link
Author

Choose a reason for hiding this comment

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

Function LibriSpeechDataModule.train_dataloader refactored with the following changes:

Comment on lines -197 to +198
dataloader = torch.utils.data.DataLoader(dataset, batch_size=None, num_workers=self.num_workers)
return dataloader
return torch.utils.data.DataLoader(
dataset, batch_size=None, num_workers=self.num_workers
)
Copy link
Author

Choose a reason for hiding this comment

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

Function LibriSpeechDataModule.val_dataloader refactored with the following changes:

dataloader = torch.utils.data.DataLoader(dataset, batch_size=None)
return dataloader
return torch.utils.data.DataLoader(dataset, batch_size=None)
Copy link
Author

Choose a reason for hiding this comment

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

Function LibriSpeechDataModule.test_dataloader refactored with the following changes:

Comment on lines -42 to +46
filename = "librispeech_clean_100_{}".format(idx)
filename = f"librispeech_clean_100_{idx}"
actual = sample[0][2]
predicted = model(batch)
hypout.append("{} ({})\n".format(predicted.upper().strip(), filename))
refout.append("{} ({})\n".format(actual.upper().strip(), filename))
hypout.append(f"{predicted.upper().strip()} ({filename})\n")
refout.append(f"{actual.upper().strip()} ({filename})\n")
Copy link
Author

Choose a reason for hiding this comment

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

Function run_eval refactored with the following changes:

Comment on lines -50 to +51
else:
scaling_factor = self.anneal_factor ** (self._step_count - self.force_anneal_step)
return [scaling_factor * base_lr for base_lr in self.base_lrs]
scaling_factor = self.anneal_factor ** (self._step_count - self.force_anneal_step)
return [scaling_factor * base_lr for base_lr in self.base_lrs]
Copy link
Author

Choose a reason for hiding this comment

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

Function WarmupLR.get_lr refactored with the following changes:

Comment on lines -72 to +71
nbest_batch = list(zip(hypos_str, hypos_score, hypos_ids))

return nbest_batch
return list(zip(hypos_str, hypos_score, hypos_ids))
Copy link
Author

Choose a reason for hiding this comment

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

Function post_process_hypos refactored with the following changes:

rareset = set()
for line in fin:
rareset.add(line.strip().upper())

rareset = {line.strip().upper() for line in fin}
Copy link
Author

Choose a reason for hiding this comment

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

Lines 18-111 refactored with the following changes:

Comment on lines -534 to -540
dataloader = DataLoader(
return DataLoader(
dataset,
batch_sampler=sampler,
collate_fn=CollateFnLibriLightLimited(),
num_workers=10,
)
return dataloader
Copy link
Author

Choose a reason for hiding this comment

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

Function HuBERTFineTuneModule.val_dataloader refactored with the following changes:

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Author

Choose a reason for hiding this comment

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

Function _parse_args refactored with the following changes:

Comment on lines -89 to +88
if args.use_gpu:
device = torch.device("cuda")
else:
device = torch.device("cpu")

device = torch.device("cuda") if args.use_gpu else torch.device("cpu")
Copy link
Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

if len(filtered_length_idx) == 0:
if not filtered_length_idx:
Copy link
Author

Choose a reason for hiding this comment

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

Function BucketizeBatchSampler.__init__ refactored with the following changes:

buckets = {k: v for k, v in sorted(buckets.items())}
buckets = dict(sorted(buckets.items()))
Copy link
Author

Choose a reason for hiding this comment

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

Function BucketizeBatchSampler._get_buckets refactored with the following changes:

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.

0 participants