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

Update precommit flake8 #3961

Merged
merged 3 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,20 @@ repos:
files: "gym-unity/.*"
args: [--ignore-missing-imports, --disallow-incomplete-defs]

- repo: https://gitlab.com/pycqa/flake8
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rev: 3.8.1
hooks:
- id: flake8
exclude: >
(?x)^(
.*_pb2.py|
.*_pb2_grpc.py
)$
# flake8-tidy-imports is used for banned-modules, not actually tidying
additional_dependencies: [flake8-comprehensions==3.2.2, flake8-tidy-imports==4.1.0, flake8-bugbear==20.1.4]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also updated the versions of these (no new errors)


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v2.5.0
hooks:
- id: mixed-line-ending
exclude: >
Expand All @@ -38,14 +50,7 @@ repos:
.*.meta
)$
args: [--fix=lf]
- id: flake8
exclude: >
(?x)^(
.*_pb2.py|
.*_pb2_grpc.py
)$
# flake8-tidy-imports is used for banned-modules, not actually tidying
additional_dependencies: [flake8-comprehensions==3.1.4, flake8-tidy-imports==4.0.0, flake8-bugbear==20.1.2]

- id: trailing-whitespace
name: trailing-whitespace-markdown
types: [markdown]
Expand Down
4 changes: 2 additions & 2 deletions ml-agents/mlagents/trainers/ppo/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ def _update_policy(self):
self.update_buffer.shuffle(sequence_length=self.policy.sequence_length)
buffer = self.update_buffer
max_num_batch = buffer_length // batch_size
for l in range(0, max_num_batch * batch_size, batch_size):
for i in range(0, max_num_batch * batch_size, batch_size):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out this warning specifically warns about l, I, and O.

update_stats = self.optimizer.update(
buffer.make_mini_batch(l, l + batch_size), n_sequences
buffer.make_mini_batch(i, i + batch_size), n_sequences
)
for stat_name, value in update_stats.items():
batch_update_stats[stat_name].append(value)
Expand Down
2 changes: 1 addition & 1 deletion ml-agents/mlagents/trainers/subprocess_env_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def external_brains(self) -> Dict[BehaviorName, BrainParameters]:
return self.env_workers[0].recv().payload

def close(self) -> None:
logger.debug(f"SubprocessEnvManager closing.")
logger.debug("SubprocessEnvManager closing.")
self.step_queue.close()
self.step_queue.join_thread()
for env_worker in self.env_workers:
Expand Down
6 changes: 3 additions & 3 deletions ml-agents/tests/yamato/check_coverage_percent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def check_coverage(root_dir, min_percentage):
# Rather than try to parse the XML, just look for a line of the form
# <Linecoverage>73.9</Linecoverage>
lines = f.readlines()
for l in lines:
if "Linecoverage" in l:
pct = l.replace("<Linecoverage>", "").replace("</Linecoverage>", "")
for line in lines:
if "Linecoverage" in line:
pct = line.replace("<Linecoverage>", "").replace("</Linecoverage>", "")
pct = float(pct)
if pct < min_percentage:
print(
Expand Down
2 changes: 1 addition & 1 deletion ml-agents/tests/yamato/yamato_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def undo_git_checkout():
subprocess.check_call("git reset HEAD .", shell=True)
subprocess.check_call("git checkout -- .", shell=True)
# Ensure the cache isn't polluted with old compiled assemblies.
subprocess.check_call(f"rm -rf Project/Library", shell=True)
subprocess.check_call("rm -rf Project/Library", shell=True)


def override_config_file(src_path, dest_path, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions utils/validate_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def _escape_non_none(s: Optional[str]) -> str:

def extract_version_string(filename):
with open(filename) as f:
for l in f.readlines():
if l.startswith(VERSION_LINE_START):
return l.replace(VERSION_LINE_START, "").strip()
for line in f.readlines():
if line.startswith(VERSION_LINE_START):
return line.replace(VERSION_LINE_START, "").strip()
return None


Expand Down