Skip to content

fix flake8 linting errors and add lint check in CI#143

Merged
borauyar merged 33 commits into
BIMSBbioinfo:mainfrom
nilchia:lint_py
Apr 19, 2026
Merged

fix flake8 linting errors and add lint check in CI#143
borauyar merged 33 commits into
BIMSBbioinfo:mainfrom
nilchia:lint_py

Conversation

@nilchia
Copy link
Copy Markdown
Collaborator

@nilchia nilchia commented Apr 3, 2026

This PR adds a new GitHub Actions workflow to automatically lint Python scripts using isort and flake8 on pushes and pull requests.

It also fixes current lint errors from flake8.

I ran black for reformating, flake8, and isort file lint checkin.

Each error is fixed in a commit.

The lint error of long lines is fixed with claude.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a GitHub Actions workflow to lint the repository’s Python code with isort and flake8, and applies broad formatting/import cleanups across the codebase to address existing flake8 issues.

Changes:

  • Added a CI workflow that runs isort and flake8 on pushes/PRs affecting *.py files.
  • Reformatted multiple modules (Black-style wrapping) and reorganized imports to reduce lint violations.
  • Updated a few tests and utility scripts to comply with linting rules (e.g., line length, unused imports).

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/unit/test_smoke.py Marks unused import with noqa to satisfy flake8.
tests/test_mps_device.py Formatting changes; introduces a regression in memory allocation test and unused locals.
flexynesis/modules.py Import cleanup and formatting adjustments.
flexynesis/models/triplet_encoder.py Import/format refactor; introduces critical bugs in Captum attribution path.
flexynesis/models/supervised_vae.py Import and formatting cleanups for lint compliance.
flexynesis/models/gnn_early.py Import/format updates; minor naming mismatch in helper.
flexynesis/models/direct_pred.py Import and formatting cleanups for lint compliance.
flexynesis/models/crossmodal_pred.py Import and formatting cleanups for lint compliance.
flexynesis/models/__init__.py Reorders imports and formats __all__.
flexynesis/main.py Large formatting refactor; introduces a hard-to-read/incorrect early-stop condition expression.
flexynesis/inference.py Formatting and minor refactors to imports / long lines.
flexynesis/generate_coexpression_network.py Formatting refactor; exposes an option that isn’t actually implemented.
flexynesis/feature_selection.py Import ordering and formatting updates.
flexynesis/config.py Formatting and consistent quoting in search-space definitions.
flexynesis/__init__.py Formatting and import ordering updates for lazy import wrapper.
.github/workflows/lint.yml New workflow to run isort + flake8 in CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_mps_device.py
Comment thread tests/test_mps_device.py
Comment thread flexynesis/models/triplet_encoder.py Outdated
Comment on lines +586 to +601
),
n_steps=steps_or_samples,
)
attributions = attributions.split(layer_sizes, dim=3)
elif method == "GradientShape":
attributions = explainer.attribute(
input_data,
baseline,
additional_forward_args=(
layer_sizes,
target_var,
steps_or_samples,
),
n_samples=steps_or_samples,
)
attributions = attributions.split(layer_sizes, dim=3)
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

Typo in method dispatch: branch checks elif method == "GradientShape" but the supported method name elsewhere is "GradientShap". With method="GradientShap", neither branch runs in the num_class == 1 case, leaving attributions undefined. Rename the branch to "GradientShap" (and ensure both numerical + categorical paths handle it).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is also not related to the linting fixes of this PR, but it looks valid to me.
Should I change it to "Gradientshap"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, that is a typo/bug, should be fixed.

Comment thread flexynesis/main.py
Comment thread .github/workflows/lint.yml Outdated
Comment on lines 149 to 157
def generate_coexpression_network(
input_file,
output_file,
method='spearman',
method="spearman",
min_correlation=0.3,
top_k=10,
remove_self_loops=True,
remove_duplicates=True
remove_duplicates=True,
):
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

remove_self_loops is exposed in generate_coexpression_network(...) but is never used; self-correlations are always removed in build_network via gene_corr[global_idx] = 0. Either implement the flag (conditionally keep self-loops) or remove the parameter to avoid a non-functional API option.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is also not related to the linting fixes of this PR, but it looks valid to me.
Should I remove the arg?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, sure

Comment thread flexynesis/models/gnn_early.py Outdated
nilchia and others added 4 commits April 3, 2026 20:47
@nilchia
Copy link
Copy Markdown
Collaborator Author

nilchia commented Apr 9, 2026

FileNotFoundError: [Errno 2] No such file or directory: './pancan_pcawg_2020/data_cna.txt'

Looks like this file can not be accessed?

@nilchia
Copy link
Copy Markdown
Collaborator Author

nilchia commented Apr 9, 2026

Hi @borauyar,

Can we replace pancan_pcawg_2020 dataset with something else?

@borauyar
Copy link
Copy Markdown
Member

Hi @borauyar,

Can we replace pancan_pcawg_2020 dataset with something else?

Hey @nilchia, I don't mind replacing it. I had to change it because there was a problem with the previous MSK dataset. When you download it, the files are just empty. That was breaking the tutorial. If you'd like to change it to something else that demonstrates the cbioportal feature (with at least 2 data modalities), I don't mind changing to something else.

@nilchia

This comment was marked as resolved.

@nilchia

This comment was marked as resolved.

Comment thread flexynesis/utils.py

def get_cbioportal_data(self, study_id, files=None):
archive_path = self.download_study_archive()
study_dir = self.extract_archive(archive_path)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This was the culprit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The commit "b3f9556" deleted those two lines because study_dir was assigned but never referenced again.
The linting flag was correct, but removing the entire call to extract_archive() was the wrong fix.
87631a9 should fix it

@nilchia nilchia marked this pull request as ready for review April 13, 2026 13:16
borauyar and others added 2 commits April 19, 2026 12:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread flexynesis/main.py
@borauyar borauyar merged commit 541ba48 into BIMSBbioinfo:main Apr 19, 2026
12 of 14 checks passed
@borauyar
Copy link
Copy Markdown
Member

@nilchia Thank you! Looks like a lot of work :) It took me a while to just go through.

@nilchia nilchia deleted the lint_py branch April 29, 2026 09:17
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.

3 participants