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

feat: upgrade to sodar core v1 (#1973) #2010

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stolpeo
Copy link
Contributor

@stolpeo stolpeo commented Oct 7, 2024

Summary by CodeRabbit

  • New Features

    • Updated PostgreSQL Docker image version to enhance testing environment.
    • Added new targets in the build process for improved clarity in migrations and coverage reporting.
    • Introduced new dependencies for better functionality and compatibility.
    • Added a method in the frontend to construct JSON strings from query settings.
    • Enhanced the handling of genomic regions and gene panels in the frontend component.
    • Added validation rules and computed properties in the frontend for better user input management.
  • Bug Fixes

    • Improved URL routing by replacing deprecated regex patterns with modern path converters for better readability and maintainability.
  • Refactor

    • Standardized base classes for permission testing across various test files to enhance consistency and maintainability.
    • Enhanced variable declarations and function logic in frontend components for better clarity.
    • Streamlined test cases by removing unnecessary mocking and focusing on actual API responses.
  • Style

    • Improved code formatting and variable declarations for better clarity and maintainability in frontend components.
  • Chores

    • Enhanced database migration commands in the Docker entrypoint script for better management of variant summaries during deployment.

@stolpeo stolpeo linked an issue Oct 7, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Oct 7, 2024

deps-report 🔍

Commit scanned: 2fdd358
ℹ️ Python version 3.11 is used by your project but the latest version is 3.13.

Vulnerable dependencies

2 dependencies have vulnerabilities 😱
Dependency Advisory Versions impacted
jinja2 (transitive) In Jinja2, the from_string function is prone to Server Side Template Injection (SSTI) where it takes the source parameter as a template object, renders it, and then returns it. The attacker can exploit it with INJECTION COMMANDS in a URI. NOTE: The maintainer and multiple third parties believe that this vulnerability isn't valid because users shouldn't use untrusted templates without sandboxing. >=0
sqlalchemy Sqlalchemy 2.0.0b1 avoids leaking cleartext passwords to the open for careless uses of str(engine.URL()) in logs and prints. sqlalchemy/sqlalchemy#8563 <2.0.0b1

Outdated dependencies

26 outdated dependencies found (including 12 outdated major versions)😢
Dependency Installed version Latest version
alabaster (transitive) 0.7.16 1.0.0
argon2-cffi (transitive) 21.3.0 23.1.0
django 4.2.16 5.1.2
django-model-utils (transitive) 4.4.0 5.0.0
django-rest-knox (transitive) 4.2.0 5.0.2
packaging (transitive) 23.2 24.1
protobuf 3.20.3 5.28.2
setuptools (transitive) 70.0.0 75.2.0
sphinx (transitive) 7.2.6 8.1.3
sphinx-rtd-theme (transitive) 2.0.0 3.0.1
sqlalchemy 1.4.54 2.0.36
unidecode (transitive) 0.4.21 1.3.8
Dependency Installed version Latest version
botocore (transitive) 1.35.36 1.35.45
celery (transitive) 5.3.6 5.4.0
crispy-bootstrap4 (transitive) 2024.1 2024.10
django-crispy-forms (transitive) 2.1 2.3
django-iconify (transitive) 0.3 0.4
django-postgres-copy 2.3.7 2.7.6
docutils (transitive) 0.20.1 0.21.2
markdown (transitive) 3.5.2 3.7
mypy-protobuf (dev) 3.3.0 3.6.0
pydantic-core (transitive) 2.23.4 2.24.2
requests-http-signature 0.2.0 0.7.1
rules (transitive) 3.3 3.5
wheel (transitive) 0.42.0 0.44.0
xmltodict (transitive) 0.13.0 0.14.2

Logs

@holtgrewe
Copy link
Collaborator

@coderabbitai full review

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

✅ Actions performed

Full review triggered.

Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes in this pull request involve updates across various files, primarily focusing on modifying test classes to use a new base class for permission testing, updating URL routing definitions to utilize the path() function instead of the deprecated url() function, and enhancing GitHub Actions workflow configurations. Additionally, there are updates to the Makefile for improved clarity in migration commands, adjustments to the Pipfile for dependency versions, and modifications to executor logic in the case import process. The Dockerfile has also been updated to use newer base images for Node.js and Python.

Changes

File Change Summary
.github/workflows/main.yml Updated PostgreSQL Docker image from postgres:14 to postgres:16 in Python-Test job; updated Python version from 3.10.13 to 3.11 in Python-Test and Python-Lint jobs; minor indentation adjustments.
backend/Makefile Renamed _migrate to _makemigrations; added makemigrations target; modified migrate target to run migration command directly; corrected indentation in docs target; added coverage target.
backend/Pipfile Updated package versions for beautifulsoup4, django-plugins-bihealth, django-sodar-core, drf-keyed-list-bihealth, django-auth-ldap; added djangorestframework and typing-extensions; changed Python version from 3.10 to 3.11.
backend/beaconsite/tests/test_permissions.py Changed base class for TestIndexView, TestConsortiumViews, TestSiteViews from TestProjectPermissionBase to ProjectPermissionTestBase.
backend/beaconsite/tests/test_permissions_ajax.py Changed base class for TestOrganisationAjaxViews, TestBeaconQueryAjaxView from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase.
backend/beaconsite/tests/test_permissions_api.py Changed base class for TestBeaconInfoApiView, TestBeaconQueryApiView from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase.
backend/beaconsite/urls.py Replaced url() function with path() function for all URL patterns, simplifying regex patterns to use path converters.
backend/cases/tests/test_permissions.py Changed base class for TestCasesViews from TestProjectPermissionBase to ProjectPermissionTestBase.
backend/cases/tests/test_permissions_ajax.py Changed base class for multiple test classes from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase.
backend/cases/tests/test_permissions_api.py Changed base class for multiple test classes from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase.
backend/cases/urls.py Replaced url() function with path() function for all URL patterns, simplifying regex patterns to use path converters.
backend/cohorts/tests/test_permissions_ajax.py Changed base class for multiple test classes from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase.
backend/cohorts/tests/test_permissions_api.py Changed base class for multiple test classes from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase.
utils/docker/Dockerfile Updated Node.js base image to node:20-slim and Python base image to python:3.11-bookworm; updated PostgreSQL client version from postgresql-client-12 to postgresql-client-14.
backend/cases_import/models/executors.py Changed keyword argument in _build_fs_options method from "app_name" to "plugin_name"; added _run_create_or_update method.
frontend/src/variants/components/FilterForm/FrequencyPane.vue Added dumpFrequencies method; exposed v$ for validation state.
frontend/src/variants/components/FilterForm/GenesRegionsPane.vue Enhanced conditional rendering for genomic region and gene allow list sections; minor template modifications.
frontend/src/variants/components/FilterForm/QualityPane.vue Simplified rendering logic for <table> element based on props.querySettings.
frontend/src/variants/components/QueryPresets/SetEditor.vue Changed variable declarations from var to const for better immutability; adjusted lifecycle hooks.
frontend/src/variants/components/QueryPresets/SetProperties.vue Reordered class and type attributes in checkbox input for defaultPresetSetModel.
backend/cohorts/migrations/0008_alter_cohort_user.py Modified user field in cohort model to allow blank and null values.

Poem

In the garden of code, we hop and play,
With updates and changes brightening the day.
From PostgreSQL to Vue, we dance with delight,
Each line a new story, each function takes flight.
So let’s celebrate progress, both big and small,
For every little change makes our project stand tall! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@holtgrewe
Copy link
Collaborator

@stolpeo just taking the CodeRabbit AI for a test drive here just for fun ;-)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 13

🧹 Outside diff range and nitpick comments (49)
backend/varfish/vueapp/urls.py (1)

7-11: LGTM: Updated URL pattern to use path() with improved readability

The change from url() to path() is correct and improves readability. The use of the str path converter simplifies the pattern while maintaining the same functionality.

For consistency with Django's style guide, consider moving the view parameter to a new line:

path(
    "ajax/user-setting/<str:setting_name>/",
    views_ajax.UserSettingView.as_view(),
    name="user-setting",
),
backend/cohorts/tests/test_views_ui.py (1)

4-4: Clarify the purpose of the TODO comment

The TODO comment lacks context and details. Could you please provide more information about what needs to be done here? This will help in understanding the intended changes or improvements for this file.

backend/variants/urls/annos.py (1)

10-14: LGTM: Updated URL pattern to use path() with UUID converter

The change from url() to path() with the <uuid:case> converter is an excellent improvement. It enhances readability and type safety while maintaining the same functionality.

Consider adding a trailing slash to the URL pattern for consistency with Django's URL naming conventions:

-        "ajax/smallvariant/user-annotated-case/<uuid:case>/",
+        "ajax/smallvariant/user-annotated-case/<uuid:case>/",

This ensures that Django will automatically redirect requests without a trailing slash to the URL with a trailing slash, which is the default behavior in Django.

backend/cases/tests/test_views.py (1)

Line range hint 1-14: Summary: Base class update for permission testing

The changes in this file are part of a larger refactoring effort to improve the structure of permission tests. The TestCasesViews class now inherits from ProjectPermissionTestBase instead of TestProjectPermissionBase. This change appears to be consistent across the codebase.

Key points:

  1. The import statement has been updated accordingly.
  2. The test method test_entrypoint remains unchanged, suggesting that the expected behavior is maintained.
  3. This change might affect other test classes that were using the old base class.

Consider updating the documentation to reflect this change in the permission testing structure, especially if it impacts how developers should write new tests or modify existing ones.

backend/maintenance/management/commands/drop_variant_summary.py (2)

9-13: LGTM: Well-defined command class with clear documentation.

The Command class is correctly defined and documented. The use of a class-level help attribute is the proper way to provide a description for Django management commands.

Consider expanding the class docstring to include more details about when and why this command should be used, as well as any potential impacts of dropping the variant summary.


15-19: Solid implementation with room for improvement in error handling and user confirmation.

The handle method is well-implemented with the use of @transaction.atomic for database consistency and proper use of Django's command output methods. However, there are a few areas for improvement:

  1. Add error handling to catch and report any exceptions that might occur during the operation.
  2. Implement a user confirmation step before proceeding with the deletion.
  3. Consider adding a dry-run option for safety.

Here's a suggested implementation:

@transaction.atomic
def handle(self, *args, **options):
    """Perform dropping the statistics."""
    if options.get('dry_run'):
        self.stdout.write("Dry run: Would drop variant summary.")
        return

    if input("Are you sure you want to drop the variant summary? This action cannot be undone. (y/N): ").lower() != 'y':
        self.stdout.write("Operation cancelled.")
        return

    try:
        models.drop_variants_smallvariantsummary()
        self.stdout.write(self.style.SUCCESS("Successfully dropped variant summary."))
    except Exception as e:
        self.stderr.write(self.style.ERROR(f"Error dropping variant summary: {str(e)}"))

def add_arguments(self, parser):
    parser.add_argument(
        '--dry-run',
        action='store_true',
        help='Simulate the drop operation without actually performing it.',
    )

This implementation adds user confirmation, error handling, and a dry-run option for safer execution.

backend/maintenance/management/commands/create_variant_summary.py (1)

15-19: Consider adding error handling and progress reporting.

The handle method is well-implemented with the @transaction.atomic decorator ensuring database consistency. The core logic delegation and success message are good practices.

However, consider the following improvements:

  1. Add error handling to catch and report any exceptions that might occur during the summary creation.
  2. Implement progress reporting for potentially long-running operations.

Here's a suggested implementation with error handling and progress reporting:

@transaction.atomic
def handle(self, *args, **options):
    """Perform creating the statistics."""
    try:
        self.stdout.write("Starting variant summary creation...")
        models.create_variants_smallvariantsummary(
            progress_callback=lambda x: self.stdout.write(f"Progress: {x}%")
        )
        self.stdout.write(self.style.SUCCESS("Done creating variant summary."))
    except Exception as e:
        self.stdout.write(self.style.ERROR(f"Error creating variant summary: {str(e)}"))
        raise

This implementation assumes that create_variants_smallvariantsummary can accept a progress_callback. If it doesn't, you may need to modify that function to support progress reporting.

backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1)

1-25: LGTM! Consider adding a comment for the dynamic related_name.

The migration looks good and follows Django best practices. The bg_job field is properly defined with appropriate attributes. The CASCADE deletion behavior and the help text are well-chosen.

Consider adding a comment explaining the use of the dynamic related_name. While it's a good practice to avoid naming conflicts, a brief explanation can help future developers understand the reasoning. You could add something like:

# Using dynamic related_name to avoid potential naming conflicts across apps
related_name="%(app_label)s_%(class)s_related",

This small addition would enhance the code's self-documentation.

backend/svs/tests/test_permissions_ajax_presets.py (1)

4-9: Overall impact: Minimal. Ensure comprehensive testing.

The changes in this file are part of a larger refactoring effort to standardize naming conventions. While the impact on this specific file is minimal and shouldn't affect the functionality of the tests, it's crucial to ensure that these changes are consistent across the entire project.

To maintain the integrity of the test suite:

  1. Run the entire test suite to ensure no regressions have been introduced.
  2. Pay special attention to any tests that inherit from ProjectAPIPermissionTestBase to verify they behave as expected.
  3. Update any documentation or developer guides that may reference the old class name.
backend/seqmeta/tests/test_permissions.py (1)

Line range hint 1-43: Summary: Permission testing framework update

The changes in this file are part of a larger update to the permission testing framework. The base class for permission testing has been changed from TestProjectPermissionBase to ProjectPermissionTestBase. While the changes in this file are consistent and focused, it's important to ensure that this update has been applied consistently across the entire project.

Consider the following steps to ensure a smooth transition:

  1. Review other test files in the project that may be using the old TestProjectPermissionBase and update them accordingly.
  2. Run the entire test suite to verify that the new base class doesn't introduce any breaking changes or require additional setup in other modules.
  3. Update any documentation or developer guidelines related to permission testing to reflect the new base class usage.

These steps will help maintain consistency and prevent potential issues in other parts of the project.

backend/varannos/tests/test_permissions.py (1)

Line range hint 1-40: Summary of changes and potential impacts.

The changes in this file are part of a larger refactoring effort to update the permission testing framework. The main changes include:

  1. Updating the import statement to use ProjectPermissionTestBase.
  2. Changing the base class of TestVarAnnoSetViews from TestProjectPermissionBase to ProjectPermissionTestBase.

While these changes appear appropriate, it's crucial to ensure that:

  1. The new base class ProjectPermissionTestBase provides all the necessary functionality, especially the assert_response method used in the test methods.
  2. The setUp method is compatible with the new base class.
  3. The overall test logic still aligns with the project's permission testing requirements.

To maintain the integrity of the permission testing framework:

  1. Document the reasons for this base class change and any differences in functionality between the old and new base classes.
  2. Update any project-wide testing guidelines or documentation to reflect this change in the permission testing approach.
  3. Consider running the entire test suite to ensure that this change doesn't have any unexpected side effects on other test classes that might be using the same base class.
backend/seqmeta/tests/test_views.py (1)

Line range hint 1-48: Summary of changes and potential impact

The modifications in this file consistently update the base class for all test classes from TestViewsBase to ViewTestBase. This refactoring appears to be part of a larger effort to standardize view testing across the project. While the changes are straightforward and consistent, it's crucial to ensure that:

  1. The new ViewTestBase class provides all the necessary functionality previously available in TestViewsBase.
  2. Test coverage is maintained across all affected test cases.
  3. This refactoring is applied consistently across the entire project.

These changes have the potential to improve code maintainability and standardization of testing practices. However, thorough verification of test functionality and coverage is recommended to prevent any regressions.

Consider documenting this change in the project's testing guidelines or developer documentation to ensure all team members are aware of the new standardized approach to view testing.

backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1)

37-46: LGTM! Consistent field definition with potential for future optimization.

The changes to the bg_job field in the importstructuralvariantbgjob model maintain the consistency observed in the previous two models. This is good for current maintenance and understanding.

Suggestion for future improvement:
Consider refactoring these models to use a common base class or mixin for the bg_job field definition. This could reduce code duplication and make future changes easier to manage.

backend/beaconsite/urls.py (1)

11-62: LGTM: Improved URL patterns with path()

The changes to ui_urlpatterns are well-implemented:

  • Replaced url() with path() for all patterns.
  • Simplified regex patterns to use path converters.
  • Consistently used <uuid:parameter_name> for UUID patterns.

These changes improve readability and maintainability.

For consistency, consider adding a trailing slash to the root path:

-    path(
-        route="",
+    path(
+        route="/",
         view=views.IndexView.as_view(),
         name="index",
     ),

This would align with the trailing slash convention used in other routes.

frontend/src/varfish/components/FilterForm/DevPane.vue (1)

87-87: Unnecessary change in input element id.

The id attribute of the input element has been modified, but the value remains "customSwitch1". This change appears to be unnecessary and might be an unintended modification or a result of code formatting.

-            id="customSwitch1"
+            id="customSwitch1"

Consider reverting this change to maintain code consistency and avoid confusion.

frontend/src/variants/components/FilterForm/FlagsPane.vue (2)

18-18: Approve change with minor optimization suggestion.

The addition of an explicit check for querySettings being neither null nor undefined is a good defensive programming practice. It ensures that the component only renders when querySettings is properly initialized, potentially preventing runtime errors.

However, we can slightly optimize this check:

Consider simplifying the condition to use the nullish coalescing operator:

-    v-if="querySettings !== null && querySettings !== undefined"
+    v-if="querySettings != null"

This change maintains the same logic but is more concise. In JavaScript, != null checks for both null and undefined.


Line range hint 1-114: General component structure review and suggestions.

The FlagsPane component is well-structured and follows Vue.js best practices. Here are some observations and suggestions for potential improvements:

  1. The component uses the Composition API with <script setup>, which is good for maintainability and readability.

  2. Props are properly defined and used throughout the component.

  3. The template structure is clear and uses appropriate Vue directives.

  4. Consider extracting the flag rendering logic into a separate component to improve reusability and reduce the complexity of this component.

  5. The inline styles and classes could be moved to the <style> section for better separation of concerns.

  6. Consider using TypeScript for better type checking and developer experience, especially for complex props like querySettings.

  7. The component imports a global CSS file. Consider using scoped CSS or CSS modules for better encapsulation.

These suggestions aim to enhance the component's maintainability and align it with modern Vue.js best practices. Would you like assistance in implementing any of these improvements?

frontend/src/variants/components/FilterForm/QualityPane.vue (2)

74-74: Improved conditional rendering

The simplification of the v-if condition is a good change. It improves code readability while maintaining the same functionality for the expected prop types. This change aligns with Vue.js best practices for conditional rendering.

Consider using the optional chaining operator for even more concise and safe property access:

<table v-if="props.querySettings?.quality" class="table table-striped table-hover sodar-card-table compact-form-groups">

This approach would prevent potential errors if querySettings is defined but quality is not, providing an additional layer of safety.


Line range hint 1-115: Suggestions for code organization and prop handling

The overall structure and implementation of the component look good. However, consider the following suggestions for further improvement:

  1. Move the keyMap object to a separate constants file if it's used in other components. This would improve maintainability and reusability.

  2. Consider using a computed property to derive membersWithGtEntries from props.caseObj.pedigree. This would make the filtering logic more reactive and easier to test.

  3. For consistency, consider using a computed property to access props.querySettings.quality instead of accessing it directly in the template. This would centralize the prop access and make it easier to add checks or transformations if needed in the future.

Here's an example of how you could implement these suggestions:

// In a separate constants file
export const QUALITY_KEY_MAP = {
  qualMinDpHet: 'dp_het',
  qualMinDpHom: 'dp_hom',
  qualMinAb: 'ab',
  qualMinGq: 'gq',
  qualMinAd: 'ad',
  qualMaxAd: 'ad_max',
  qualFail: 'fail',
}

// In your component
import { QUALITY_KEY_MAP } from '@/constants/qualitySettings'

// ...

const membersWithGtEntries = computed(() => 
  props.caseObj.pedigree.filter((member) => member.has_gt_entries)
)

const qualitySettings = computed(() => props.querySettings?.quality || {})

// Then in your template, use `qualitySettings.value[member.name]` instead of `querySettings.quality[member.name]`

These changes would make your component more maintainable and slightly more performant.

backend/beaconsite/tests/test_permissions_ajax.py (1)

Line range hint 1-108: Summary: Consistent base class update with minimal impact.

The changes in this file are limited to updating the base class for both test classes from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent across the file and aligns with the PR objectives to upgrade to sodar core v1.

The lack of other changes in the file suggests that the new base class is compatible with the existing test methods, which is a positive sign. However, it's important to ensure that this change is applied consistently across the entire codebase and that it doesn't negatively impact test coverage or functionality.

Consider adding a comment at the top of the file explaining the reason for using ProjectAPIPermissionTestBase and its benefits over the previous base class. This would help future developers understand the context of these changes.

backend/genepanels/tests/test_permissions.py (1)

Line range hint 1-96: Summary: Base class update requires careful verification.

The changes in this file are part of a larger refactoring effort, updating the base class for permission testing from TestProjectPermissionBase to ProjectPermissionTestBase. While the changes are consistent and the test methods remain unchanged, it's crucial to verify that:

  1. The new base class provides all necessary methods and attributes.
  2. The behavior of inherited methods, especially assert_response, remains consistent.
  3. The test coverage and effectiveness have not been inadvertently reduced.

Consider the following steps to ensure the refactoring hasn't introduced any regressions:

  1. Run the entire test suite for the genepanels module and verify that all tests pass.
  2. Compare the code coverage before and after this change to ensure no decrease in coverage.
  3. Review the changes made to the ProjectPermissionTestBase class in the projectroles module to understand any new features or behavior changes that could be leveraged in these tests.

If you need assistance in generating scripts for these verifications or in updating the tests to take advantage of any new features in the base class, please let me know.

backend/cases_analysis/tests/test_permissions_api.py (1)

Line range hint 1-107: Summary: File updated successfully as part of sodar core v1 upgrade.

The changes in this file are consistent with the PR objective of upgrading to sodar core v1. The main updates include:

  1. Importing ProjectAPIPermissionTestBase instead of TestProjectAPIPermissionBase.
  2. Updating both test classes to inherit from the new base class.

These changes appear to be part of a larger refactoring effort. The existing test structure and methods remain unchanged, which suggests that the new base class is compatible with the current testing approach. This minimizes the risk of introducing new bugs.

A minor typo was found in one of the class names, which has been addressed in a previous comment.

To ensure a smooth transition:

  1. Verify that all methods used from the base class are still available in ProjectAPIPermissionTestBase.
  2. Run the test suite to confirm that all tests still pass with the new base class.
  3. Update the class name typo as suggested earlier.

Consider reviewing other test files in the project to ensure consistent use of the new ProjectAPIPermissionTestBase class across all relevant test cases.

backend/Makefile (1)

120-121: Approved with suggestion: Simplified migrate target

The simplified migrate target directly runs the Django migrate command, which is clear and straightforward. This change reduces complexity in the migration process.

However, consider adding a dependency on the makemigrations target to ensure migrations are always generated before being applied:

.PHONY: migrate
migrate: makemigrations
	pipenv run $(MANAGE) migrate

This would prevent scenarios where migrations are applied without first being generated, maintaining a consistent workflow.

backend/cases/urls.py (2)

15-79: LGTM: Consistent modernization of AJAX URL patterns

The update from url() to path() for all AJAX URL patterns is consistent and aligns with Django's best practices. The use of UUID converters (<uuid:...>) for various parameters ensures type safety and consistency across all patterns.

Consider refactoring these URL patterns to reduce repetition. You might be able to use Django's include() function or create a custom URL pattern generator to minimize duplication, especially for patterns that follow a similar structure (e.g., list, create, retrieve, update, destroy operations).

Example of a potential refactoring:

def create_crud_patterns(prefix, view_class, name_prefix):
    return [
        path(f"{prefix}/list/<uuid:project>/", view_class.as_view(), name=f"{name_prefix}-list"),
        path(f"{prefix}/retrieve-update-destroy/<uuid:id>/", view_class.as_view(), name=f"{name_prefix}-retrieveupdatedestroy"),
        # Add other common patterns here
    ]

# Usage
ajax_urlpatterns = [
    *create_crud_patterns("ajax/case", views_ajax.CaseAjaxView, "ajax-case"),
    *create_crud_patterns("ajax/case-comment", views_ajax.CaseCommentAjaxView, "ajax-casecomment"),
    # Add other pattern groups here
]

This approach could make the URL configuration more maintainable and less prone to errors when adding new patterns or modifying existing ones.


Inconsistent Use of AJAX Views in API URL Patterns

The verification confirms that while all necessary API views are properly defined in backend/cases/views_api.py, the api_urlpatterns in backend/cases/urls.py continue to reference AJAX views from views_ajax. This inconsistency should be corrected to ensure that API URL patterns utilize the appropriate API views.

Areas Needing Attention:

  • backend/cases/urls.py: Update api_urlpatterns to use views_api.*ApiView instead of views_ajax.*AjaxView.
🔗 Analysis chain

Line range hint 1-155: Overall assessment: Good modernization with room for improvement

The changes in this file represent a positive step towards modernizing the URL configuration by consistently using path() instead of url() and implementing UUID converters for type safety. These updates align well with Django's current best practices.

However, there are a few areas that could benefit from further attention:

  1. The repetitive nature of the URL patterns suggests an opportunity for refactoring to improve maintainability and reduce the likelihood of errors when adding or modifying patterns.

  2. There are inconsistencies in the API section where some patterns still reference AJAX views instead of API views. This should be addressed to ensure proper separation of concerns and consistent behavior.

  3. Consider implementing a more DRY (Don't Repeat Yourself) approach to defining URL patterns, possibly by using Django's include() function or creating custom URL pattern generators.

Addressing these points will further enhance the quality and maintainability of the URL configuration.

To ensure that all necessary API views exist and are properly referenced, you can run the following script:

This script will help identify any missing API views and any remaining references to AJAX views in the API URL patterns.


Action Required: Re-run Verification with Updated Script

To address the issues encountered in the previous verification attempt, please execute the following updated script:

This script adjusts the file type specification by searching for .py files directly and removes the additional rg "api_urlpatterns" pipe to prevent further errors. Running this should provide the necessary information to verify the API views and AJAX references accurately.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of API views and their correct usage in URL patterns

# Check for the existence of API views
echo "Checking for the existence of API views:"
rg -t python "class \w+ApiView\(" backend/cases/views_api.py

# Check for any remaining references to AJAX views in api_urlpatterns
echo "\nChecking for references to AJAX views in api_urlpatterns:"
rg -t python "views_ajax\.\w+AjaxView" backend/cases/urls.py | rg "api_urlpatterns"

Length of output: 428


Script:

# 
#!/bin/bash
# Description: Verify the existence of API views and their correct usage in URL patterns

# Check for the existence of API views
echo "Checking for the existence of API views:"
rg "class \w+ApiView\(" backend/cases/views_api.py

# Check for any remaining references to AJAX views in api_urlpatterns
echo -e "\nChecking for references to AJAX views in api_urlpatterns:"
rg "views_ajax\.\w+AjaxView" backend/cases/urls.py

Length of output: 2473

backend/cases_import/tests/test_permissions_api.py (1)

16-16: LGTM: Base class updated to ProjectAPIPermissionTestBase.

The base class has been successfully updated to ProjectAPIPermissionTestBase, which is consistent with the import statement change. This modification improves naming consistency and likely reflects a broader refactoring of test classes.

Consider updating the class docstring to reflect any changes in functionality or purpose that might have come with the new base class, if applicable.

backend/beaconsite/tests/test_permissions_api.py (1)

Line range hint 1-186: Consider refactoring to reduce code duplication.

The changes to both TestBeaconInfoApiView and TestBeaconQueryApiView look good and are consistent. However, there's an opportunity to improve the overall structure of these tests:

  1. Both classes share similar test methods (test_success, test_fail_key, test_fail_clock_skew) with nearly identical implementations.
  2. The AcceptHeaderMixin is used by both classes and contains shared functionality.

Consider creating a common base class that inherits from both AcceptHeaderMixin and ProjectAPIPermissionTestBase. This new base class could include the shared test methods, reducing code duplication and improving maintainability.

Example structure:

class BaseBeaconApiTest(AcceptHeaderMixin, ProjectAPIPermissionTestBase):
    def setUp(self):
        super().setUp()
        self.consortium = ConsortiumWithLocalAndRemoteSiteFactory()
        self.remote_site = Site.objects.get(role=Site.REMOTE)
        ConsortiumAssignmentFactory(
            consortium=self.consortium,
            project=self.project,
        )

    def test_success(self):
        # Implement shared success test logic

    def test_fail_key(self):
        # Implement shared key failure test logic

    def test_fail_clock_skew(self):
        # Implement shared clock skew test logic

class TestBeaconInfoApiView(BaseBeaconApiTest):
    def setUp(self):
        super().setUp()
        self.url = reverse("beaconsite:beacon-api-info")

class TestBeaconQueryApiView(BaseBeaconApiTest):
    def setUp(self):
        super().setUp()
        self.small_variant = SmallVariantFactory(case__project=self.project)
        self.beacon_allele_request = BeaconAlleleRequest(...)
        self.url = reverse("beaconsite:beacon-api-query") + "?" + self.get_query_params()

    def get_query_params(self):
        return "&".join(
            "%s=%s" % (k, v) for k, v in cattr.unstructure(self.beacon_allele_request).items()
        )

This refactoring would make the tests more maintainable and easier to extend in the future.

backend/variants/tests/test_ui.py (1)

Line range hint 35-143: LGTM: Excellent addition of custom wait conditions.

The new classes (wait_for_the_attribute_value, wait_for_the_attribute_endswith_value, wait_for_element_endswith_value, element_has_class_locator, and element_has_class) are well-implemented and documented. They will significantly enhance the robustness of the UI tests by providing more precise control over element waiting conditions.

Consider adding a base class for these wait conditions to reduce code duplication, especially for the __init__ methods and error handling. For example:

class BaseWaitCondition:
    def __init__(self, locator_or_element, attribute, value):
        self.locator_or_element = locator_or_element
        self.attribute = attribute
        self.value = value

    def _get_element(self, driver):
        if isinstance(self.locator_or_element, tuple):
            return ec._find_element(driver, self.locator_or_element)
        return self.locator_or_element

    def __call__(self, driver):
        try:
            element = self._get_element(driver)
            return self._check_condition(element)
        except StaleElementReferenceException:
            return False

    def _check_condition(self, element):
        raise NotImplementedError

Then, each specific wait condition class could inherit from this base class and implement only the _check_condition method.

🧰 Tools
🪛 Ruff

167-167: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)

backend/variants/tests/test_permissions_ajax.py (1)

183-183: LGTM! Base class updated consistently. Consider addressing TODOs.

The base class has been correctly updated to ProjectAPIPermissionTestBase for this test class as well. The change is consistent with the previous updates and maintains the existing test structure.

Additionally, there are some TODO comments and commented-out code related to authentication status codes throughout the file. Consider addressing these in a future update to improve the test coverage and remove any obsolete code.

frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (5)

Line range hint 14-22: LGTM! Consider using environment variables for API endpoints.

The addition of lookupGeneApiEndpoint and lookupGenePanelApiEndpoint properties improves the component's flexibility. This change allows for easier customization of API endpoints, which is a good practice.

For consistency and easier configuration management, consider using environment variables for these API endpoints. This approach would allow for different values in development and production environments without changing the code. For example:

lookupGeneApiEndpoint: {
  type: String,
  default: process.env.VUE_APP_LOOKUP_GENE_API_ENDPOINT || '/proxy/varfish/annonars/genes/lookup',
},
lookupGenePanelApiEndpoint: {
  type: String,
  default: process.env.VUE_APP_LOOKUP_GENE_PANEL_API_ENDPOINT || '/genepanels/api/lookup-genepanel/',
},

Line range hint 95-134: Improved flexibility, but consider enhancing error handling and readability.

The changes to validateGeneBatch method significantly improve its flexibility by supporting both gene and gene panel validations. The use of async/await and Promise.all for concurrent requests is a good practice that enhances performance.

Consider the following improvements:

  1. Enhance error handling:

    try {
      const response = await fetch(url, {
        // ... existing options
      });
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }
      return await response.json();
    } catch (error) {
      console.error('Validation error:', error);
      return { [token]: { valid: false, error: error.message } };
    }
  2. Refactor for readability:

    • Extract the gene panel validation logic into a separate method.
    • Use object destructuring for cleaner code, e.g., const { identifier, state } = item;.
  3. Consider adding a timeout to the fetch requests to prevent long-running requests from blocking the UI:

    const controller = new AbortController();
    const timeoutId = setTimeout(() => controller.abort(), 5000); // 5 second timeout
    const response = await fetch(url, {
      // ... existing options
      signal: controller.signal,
    });
    clearTimeout(timeoutId);

These changes will improve the robustness and maintainability of the validation logic.


Line range hint 191-200: Good use of async/await, but consider improving error handling and endpoint management.

The loadGenePanelCategories method has been improved with the use of async/await, which enhances readability. The loading state is correctly managed using the loadingGenePanelCategories ref.

Consider the following improvements:

  1. Add error handling:

    const loadGenePanelCategories = async () => {
      loadingGenePanelCategories.value = true;
      try {
        const response = await fetch('/genepanels/api/genepanel-category/list/');
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }
        genePanelCategories.value = await response.json();
      } catch (error) {
        console.error('Failed to load gene panel categories:', error);
        // Optionally, set an error state or show a user-friendly error message
      } finally {
        loadingGenePanelCategories.value = false;
      }
    };
  2. Move the API endpoint to a prop or constant:

    const GENE_PANEL_CATEGORIES_ENDPOINT = '/genepanels/api/genepanel-category/list/';
    // Or as a prop
    const props = defineProps({
      // ... other props
      genePanelCategoriesEndpoint: {
        type: String,
        default: '/genepanels/api/genepanel-category/list/',
      },
    });

These changes will improve the robustness and maintainability of the loadGenePanelCategories method.


Line range hint 310-323: Good addition of confidence selection, consider improving accessibility.

The addition of the Genomics England confidence select element enhances user control over gene panel selection. The change from @change to @select in the Multiselect component is correct and aligns with the component's API.

To improve accessibility, consider adding aria-label attributes to the select elements:

<Multiselect
  id="genomicsEnglandPanelApp"
  :options="genomicsEnglandPanels"
  placeholder="Add from GE PanelApp"
  :searchable="true"
  style="width: 400px"
  @select="insertGenomicsEnglandPanel"
  aria-label="Select Genomics England Panel"
/>
<select
  id="genomicsEnglandConfidence"
  v-model="genomicsEnglandConfidence"
  class="form-control ml-2 mr-2"
  aria-label="Select Genomics England Confidence Level"
>
  <!-- ... options ... -->
</select>

This will improve the experience for users relying on screen readers or other assistive technologies.


Line range hint 328-367: Excellent addition of loading state and conditional rendering.

The implementation of a loading state for local panels and the conditional rendering of the dropdown menu significantly improve the user experience. This approach prevents the display of an empty menu and provides clear feedback during data fetching.

To further enhance the user experience, consider adding a message when there are no gene panel categories available:

<div v-else-if="!loadingGenePanelCategories && genePanelCategories.length === 0" class="alert alert-info mt-2">
  No local gene panel categories available.
</div>

This will provide clear feedback to the user when there are no categories to display, improving the overall usability of the component.

frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (1)

285-285: Approve with suggestion: Consider initializing querySettings with default values

The addition of the v-if directive is a good safeguard against potential errors when querySettings is null or undefined. However, to ensure consistent behavior, consider initializing querySettings with default values in the component's setup or in the parent component.

const props = withDefaults(defineProps<{
  querySettings: {
    genomic_region: string[],
    gene_allowlist: string[]
  }
}>(), {
  querySettings: () => ({
    genomic_region: [],
    gene_allowlist: []
  })
})

This approach would maintain the visibility of the genomic region section while still preventing errors.

frontend/src/variants/components/FilterForm/EffectPane.vue (2)

143-143: Approve changes with a minor suggestion for consistency

The addition of null checks for props.querySettings in the v-if directive improves the component's robustness. This change prevents potential runtime errors when props.querySettings is null or undefined.

For consistency with the script section, consider using the nullish coalescing operator (??) instead of the logical OR (||) for the null check:

-v-if="props.querySettings !== null && props.querySettings !== undefined"
+v-if="props.querySettings != null"

This change maintains the same functionality while making the code more concise and consistent with modern JavaScript practices.


143-143: Approve changes with suggestion for improved error handling

The addition of the v-if directive to the root <div> element is a good practice to prevent rendering when props.querySettings is null or undefined. This change helps avoid potential runtime errors and unexpected behavior.

However, to improve debugging and error handling, consider adding a fallback or error message when props.querySettings is not available. This can help identify issues more quickly during development or in production. For example:

<template>
  <div v-if="props.querySettings != null" style="position: relative" class="mr-2 mt-2">
    <!-- Existing content -->
  </div>
  <div v-else class="alert alert-warning">
    Error: querySettings is not available. Please check the parent component.
  </div>
</template>

This addition will make it easier to identify and debug issues related to missing or invalid querySettings.

frontend/src/variants/components/FilterForm/FrequencyPane.vue (2)

Line range hint 13-28: New method dumpFrequencies() added for developer information

The dumpFrequencies() method has been added to serialize specific frequency-related properties from props.querySettings. This is useful for debugging and development purposes.

Consider the following suggestions:

  1. Add a comment explaining the purpose of this method and when it should be used.
  2. Consider using a more efficient approach for filtering object properties, such as Object.fromEntries() combined with Object.entries().

Here's an example of how you could refactor the method for better performance and readability:

const dumpFrequencies = () => {
  const frequencyPrefixes = ['thousand_genomes_', 'exac_', 'gnomad_exomes_', 'gnomad_genomes_', 'inhouse_', 'mtdb_', 'helixmtdb_', 'mitomap'];
  return JSON.stringify(Object.fromEntries(
    Object.entries(props.querySettings).filter(([key]) => 
      frequencyPrefixes.some(prefix => key.startsWith(prefix))
    )
  ));
}

This refactored version reduces the number of iterations and improves readability by using a predefined list of prefixes.


Line range hint 425-433: New developer information section added

A new <div> has been added to display developer information, showing the result of dumpFrequencies() when filtrationComplexityMode is set to 'dev'.

This addition is helpful for debugging and development purposes. It provides a quick way to view the current state of frequency-related settings.

Consider adding a brief explanation or tooltip for the displayed information to help developers understand its purpose and content.

backend/cases/tests/test_permissions_ajax.py (1)

Line range hint 1-543: Consider enhancing test coverage and reducing duplication

While the current tests cover the basic CRUD operations and permissions, there are a few areas where the test suite could be improved:

  1. Consider using parameterized tests to reduce code duplication across similar test classes. This can make the test suite more maintainable and easier to extend.

  2. Add tests for edge cases and error conditions. For example, test behavior with invalid input data or when a resource doesn't exist.

  3. Add docstrings to test methods to clearly describe what each test is verifying. This will improve the maintainability and readability of the test suite.

Example of a parameterized test:

import pytest

@pytest.mark.parametrize("view_name,model_factory,url_kwargs", [
    ("cases:ajax-case-list", CaseFactory, {"project": "project.sodar_uuid"}),
    ("cases:ajax-casephenotypeterms-listcreate", CasePhenotypeTermsFactory, {"case": "case.sodar_uuid"}),
    # Add more view configurations here
])
def test_list_view_permissions(self, view_name, model_factory, url_kwargs):
    obj = model_factory(project=self.project)
    url = reverse(view_name, kwargs={k: getattr(obj, v) for k, v in url_kwargs.items()})
    
    good_users = [
        self.superuser,
        self.user_owner,
        self.user_delegate,
        self.user_contributor,
        self.user_guest,
    ]
    bad_users_403 = [self.anonymous, self.user_no_roles]
    
    self.assert_response(url, good_users, 200, method="GET")
    self.assert_response(url, bad_users_403, 403, method="GET")

This approach can significantly reduce the amount of repeated code in your test suite.

frontend/src/variants/components/QueryPresets/SetEditor.vue (2)

Line range hint 411-438: Improved implementation of setUpQuickPresetSortable function

The changes in this function enhance the logic for updating quick preset positions. The use of const for variables and the async/await syntax for updating presets are good practices.

Consider extracting the preset update logic into a separate function for better readability:

 set: async (sortable) => {
   const uuids = sortable.toArray()
   const uuidsToPresets = {}
   for (const presets of presetSet.value[
     `${selectedCategory.value}_set`
   ]) {
     uuidsToPresets[presets.sodar_uuid] = presets
   }
-  uuids.forEach(async (presetsUuid, i) => {
-    if (presetsUuid in uuidsToPresets) {
-      uuidsToPresets[presetsUuid].position = i
-      await queryPresetsStore.updatePresets(
-        'quickpresets',
-        props.presetSetUuid,
-        presetsUuid,
-        uuidsToPresets[presetsUuid],
-      )
-    }
-  })
+  await Promise.all(uuids.map(async (presetsUuid, i) => {
+    if (presetsUuid in uuidsToPresets) {
+      uuidsToPresets[presetsUuid].position = i
+      return queryPresetsStore.updatePresets(
+        'quickpresets',
+        props.presetSetUuid,
+        presetsUuid,
+        uuidsToPresets[presetsUuid],
+      )
+    }
+  }))
 },

This change uses Promise.all to update all presets concurrently, which could improve performance.


Line range hint 451-459: Improved watch function for presetSetUuid

The changes in this watch function enhance the handling of presetSetUuid prop changes. The reset of the selected category and conditional setup of the sortable are good practices.

Consider adding a check to prevent unnecessary calls to setUpQuickPresetSortable:

 watch(
   () => props.presetSetUuid,
   async (newValue) => {
     await handleCategoryClicked('presetset')
-    if (sortable.value === null) {
+    if (sortable.value === null && getPresetSetEntries('quickpresets').length > 0) {
       setUpQuickPresetSortable()
     }
   },
 )

This change ensures that setUpQuickPresetSortable is only called when there are quick presets to sort, consistent with the logic in the onMounted hook.

backend/genepanels/tests/test_views.py (4)

Line range hint 91-119: Consider adding a test for invalid data submission.

The current tests cover the happy path for category creation, but it would be beneficial to also test how the view handles invalid data submission. This ensures that the view properly validates input and returns appropriate error responses.

Here's a suggested test method to add:

def test_create_invalid_data(self):
    self.assertEqual(GenePanelCategory.objects.count(), 0)

    post_data = {
        "title": "",  # Invalid: empty title
        "description": "ddd",
    }

    with self.login(self.superuser):
        response = self.client.post(reverse("genepanels:category-create"), post_data)

    self.assertEqual(response.status_code, 200)  # Should re-render the form
    self.assertFormError(response, "form", "title", "This field is required.")
    self.assertEqual(GenePanelCategory.objects.count(), 0)

Line range hint 120-166: Consider adding a test for invalid data submission in update view.

Similar to the create view, it would be beneficial to test how the update view handles invalid data submission. This ensures that the view properly validates input and returns appropriate error responses when updating a category.

Here's a suggested test method to add:

def test_update_invalid_data(self):
    self.assertEqual(GenePanelCategory.objects.count(), 1)

    post_data = {
        "title": "",  # Invalid: empty title
        "description": "ddd",
    }

    with self.login(self.superuser):
        response = self.client.post(
            reverse(
                "genepanels:category-update",
                kwargs={"category": self.category.sodar_uuid},
            ),
            post_data,
        )

    self.assertEqual(response.status_code, 200)  # Should re-render the form
    self.assertFormError(response, "form", "title", "This field is required.")
    self.assertEqual(GenePanelCategory.objects.count(), 1)
    self.category.refresh_from_db()
    self.assertNotEqual(self.category.title, post_data["title"])

Line range hint 303-358: Consider adding a test for invalid data submission in gene panel update view.

While the current tests cover the happy path and external service interaction, it would be beneficial to also test how the update view handles invalid data submission. This ensures that the view properly validates input and returns appropriate error responses when updating a gene panel.

Here's a suggested test method to add:

@patch("django.conf.settings.VARFISH_BACKEND_URL_ANNONARS", "https://annonars.com")
@Mocker()
def test_update_invalid_data(self, mock):
    self.assertEqual(GenePanel.objects.count(), 1)
    self._set_annonars_mocker(mock)

    post_data = {
        "identifier": "",  # Invalid: empty identifier
        "title": "XXX",
        "description": "ddd",
        "version_major": 2,
        "version_minor": 2,
        "category": str(self.category.sodar_uuid),
        "genes": "TTN\nGBA1",
    }

    with self.login(self.superuser):
        response = self.client.post(
            reverse(
                "genepanels:genepanel-update",
                kwargs={"panel": self.panel.sodar_uuid},
            ),
            post_data,
        )

    self.assertEqual(response.status_code, 200)  # Should re-render the form
    self.assertFormError(response, "form", "identifier", "This field is required.")
    self.panel.refresh_from_db()
    self.assertNotEqual(self.panel.identifier, post_data["identifier"])

Line range hint 1-700: Summary of changes and suggestions for improvement

The main change in this file is the consistent update of the base class from TestViewsBase to ViewTestBase for all test classes. This change appears to be part of a larger refactoring effort to standardize view tests across the project.

The existing test coverage is generally good, with comprehensive tests for various scenarios including different panel states and interactions with external services. However, there are a few areas where the test coverage could be improved:

  1. Several view tests (GenePanelCategoryCreateView, GenePanelCategoryUpdateView, GenePanelUpdateView) lack tests for invalid data submission. Adding these tests would ensure that the views properly handle and respond to invalid input.

  2. Consider adding edge case tests for some views, such as testing with maximum allowed values or testing with special characters in input fields.

  3. For views that interact with external services (like Annonars), consider adding tests for scenarios where the external service fails or returns unexpected data.

These improvements would further enhance the robustness of the test suite and help catch potential issues early in the development process.

backend/variants/tests/test_file_export.py (1)

18-18: Consider checking other files for similar changes

The switch from ProjectEvent to TimelineEvent in this file might be part of a larger refactoring effort. It would be beneficial to ensure that this change has been consistently applied across the entire codebase where necessary.

Consider running the following script to identify other files that might need similar updates:

#!/bin/bash
# Description: Search for other occurrences of ProjectEvent in the codebase

# Test: Search for files containing ProjectEvent
rg -l 'ProjectEvent'

# Note: Review the output and update other files if necessary

Also applies to: 978-978

backend/seqvars/tests/test_permissions_api.py (2)

Line range hint 356-2341: Consider a comprehensive refactoring of the test suite structure

The current test file contains 16 very similar test classes, each testing CRUD operations for different models related to sequence variant queries and results. While thorough, this approach leads to significant code duplication and a very long file that may be difficult to maintain. Consider a major refactoring of the test suite to improve its structure, readability, and maintainability.

Here are some suggestions for refactoring:

  1. Create a base test class:
    Implement a base test class that contains all the common CRUD test methods. This class should be generic enough to work with different models and URL patterns.

  2. Use parameterized tests:
    Utilize a library like parameterized to create data-driven tests. This can help reduce the number of test classes and methods while still covering all necessary cases.

  3. Group related tests:
    Instead of having separate test classes for closely related models, consider grouping them into a single test class with multiple test methods.

  4. Use fixtures or factories more extensively:
    Create fixtures or use factory-boy more extensively to set up test data, reducing the amount of setup code in each test method.

  5. Separate permissions tests:
    Consider separating the permissions testing logic into its own set of tests, allowing the CRUD tests to focus solely on functionality.

Here's a basic example of how this refactoring could look:

from parameterized import parameterized

class BaseAPITest(ProjectAPIPermissionTestBase):
    def setUp(self):
        super().setUp()
        self.good_users = [self.superuser, self.user_owner, self.user_delegate, self.user_contributor, self.user_guest]
        self.bad_users_401 = [self.anonymous]
        self.bad_users_403 = [self.user_no_roles, self.user_finder_cat]

    def assert_crud_operations(self, url_name, factory, create_data):
        # Implement generic CRUD tests here

class TestSeqVarsAPI(BaseAPITest):
    @parameterized.expand([
        ("querypresetsset", SeqvarsQueryPresetsSetFactory, {"rank": 1, "label": "test"}),
        ("querypresetssetversion", SeqvarsQueryPresetsSetVersionFactory, {"version_minor": 2}),
        # ... add other models here
    ])
    def test_crud_operations(self, url_name, factory, create_data):
        self.assert_crud_operations(url_name, factory, create_data)

    # Add any specific tests that don't fit the generic CRUD pattern here

This refactoring would significantly reduce the length of the test file, make it easier to maintain and extend, and still provide comprehensive coverage of your API endpoints.


Line range hint 1-2341: Summary of review for test_permissions_api.py

This file contains comprehensive tests for API permissions across multiple related models in the sequence variants module. The tests are thorough and cover various user roles and CRUD operations. However, there are several areas where the code could be improved:

  1. There's significant repetition across the test classes, which could be reduced through refactoring.
  2. The file is very long, which may impact maintainability.
  3. More advanced testing techniques could be employed to make the tests more concise and easier to maintain.

Main suggestions for improvement:

  1. Create a base test class for common CRUD operations.
  2. Use parameterized tests to reduce repetition.
  3. Consider grouping related tests and using fixtures or factories more extensively.
  4. Separate permissions testing logic from CRUD testing.

Implementing these suggestions could significantly improve the maintainability and readability of the test suite while maintaining its comprehensive coverage.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 40c78cb and 85aac5f.

⛔ Files ignored due to path filters (1)
  • backend/Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (75)
  • .github/workflows/main.yml (1 hunks)
  • backend/Makefile (1 hunks)
  • backend/Pipfile (4 hunks)
  • backend/beaconsite/tests/test_permissions.py (3 hunks)
  • backend/beaconsite/tests/test_permissions_ajax.py (2 hunks)
  • backend/beaconsite/tests/test_permissions_api.py (3 hunks)
  • backend/beaconsite/tests/test_views.py (9 hunks)
  • backend/beaconsite/tests/test_views_ajax.py (1 hunks)
  • backend/beaconsite/urls.py (1 hunks)
  • backend/cases/tests/test_permissions.py (1 hunks)
  • backend/cases/tests/test_permissions_ajax.py (12 hunks)
  • backend/cases/tests/test_permissions_api.py (11 hunks)
  • backend/cases/tests/test_views.py (1 hunks)
  • backend/cases/tests/test_views_ajax.py (12 hunks)
  • backend/cases/urls.py (1 hunks)
  • backend/cases_analysis/tests/test_permissions_api.py (2 hunks)
  • backend/cases_import/tests/test_permissions_api.py (1 hunks)
  • backend/cases_qc/tests/test_permissions_api.py (2 hunks)
  • backend/cohorts/migrations/0008_alter_cohort_user.py (1 hunks)
  • backend/cohorts/tests/test_permissions_ajax.py (3 hunks)
  • backend/cohorts/tests/test_permissions_api.py (3 hunks)
  • backend/cohorts/tests/test_views_ui.py (1 hunks)
  • backend/cohorts/urls.py (1 hunks)
  • backend/config/settings/base.py (3 hunks)
  • backend/config/urls.py (5 hunks)
  • backend/ext_gestaltmatcher/migrations/0003_alter_smallvariantquerygestaltmatcherscores_id_and_more.py (1 hunks)
  • backend/genepanels/tests/test_permissions.py (2 hunks)
  • backend/genepanels/tests/test_views.py (12 hunks)
  • backend/genepanels/urls.py (1 hunks)
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1 hunks)
  • backend/importer/urls.py (1 hunks)
  • backend/maintenance/management/commands/create_variant_summary.py (1 hunks)
  • backend/maintenance/management/commands/drop_variant_summary.py (1 hunks)
  • backend/seqmeta/tests/test_permissions.py (2 hunks)
  • backend/seqmeta/tests/test_views.py (3 hunks)
  • backend/seqmeta/urls.py (2 hunks)
  • backend/seqvars/tests/test_permissions_api.py (17 hunks)
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_presets.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_queries.py (6 hunks)
  • backend/svs/urls.py (2 hunks)
  • backend/varannos/tests/helpers.py (3 hunks)
  • backend/varannos/tests/test_permissions.py (1 hunks)
  • backend/varannos/tests/test_permissions_api.py (1 hunks)
  • backend/varannos/tests/test_views.py (2 hunks)
  • backend/varannos/urls.py (2 hunks)
  • backend/varfish/templates/users/login.html (1 hunks)
  • backend/varfish/users/urls.py (1 hunks)
  • backend/varfish/vueapp/urls.py (1 hunks)
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (1 hunks)
  • backend/variants/models/maintenance.py (1 hunks)
  • backend/variants/tests/helpers.py (4 hunks)
  • backend/variants/tests/test_file_export.py (2 hunks)
  • backend/variants/tests/test_permissions_ajax.py (6 hunks)
  • backend/variants/tests/test_permissions_ajax_annos.py (1 hunks)
  • backend/variants/tests/test_permissions_ajax_presets.py (29 hunks)
  • backend/variants/tests/test_permissions_api.py (7 hunks)
  • backend/variants/tests/test_ui.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (2 hunks)
  • backend/variants/urls/init.py (2 hunks)
  • backend/variants/urls/annos.py (1 hunks)
  • backend/variants/urls/presets.py (2 hunks)
  • frontend/ext/reev-frontend-lib (1 hunks)
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (1 hunks)
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4 hunks)
  • frontend/src/varfish/components/FilterForm/DevPane.vue (2 hunks)
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/EffectPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FlagsPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3 hunks)
  • frontend/src/variants/components/FilterForm/QualityPane.vue (1 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetProperties.vue (1 hunks)
  • utils/docker/docker-entrypoint.sh (1 hunks)
🧰 Additional context used
🪛 Ruff
backend/variants/models/maintenance.py

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

backend/variants/tests/helpers.py

158-158: Redefinition of unused ViewTestBase from line 47

(F811)

🔇 Additional comments (304)
frontend/ext/reev-frontend-lib (1)

1-1: Submodule update approved. Verify compatibility.

The submodule reev-frontend-lib has been updated to a new commit. This change looks good, but it's important to ensure that this update is intentional and compatible with the main project.

To verify the changes between the old and new versions of the submodule, you can run the following commands:

This will help you review the changes and ensure there are no breaking changes or unexpected modifications.

Would you like me to analyze the changes in the submodule for potential impacts on the main project?

backend/varfish/vueapp/urls.py (1)

1-1: LGTM: Updated import statement to use django.urls

The change from django.conf.urls to django.urls and the use of path instead of url is correct. This aligns with Django's best practices and deprecation warnings.

backend/varfish/users/urls.py (6)

1-1: LGTM: Correct import for Django's path function.

The change from importing url to importing path is correct and follows Django's best practices for URL routing.


6-6: LGTM: Correct implementation of path() for UserListView.

The URL pattern for UserListView has been correctly updated to use path(). The empty string pattern correctly matches the root of the URL namespace, equivalent to the previous regex ^$.


7-7: LGTM: Correct implementation of path() for UserRedirectView.

The URL pattern for UserRedirectView has been correctly updated to use path(). The simplified pattern ~redirect/ is equivalent to the previous regex ^~redirect/$ in this context.


8-8: LGTM: Improved readability with path() for UserDetailView.

The URL pattern for UserDetailView has been correctly updated to use path(). The new pattern <str:username>/ uses a path converter, which is equivalent to the previous regex for capturing usernames. This change improves readability and maintainability of the code.


9-9: LGTM: Correct implementation of path() for UserUpdateView.

The URL pattern for UserUpdateView has been correctly updated to use path(). The simplified pattern ~update/ is equivalent to the previous regex ^~update/$ in this context.


1-9: Great job updating URL patterns to use path()!

The changes in this file consistently update all URL patterns to use Django's path() function instead of the deprecated url() function. This update aligns with Django's best practices and improves the overall readability and maintainability of the URL routing configuration. The functionality remains unchanged while benefiting from the more modern syntax.

backend/cohorts/tests/test_views_ui.py (1)

Line range hint 5-17: Address the commented-out state of the entire file

The entire file, including the TestEntrypointView class, is commented out. This effectively disables all tests for the cohorts entrypoint view, which could lead to reduced test coverage.

  1. Is this intentional?
  2. If so, what is the plan to re-enable these tests or replace them?
  3. If not, should these tests be uncommented and updated to work with the new UITestBase class?

Ensuring proper test coverage is crucial for maintaining the reliability of the cohorts functionality.

To check the current test coverage for the cohorts module, we can run the following script:

This will help us understand the impact of commenting out this test file on the overall test coverage of the cohorts module.

backend/variants/urls/annos.py (1)

3-3: LGTM: Updated import statement to use path from django.urls

This change aligns with Django's best practices by using the more modern path() function instead of the deprecated url() function for URL routing. This update improves code readability and maintainability.

backend/cases/tests/test_views.py (2)

2-2: LGTM! Verify base class functionality.

The import statement has been updated to use ProjectPermissionTestBase from projectroles.tests.test_permissions. This change appears to be part of a refactoring effort and follows better naming conventions.

To ensure that the new base class provides all necessary functionality, please run the following script:


5-5: LGTM! Verify impact on test suite.

The class inheritance has been updated to use ProjectPermissionTestBase, which is consistent with the import statement change. The test method remains unchanged, suggesting that the expected behavior is maintained.

To ensure that this change doesn't negatively impact other parts of the test suite, please run the following script:

backend/maintenance/management/commands/drop_variant_summary.py (1)

1-7: LGTM: Well-structured file with proper imports.

The file structure and import organization follow good practices. The module-level docstring provides a clear description of the file's purpose, and the imports are grouped logically with proper spacing.

backend/maintenance/management/commands/create_variant_summary.py (3)

1-7: LGTM: Well-structured imports and file organization.

The file structure and imports are well-organized, following Python best practices. The module-level docstring provides a clear description of the file's purpose, and the imports are grouped logically with appropriate spacing.


9-13: LGTM: Well-defined Command class.

The Command class is correctly implemented as a Django management command. The class-level docstring and the help attribute provide clear and concise information about the command's purpose.


1-19: Overall assessment: Well-implemented Django management command.

This new Django management command for creating variant summaries is well-structured and follows best practices. The code is clean, readable, and properly organized. The suggested improvements for error handling and progress reporting will enhance its robustness and user-friendliness, but the current implementation is already solid and ready for use.

Great job on this implementation!

backend/cases/tests/test_permissions.py (3)

Line range hint 1-24: Summary: Base class update improves consistency.

The changes in this file are minimal and focused on updating the base class name from TestProjectPermissionBase to ProjectPermissionTestBase. This update improves code consistency and follows better naming conventions. The functionality of the TestCasesViews class and its test_entrypoint method remains unchanged, which suggests that the base class interface is compatible.

To ensure project-wide consistency, consider reviewing other test files that might still be using the old base class name.


2-2: LGTM! Consider verifying other test files.

The import statement has been updated to use ProjectPermissionTestBase, which follows better naming conventions. This change improves code readability and consistency.

To ensure consistency across the project, let's verify if other test files need similar updates:

#!/bin/bash
# Description: Check for other test files that might need updating

# Search for files still using the old base class name
rg --type python 'from projectroles.tests.test_permissions import TestProjectPermissionBase' -l

# Search for files already using the new base class name
rg --type python 'from projectroles.tests.test_permissions import ProjectPermissionTestBase' -l

5-5: LGTM! Verify base class interface consistency.

The class inheritance has been updated to use ProjectPermissionTestBase, which is consistent with the import statement change. This improves code consistency and readability.

To ensure that the new base class maintains the same interface, let's verify its definition:

backend/ext_gestaltmatcher/migrations/0003_alter_smallvariantquerygestaltmatcherscores_id_and_more.py (4)

1-4: LGTM: Migration file header and imports are correct.

The file header and imports are standard for a Django migration file. The Django version (4.2.16) is up-to-date, and the necessary modules are imported correctly.


1-27: Overall assessment: Well-structured migration for improved scalability.

This migration file is well-crafted and follows Django best practices. The change to BigAutoField for the id fields of both smallvariantquerygestaltmatcherscores and smallvariantquerypediascores models is a forward-thinking approach to ensure database scalability.

Key points:

  1. The migration is correctly dependent on the previous migration.
  2. The changes are consistent across both models.
  3. The use of BigAutoField allows for a larger range of unique identifiers.

Remember to test thoroughly, especially if there's existing data, and update any related code or models that might be affected by this change.


12-27: LGTM: Appropriate field type change for better scalability.

The migration correctly changes the id field to BigAutoField for both smallvariantquerygestaltmatcherscores and smallvariantquerypediascores models. This change improves the scalability of the database by allowing for a larger range of unique identifiers.

Consider the following:

  1. Ensure that any foreign key references to these models are updated accordingly.
  2. If there's existing data, verify that the migration handles the conversion of existing IDs correctly.
  3. Update any code that might be making assumptions about the type or size of these ID fields.

To verify the impact of this change on related models, run the following command:


8-10: LGTM: Migration dependency is correctly specified.

The dependency on the previous migration (0002_smallvariantquerypediascores) is correctly specified, ensuring that migrations are applied in the proper sequence.

To verify the migration history and ensure this migration is correctly placed, run the following command:

backend/cohorts/migrations/0008_alter_cohort_user.py (1)

1-28: Verify the impact of making the user field optional in the Cohort model.

The migration alters the user field in the Cohort model, making it optional and changing its behavior on user deletion. While this change provides more flexibility, it has several implications:

  1. Cohorts can now exist without an associated user.
  2. If a user is deleted, their cohorts will remain but with a NULL user reference.

These changes might impact existing queries, business logic, and data integrity. Please ensure that:

  1. All code interacting with cohorts accounts for potentially NULL user values.
  2. The application logic for creating and managing cohorts is updated to handle cases where a user is not specified.
  3. Any reports or analytics depending on cohort ownership are adjusted accordingly.

To help verify the impact, you can run the following script to check for any direct references to the cohort's user that might need updating:

Consider implementing a database constraint or application-level validation to ensure that cohorts always have an associated user, even if it's a system user. This can help maintain data integrity and simplify querying.

backend/variants/tests/test_permissions_ajax_annos.py (3)

2-2: LGTM: Import statement updated correctly.

The import statement has been appropriately updated to reflect the change in the base class. This change aligns with the new inheritance structure of the test class.


Line range hint 8-28: Verify unchanged methods compatibility.

The setUp and test_get methods remain unchanged. They appear to use attributes and methods that should be common to both the old and new base classes (e.g., self.project, self.superuser, self.user_owner, etc.). However, it's important to ensure full compatibility.

Please run the following script to verify the compatibility of these unchanged methods with the new base class:

After running these checks, please confirm that:

  1. All required attributes (self.project, self.superuser, self.user_owner, etc.) are available in the new base class.
  2. The assert_response method is present and functions as expected in the new base class.
  3. There are no significant changes in the implementation of these methods that could affect the test behavior.

7-7: Verify compatibility with new base class.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase looks good and aligns with the updated import statement. This change suggests a move towards a more standardized testing framework for project API permissions.

To ensure that this change doesn't introduce any unexpected behavior, please verify:

  1. That all methods used in this test class are still available in the new base class.
  2. That the behavior of inherited methods remains consistent with the previous implementation.

You can run the following script to check for any potential issues:

backend/svs/tests/test_permissions_ajax_presets.py (2)

9-9: LGTM! Ensure consistent base class usage.

The change of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the import change. This update should maintain the same functionality, assuming the new base class has an identical interface.

Let's verify that this base class change has been consistently applied across the codebase:

#!/bin/bash
# Description: Check for consistent usage of ProjectAPIPermissionTestBase

# Test 1: Search for class definitions using ProjectAPIPermissionTestBase
echo "Searching for class definitions using ProjectAPIPermissionTestBase:"
rg --type python "class \w+\(.*ProjectAPIPermissionTestBase"

# Test 2: Search for any remaining class definitions using TestProjectAPIPermissionBase
echo "Searching for any remaining class definitions using TestProjectAPIPermissionTestBase:"
rg --type python "class \w+\(.*TestProjectAPIPermissionBase"

4-4: LGTM! Verify consistent usage across the codebase.

The import change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase looks good. This new name follows a more standard naming convention for test base classes.

To ensure consistency, let's verify that this change has been applied across the entire codebase:

✅ Verification successful

Import change verified successfully.

All instances of TestProjectAPIPermissionBase have been updated to ProjectAPIPermissionTestBase across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of TestProjectAPIPermissionBase

# Test 1: Search for any remaining imports of TestProjectAPIPermissionBase
echo "Searching for remaining imports of TestProjectAPIPermissionBase:"
rg --type python "from projectroles.tests.test_permissions_api import .*TestProjectAPIPermissionBase"

# Test 2: Search for any remaining class definitions using TestProjectAPIPermissionBase
echo "Searching for remaining class definitions using TestProjectAPIPermissionBase:"
rg --type python "class \w+\(.*TestProjectAPIPermissionBase"

Length of output: 608


Script:

#!/bin/bash
# Description: Check for any remaining usage of TestProjectAPIPermissionBase

# Test 1: Search for any remaining imports of TestProjectAPIPermissionBase
echo "Searching for remaining imports of TestProjectAPIPermissionBase:"
rg "from projectroles.tests.test_permissions_api import .*TestProjectAPIPermissionBase" --glob "*.py"

# Test 2: Search for any remaining class definitions using TestProjectAPIPermissionBase
echo "Searching for remaining class definitions using TestProjectAPIPermissionBase:"
rg "class \w+\(.*TestProjectAPIPermissionBase" --glob "*.py"

Length of output: 470

backend/varannos/tests/helpers.py (3)

14-14: LGTM! Class rename improves consistency.

The class rename from TestViewsBase to ViewTestBase aligns with the convention of putting "Test" at the end of test class names. This change enhances code readability and maintains consistency with other recent changes.


31-31: LGTM! Verify test coverage after base class update.

The ApiViewTestBase class has been updated to inherit from ProjectAPIPermissionTestBase, which is consistent with the import statement change. This maintains the intended functionality while improving naming consistency.

To ensure this change doesn't introduce any unexpected behavior, please run the following script to check the test coverage for this file and related tests:

#!/bin/bash
# Description: Check test coverage for varannos/tests/helpers.py and related tests

# Test: Run pytest with coverage for varannos/tests/helpers.py and print the report
pytest --cov=varannos.tests.helpers --cov-report=term-missing varannos/tests/

3-3: LGTM! Verify the impact of the base class rename.

The import statement has been updated to use ProjectAPIPermissionTestBase, which follows a more conventional naming pattern for test classes. This change improves code readability.

To ensure this change doesn't introduce any issues, please run the following script to check for any remaining references to the old class name:

✅ Verification successful

LGTM! Verify the impact of the base class rename.

The import statement has been updated to use ProjectAPIPermissionTestBase, which follows a more conventional naming pattern for test classes. This change improves code readability.


Action Required: Update the shell script to use the correct file type for Python files.

The previous script failed because rg does not recognize python as a valid file type. Please use py instead.


LGTM! The impact of the base class rename has been verified with no remaining references found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to TestProjectAPIPermissionBase

# Test: Search for TestProjectAPIPermissionBase. Expect: No results.
rg --type python 'TestProjectAPIPermissionBase'

Length of output: 153


Script:

#!/bin/bash
# Description: Check for any remaining references to TestProjectAPIPermissionBase

# Test: Search for TestProjectAPIPermissionBase. Expect: No results.
rg --type python 'TestProjectAPIPermissionBase'

Length of output: 78


Script:

#!/bin/bash
# Description: Check for any remaining references to TestProjectAPIPermissionBase

# Test: Search for TestProjectAPIPermissionBase. Expect: No results.
rg --type py 'TestProjectAPIPermissionBase'

Length of output: 43

backend/varannos/tests/test_views.py (4)

21-21: LGTM: Base class updated for TestVarAnnoSetDetailView.

The base class has been changed from TestViewsBase to ViewTestBase, consistent with the changes made to TestVarAnnoSetListView.

Please refer to the previous comment regarding TestVarAnnoSetListView for verification steps. The same considerations apply to this class.


7-7: LGTM: Base class updated for TestVarAnnoSetListView.

The base class has been changed from TestViewsBase to ViewTestBase. This change appears to be consistent with the new import statement.

To ensure that all required methods are still available, please verify:

  1. That ViewTestBase provides all the methods used in this test class, particularly setUp and login.
  2. Run the tests to confirm they still pass with the new base class.

You can use the following script to check for any potential method conflicts:

#!/bin/bash
# Description: Check for methods used in TestVarAnnoSetListView that might not be in ViewTestBase

# Test: List methods called on self that are not standard Python test methods
echo "Methods potentially needing verification in ViewTestBase:"
rg --type python -N "self\.((?!assert|setUp|tearDown|test_)[a-zA-Z_]+)\(" backend/varannos/tests/test_views.py

Line range hint 1-34: Verify the impact of base class changes on the entire test suite.

The changes to both TestVarAnnoSetListView and TestVarAnnoSetDetailView appear to be part of a larger refactoring effort to use ViewTestBase instead of TestViewsBase. While the changes in this file look good, it's important to ensure that this refactoring doesn't have unintended consequences across the entire test suite.

Please run the following steps to verify the overall impact:

  1. Run the entire test suite to ensure all tests still pass.
  2. Check for any deprecation warnings related to ViewTestBase or TestViewsBase.
  3. Verify that similar changes have been applied consistently across other test files.

You can use the following script to check for consistency across the project:

If any inconsistencies are found, please ensure they are addressed or explained in the PR description.

✅ Verification successful

Base class refactoring verified successfully. All test files now use ViewTestBase, and no instances of TestViewsBase remain. The test suite is consistent with the refactoring.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in base class usage across test files

# Test 1: Count occurrences of ViewTestBase and TestViewsBase
echo "Occurrences of ViewTestBase:"
rg --type python -c "class .*(ViewTestBase)" 

echo "Occurrences of TestViewsBase:"
rg --type python -c "class .*(TestViewsBase)"

# Test 2: List files still using TestViewsBase
echo "Files still using TestViewsBase:"
rg --type python -l "class .*(TestViewsBase)"

Length of output: 446


Script:

#!/bin/bash
# Description: Check for consistency in base class usage across test files

# Test 1: Count occurrences of ViewTestBase and TestViewsBase
echo "Occurrences of ViewTestBase:"
rg --glob '*.py' -c 'class\s+\w+\s*\(ViewTestBase\)' 

echo "Occurrences of TestViewsBase:"
rg --glob '*.py' -c 'class\s+\w+\s*\(TestViewsBase\)'

# Test 2: List files still using TestViewsBase
echo "Files still using TestViewsBase:"
rg --glob '*.py' -l 'class\s+\w+\s*\(TestViewsBase\)'

Length of output: 610


4-4: LGTM: New base class import added.

The import of ViewTestBase from variants.tests.helpers has been added, replacing the previous base class. This change appears to be part of a refactoring effort to improve test organization.

To ensure this change is consistent across the project, please run the following script:

✅ Verification successful

[/run_scripts]


[/run_scripts]


Verification Successful: All TestViewsBase references have been removed and replaced with ViewTestBase.

The changes in backend/varannos/tests/test_views.py have been verified. There are no remaining imports or class definitions of TestViewsBase, and ViewTestBase is correctly imported and utilized as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of ViewTestBase and absence of TestViewsBase

# Test 1: Check for any remaining imports of TestViewsBase
echo "Checking for remaining TestViewsBase imports:"
rg --type python "from .* import .*TestViewsBase"

# Test 2: Check for the new ViewTestBase imports
echo "Checking for new ViewTestBase imports:"
rg --type python "from variants.tests.helpers import .*ViewTestBase"

# Test 3: Check for any remaining class definitions using TestViewsBase
echo "Checking for remaining TestViewsBase class definitions:"
rg --type python "class .*(TestViewsBase)"

Length of output: 867


Script:

#!/bin/bash
# Description: Verify the usage of ViewTestBase and absence of TestViewsBase

# Test 1: Check for any remaining imports of TestViewsBase
echo "Checking for remaining TestViewsBase imports:"
rg --type python "from .* import .*TestViewsBase" || echo "No TestViewsBase imports found."

# Test 2: Check for the new ViewTestBase imports
echo "Checking for new ViewTestBase imports:"
rg --type python "from variants.tests.helpers import .*ViewTestBase" || echo "ViewTestBase imports not found."

# Test 3: Check for any remaining class definitions using TestViewsBase
echo "Checking for remaining TestViewsBase class definitions:"
rg --type python "class .*TestViewsBase" || echo "No TestViewsBase class definitions found."

Length of output: 806


Script:

#!/bin/bash
# Description: Verify the usage of ViewTestBase and absence of TestViewsBase

# Test 1: Check for any remaining imports of TestViewsBase
echo "Checking for remaining TestViewsBase imports:"
rg "from .* import .*TestViewsBase" --glob "*.py" || echo "No TestViewsBase imports found."

# Test 2: Check for the new ViewTestBase imports
echo "Checking for new ViewTestBase imports:"
rg "from variants.tests.helpers import .*ViewTestBase" --glob "*.py" || echo "ViewTestBase imports not found."

# Test 3: Check for any remaining class definitions using TestViewsBase
echo "Checking for remaining TestViewsBase class definitions:"
rg "class .*TestViewsBase" --glob "*.py" || echo "No TestViewsBase class definitions found."

Length of output: 2182

backend/varannos/urls.py (8)

1-1: LGTM: Import statement updated correctly

The import statement has been correctly updated to use django.urls instead of django.conf.urls. This change is necessary and consistent with the transition from url() to path() throughout the file.


7-11: LGTM: URL pattern updated correctly with improved readability

The URL pattern for VarAnnoSetListView has been successfully updated to use path() instead of url(). This change brings several improvements:

  1. The use of the uuid path converter enhances type safety and readability.
  2. The pattern is now more concise and easier to understand.
  3. The trailing slash is handled automatically by Django's path() function.

These updates align with modern Django best practices.


12-16: LGTM: URL pattern updated consistently with previous changes

The URL pattern for VarAnnoSetDetailView has been correctly updated to use path(). This change maintains consistency with the previous pattern update and includes the same improvements:

  1. Utilization of the uuid path converter for enhanced type safety and readability.
  2. Simplified and more intuitive pattern structure.
  3. Automatic handling of the trailing slash by Django's path() function.

This update continues to align with modern Django best practices and maintains consistency throughout the file.


22-26: LGTM: API URL pattern updated consistently with UI patterns

The URL pattern for VarAnnoSetListCreateApiView has been successfully updated to use path(). This change maintains consistency with the previous UI pattern updates and extends the improvements to the API routes:

  1. Consistent use of the uuid path converter across both UI and API routes.
  2. Simplified pattern structure that enhances readability and maintainability.
  3. Preservation of the API-specific URL structure while modernizing the pattern definition.

This update demonstrates a cohesive approach to URL pattern modernization across different view types in the application.


27-31: LGTM: API URL pattern updated consistently with previous patterns

The URL pattern for VarAnnoSetRetrieveUpdateDestroyApiView has been correctly updated to use path(). This change maintains the consistency established in previous updates:

  1. Continued use of the uuid path converter for API routes.
  2. Simplified pattern structure that enhances readability and maintainability.
  3. Preservation of the API-specific URL structure while using modern Django URL patterns.

This update further reinforces the cohesive approach to modernizing URL patterns across the application's API routes.


32-36: LGTM: API URL pattern for VarAnnoSetEntry updated consistently

The URL pattern for VarAnnoSetEntryListCreateApiView has been successfully updated to use path(). This change maintains the consistency established in previous updates and extends it to a different model type:

  1. Consistent use of the uuid path converter for API routes across different models.
  2. Simplified pattern structure that enhances readability and maintainability.
  3. Preservation of the API-specific URL structure while using modern Django URL patterns.

This update demonstrates a systematic approach to modernizing URL patterns across different model types in the API, ensuring consistency throughout the application.


37-41: LGTM: Consistent URL pattern updates completed across all routes

The URL pattern for VarAnnoSetEntryRetrieveUpdateDestroyApiView has been correctly updated to use path(). This final change completes the consistent update of all URL patterns in the file:

  1. Uniform use of the uuid path converter across all routes (UI and API).
  2. Consistent simplification of pattern structures, enhancing overall readability and maintainability.
  3. Preservation of specific URL structures (UI vs API) while modernizing all patterns.

This update concludes the systematic modernization of URL patterns across different view types and models in the application. The consistency in these changes will significantly improve code maintainability and align the project with current Django best practices.


Line range hint 1-46: Excellent work on modernizing URL patterns

This update successfully transitions all URL patterns from url() to path(), bringing several benefits to the project:

  1. Improved readability: The use of path converters (e.g., <uuid:project>) makes the URL patterns more intuitive and easier to understand at a glance.
  2. Enhanced type safety: The uuid path converter ensures that only valid UUIDs are matched, reducing the risk of errors.
  3. Consistency: The changes have been applied uniformly across both UI and API routes, maintaining a cohesive structure throughout the file.
  4. Alignment with best practices: These updates bring the project in line with modern Django conventions, facilitating future maintenance and upgrades.
  5. Simplified patterns: The new patterns are more concise and eliminate the need for complex regex expressions.

The preservation of the existing file structure (ui_urlpatterns, ajax_urlpatterns, api_urlpatterns) alongside these updates ensures that the overall organization of the URLs remains intact while benefiting from the improved syntax.

Overall, this is a well-executed update that enhances the quality and maintainability of the codebase.

backend/seqmeta/tests/test_permissions.py (2)

26-26: LGTM. Verify test suite functionality.

The base class for TestSeqmetaView has been updated from TestProjectPermissionBase to ProjectPermissionTestBase, which is consistent with the import statement change.

To ensure that this change doesn't introduce any issues, please run the test suite for this module and verify that all tests pass. You can use the following command:

#!/bin/bash
# Description: Run tests for the seqmeta module

# Test: Run pytest for the seqmeta module
pytest backend/seqmeta

# If any tests fail, it might indicate that the new base class requires additional setup
# or has introduced breaking changes that need to be addressed.

2-2: LGTM. Verify consistent updates across the project.

The import statement has been updated to use ProjectPermissionTestBase instead of TestProjectPermissionBase. This change aligns with the modification of the base class for TestSeqmetaView.

To ensure consistency across the project, please run the following script to check for any remaining usage of TestProjectPermissionBase:

backend/seqmeta/urls.py (9)

1-1: LGTM: Import statement updated correctly

The import statement has been correctly updated to use django.urls instead of django.conf.urls. This change is necessary and consistent with the transition from url() to path() in Django's URL routing.


8-12: LGTM: Index view URL pattern updated correctly

The URL pattern for the index view has been successfully updated to use the path() function. The empty string correctly represents the root URL, which is equivalent to the previous regex pattern r"^$". This change improves readability and follows Django's recommended practices for URL routing.


13-17: LGTM: Enrichment kit list view URL pattern updated correctly

The URL pattern for the enrichment kit list view has been successfully updated to use the path() function. The new pattern "enrichmentkit/" correctly includes a trailing slash, which is consistent with Django's URL naming conventions. This change simplifies the URL pattern and improves its readability.


18-22: LGTM: Enrichment kit detail view URL pattern updated with improved type safety

The URL pattern for the enrichment kit detail view has been successfully updated to use the path() function. The new pattern "enrichmentkit/<uuid:enrichmentkit>/" offers several improvements:

  1. It uses the uuid path converter, which is more specific and type-safe compared to the previous regex pattern.
  2. It maintains consistency with Django's URL naming conventions by including the trailing slash.
  3. It improves readability and simplifies the URL pattern.

This change enhances both the clarity and the robustness of the URL routing for the enrichment kit detail view.


28-32: LGTM: Enrichment kit list-create API view URL pattern updated correctly

The URL pattern for the enrichment kit list-create API view has been successfully updated to use the path() function. The new pattern "api/enrichmentkit/list-create/" correctly includes a trailing slash, maintaining consistency with Django's URL naming conventions. This change simplifies the URL pattern while preserving the API endpoint structure, ensuring backwards compatibility.


33-37: LGTM: Enrichment kit retrieve-update-destroy API view URL pattern updated with improved type safety

The URL pattern for the enrichment kit retrieve-update-destroy API view has been successfully updated to use the path() function. The new pattern "api/enrichmentkit/retrieve-update-destroy/<uuid:enrichmentkit>/" offers several improvements:

  1. It uses the uuid path converter, which is more specific and type-safe compared to the previous regex pattern.
  2. It maintains consistency with Django's URL naming conventions by including the trailing slash.
  3. It improves readability and simplifies the URL pattern.
  4. It preserves the API endpoint structure, ensuring backwards compatibility.

This change enhances both the clarity and the robustness of the URL routing for the enrichment kit retrieve-update-destroy API view.


38-42: LGTM: Target bed file list-create API view URL pattern updated with improved type safety

The URL pattern for the target bed file list-create API view has been successfully updated to use the path() function. The new pattern "api/targetbedfile/list-create/<uuid:enrichmentkit>/" offers several improvements:

  1. It uses the uuid path converter, which is more specific and type-safe compared to the previous regex pattern.
  2. It maintains consistency with Django's URL naming conventions by including the trailing slash.
  3. It improves readability and simplifies the URL pattern.
  4. It preserves the API endpoint structure, ensuring backwards compatibility.

This change enhances both the clarity and the robustness of the URL routing for the target bed file list-create API view.


43-47: LGTM: Target bed file retrieve-update-destroy API view URL pattern updated with improved type safety

The URL pattern for the target bed file retrieve-update-destroy API view has been successfully updated to use the path() function. The new pattern "api/targetbedfile/retrieve-update-destroy/<uuid:targetbedfile>/" offers several improvements:

  1. It uses the uuid path converter, which is more specific and type-safe compared to the previous regex pattern.
  2. It maintains consistency with Django's URL naming conventions by including the trailing slash.
  3. It improves readability and simplifies the URL pattern.
  4. It preserves the API endpoint structure, ensuring backwards compatibility.

This change enhances both the clarity and the robustness of the URL routing for the target bed file retrieve-update-destroy API view.


Line range hint 1-49: Overall: Excellent update to modern Django URL routing

The changes made to this file represent a comprehensive and well-executed update of the URL routing system. Here's a summary of the improvements:

  1. All URL patterns have been successfully migrated from url() to path(), aligning with modern Django practices.
  2. The use of the uuid path converter enhances type safety for URL parameters, reducing the risk of invalid URLs.
  3. Consistent use of trailing slashes in all patterns maintains compatibility with Django's URL naming conventions.
  4. The changes preserve the existing API structure, ensuring backwards compatibility.
  5. The new patterns are more readable and maintainable, which will benefit future development and debugging efforts.

These updates collectively improve the robustness, clarity, and maintainability of the URL routing system. Great job on implementing these changes!

backend/varannos/tests/test_permissions.py (3)

2-2: Import statement updated to match the new base class.

The import statement has been correctly updated to import ProjectPermissionTestBase from projectroles.tests.test_permissions. This change aligns with the new base class used in the TestVarAnnoSetViews class.


Line range hint 9-40: Verify compatibility of test methods with the new base class.

The test methods test_list and test_detail remain unchanged after the base class update. To ensure they continue to function as expected:

  1. Confirm that ProjectPermissionTestBase provides the assert_response method used in both test methods.
  2. Verify that the setUp method is compatible with the new base class and sets up the necessary test data.
  3. Ensure that the test logic still aligns with the project's permission testing requirements.

To verify these points, please run the following script:

#!/bin/bash
# Description: Verify the compatibility of test methods with the new base class

# Check for the assert_response method in ProjectPermissionTestBase
echo "Searching for assert_response method in ProjectPermissionTestBase:"
rg --type python -A 3 "def assert_response" $(rg --files-with-matches "class ProjectPermissionTestBase")

# Check for the setUp method in ProjectPermissionTestBase
echo "Searching for setUp method in ProjectPermissionTestBase:"
rg --type python -A 3 "def setUp" $(rg --files-with-matches "class ProjectPermissionTestBase")

# Look for any usage of TestProjectPermissionBase specific methods in the current file
echo "Checking for usage of TestProjectPermissionBase specific methods:"
rg --type python "self\.((?!assert_response|setUp)[\w_]+)" backend/varannos/tests/test_permissions.py

Please review the output to ensure that all necessary methods are available in the new base class and that no incompatible methods are being used in the current test class.


7-7: Base class updated for TestVarAnnoSetViews.

The base class for TestVarAnnoSetViews has been changed from TestProjectPermissionBase to ProjectPermissionTestBase. This change might affect the behavior of the tests.

To ensure that this change doesn't introduce any unintended side effects, let's verify the differences between the old and new base classes:

Please review the output of this script to ensure that all necessary methods and attributes are still available in the new base class, and that no functionality has been lost due to this change.

backend/seqmeta/tests/test_views.py (4)

7-7: Approve base class change and verify test coverage.

The change from TestViewsBase to ViewTestBase as the base class for IndexViewTest is consistent with the new import. This refactoring likely aims to standardize view testing across the project.

To ensure that this change doesn't affect test coverage or functionality, please run the following script:

#!/bin/bash
# Description: Verify test coverage for IndexViewTest

# Test: Run tests for IndexViewTest and check coverage
python -m pytest backend/seqmeta/tests/test_views.py::IndexViewTest --cov=seqmeta.views --cov-report=term-missing

20-20: Approve base class change and verify test coverage.

The change from TestViewsBase to ViewTestBase as the base class for EnrichmentKitListViewTest is consistent with the previous modifications. This systematic refactoring approach should lead to more standardized view testing across the project.

To ensure that this change doesn't affect test coverage or functionality, please run the following script:

#!/bin/bash
# Description: Verify test coverage for EnrichmentKitListViewTest

# Test: Run tests for EnrichmentKitListViewTest and check coverage
python -m pytest backend/seqmeta/tests/test_views.py::EnrichmentKitListViewTest --cov=seqmeta.views --cov-report=term-missing

4-4: Approve import change and verify compatibility.

The import of ViewTestBase from variants.tests.helpers aligns with the base class changes in the test classes. This suggests a refactoring of test utilities, which could lead to more standardized view testing across the project.

To ensure the new base class is compatible and contains all necessary methods, please run the following script:


33-33: Approve base class change, verify test coverage, and ensure consistency across the test suite.

The change from TestViewsBase to ViewTestBase as the base class for EnrichmentKitDetailView completes the consistent refactoring of all test classes in this file. This systematic approach should lead to more standardized view testing across the project.

To ensure that this change doesn't affect test coverage or functionality, and to verify consistency across the entire test suite, please run the following script:

Please review the results to ensure all view test classes have been updated consistently across the project.

backend/beaconsite/tests/test_views_ajax.py (3)

12-12: LGTM! Verify test coverage remains intact.

The class inheritance has been updated to use ProjectAPIPermissionTestBase, which is consistent with the import change. The test logic remains unchanged, suggesting that this is primarily a structural update.

To ensure that this change hasn't inadvertently affected test coverage, let's run a verification:

#!/bin/bash
# Description: Verify test coverage for TestBeaconInfoAjaxView

# Test 1: Check if the test class is being picked up by the test runner
echo "Checking if TestBeaconInfoAjaxView is recognized by the test runner:"
python manage.py test beaconsite.tests.test_views_ajax.TestBeaconInfoAjaxView --list-tests

# Test 2: Run the tests and check for any failures
echo "Running TestBeaconInfoAjaxView tests:"
python manage.py test beaconsite.tests.test_views_ajax.TestBeaconInfoAjaxView

# Test 3: Check for any changes in test coverage
echo "Checking test coverage for TestBeaconInfoAjaxView:"
coverage run --source='.' manage.py test beaconsite.tests.test_views_ajax.TestBeaconInfoAjaxView
coverage report -m

Please review the output of these tests to ensure that the test coverage remains intact and that no unexpected issues have been introduced by the base class change.


Line range hint 1-41: Verify the broader impact of projectroles testing framework changes.

The changes in this file appear to be part of a larger refactoring effort in the projectroles testing framework. While the impact on this specific file is minimal and the core functionality remains unchanged, it's important to ensure that these changes are consistently applied across the entire codebase.

To assess the broader impact of these changes, let's run a codebase-wide check:

#!/bin/bash
# Description: Check for consistency in projectroles testing framework usage

# Test 1: Check for any remaining usage of TestProjectAPIPermissionBase
echo "Checking for any remaining usage of TestProjectAPIPermissionBase:"
rg --type python "TestProjectAPIPermissionBase"

# Test 2: Verify consistent usage of ProjectAPIPermissionTestBase
echo "Verifying consistent usage of ProjectAPIPermissionTestBase:"
rg --type python "ProjectAPIPermissionTestBase"

# Test 3: Check for any test files that might need similar updates
echo "Checking for potential test files that might need updates:"
fd --type file --extension py "test_.*\.py" | xargs grep -l "projectroles.tests"

Please review the output of these checks to ensure that the changes to the projectroles testing framework have been consistently applied across the codebase. If any inconsistencies are found, they should be addressed to maintain uniformity in the testing structure.


5-5: LGTM! Verify the updated import across the codebase.

The import statement has been updated to use the new ProjectAPIPermissionTestBase from test_permissions_api. This change aligns with best practices in naming conventions for test base classes.

To ensure consistency, let's verify that this import has been updated across the entire codebase:

✅ Verification successful

Import Statement Update Verified

The old TestProjectAPIPermissionBase import statements have been successfully removed, and the new ProjectAPIPermissionTestBase import is consistently used across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining imports of TestProjectAPIPermissionBase

# Test 1: Search for old import statement
echo "Searching for old import statements:"
rg --type python "from projectroles.tests.test_permissions import TestProjectAPIPermissionBase"

# Test 2: Search for usage of TestProjectAPIPermissionBase
echo "Searching for usage of TestProjectAPIPermissionBase:"
rg --type python "class \w+\(TestProjectAPIPermissionBase\)"

# Test 3: Verify new import statement usage
echo "Verifying new import statement usage:"
rg --type python "from projectroles.tests.test_permissions_api import ProjectAPIPermissionTestBase"

Length of output: 2122


Script:

#!/bin/bash
# Description: Re-verify import statement changes without using --type python

# Test 1: Search for old import statement in .py files
echo "Searching for old import statements in .py files:"
rg "from projectroles\.tests\.test_permissions import TestProjectAPIPermissionBase" --type-add 'python:*.py' --type python

# Test 2: Search for usage of TestProjectAPIPermissionBase in .py files
echo "Searching for usage of TestProjectAPIPermissionBase in .py files:"
rg "class \w+\(TestProjectAPIPermissionBase\)" --type-add 'python:*.py' --type python

# Test 3: Verify new import statement usage in .py files
echo "Verifying new import statement usage in .py files:"
rg "from projectroles\.tests\.test_permissions_api import ProjectAPIPermissionTestBase" --type-add 'python:*.py' --type python

Length of output: 3517

backend/cases_qc/tests/test_permissions_api.py (3)

35-35: LGTM! Consistent change across test classes.

The base class has been correctly updated to ProjectAPIPermissionTestBase, maintaining consistency with the previous class modification and the import statement change.

This change ensures that both test classes in the file now use the same updated base class, which is a good practice for maintaining consistency and reducing potential issues related to different base class implementations.


Line range hint 1-62: Summary: Consistent update of test base classes

The changes in this file are part of a larger refactoring effort to standardize the testing framework. Both test classes now inherit from ProjectAPIPermissionTestBase instead of TestProjectAPIPermissionBase. This update maintains consistency across the file and likely across the entire project.

Key points:

  1. The import statement has been updated to reflect the new base class.
  2. Both TestCaseQcRetrieveApiView and TestVarfishStatsRetrieveApiView now use the new base class.
  3. The test methods remain unchanged, suggesting backwards compatibility of the new base class.

These changes should improve code consistency and potentially enable new features or optimizations in the testing framework. However, it's crucial to ensure that these changes are applied consistently across the entire project and that all tests still function as expected with the new base class.

To ensure the changes have been applied consistently and haven't introduced any regressions, consider running the following:

  1. The full test suite for this module.
  2. Any integration tests that might be affected by changes in the permission testing framework.
  3. A project-wide search for any remaining uses of TestProjectAPIPermissionBase to ensure complete migration.

7-7: LGTM! Verify base class functionality.

The base class has been correctly updated to ProjectAPIPermissionTestBase, which is consistent with the import statement change. This modification likely reflects an update in the project's testing framework.

To ensure that the new base class maintains the expected functionality, run the following script:

frontend/src/variants/components/QueryPresets/SetProperties.vue (2)

64-65: LGTM: Improved formatting for checkbox input

The changes to the checkbox input improve code readability by placing the class and type attributes on separate lines. This formatting change aligns with best practices for template readability in Vue components.


Line range hint 1-85: Overall assessment: Positive formatting improvements

The changes in this file are minimal and focus on improving the formatting of the checkbox input in the template section. These changes enhance code readability without altering the component's functionality. The script and style sections remain unchanged, and the overall structure of the component adheres to Vue 3 best practices.

backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (4)

17-26: LGTM! Well-structured ForeignKey definition.

The changes to the bg_job field in the buildbackgroundsvsetjob model are well-implemented:

  1. The CASCADE deletion policy ensures data integrity by removing related objects when a background job is deleted.
  2. The dynamic related_name using %(app_label)s_%(class)s_related prevents naming conflicts and follows Django best practices.
  3. The help text provides clear information about the field's purpose.

27-36: LGTM! Consistent field definition.

The changes to the bg_job field in the cleanupbackgroundsvsetjob model are identical to the previous model, which is excellent for maintaining consistency across related models. This approach:

  1. Ensures uniform behavior for background job relationships.
  2. Simplifies code maintenance and understanding.

47-58: LGTM! Well-designed user reference field.

The changes to the user field in the svquery model are well-implemented:

  1. The SET_NULL deletion policy allows queries to persist even if the associated user is deleted, which is often desirable for maintaining historical data.
  2. Allowing null and blank values provides flexibility in cases where a query might not always be associated with a user.
  3. The dynamic related_name using %(app_label)s_%(class)s_related prevents naming conflicts and is consistent with the other fields in this migration.
  4. The help text clearly describes the field's purpose.

These choices demonstrate good Django practices and thoughtful database design.


1-59: Excellent migration file with consistent and well-structured changes.

This migration file demonstrates a systematic approach to updating multiple models with consistent and well-thought-out changes. Key points:

  1. Consistent use of dynamic related_name across all modified fields.
  2. Appropriate on_delete behaviors chosen for each field (CASCADE for job-related fields, SET_NULL for user reference).
  3. Clear and helpful text descriptions for all fields.

These changes will likely improve the overall database schema consistency and make future development and maintenance easier. The systematic nature of the changes suggests this is part of a larger effort to standardize the codebase, which is commendable.

backend/beaconsite/urls.py (3)

4-4: LGTM: Updated import statement

The change from django.conf.urls to django.urls is correct and aligns with Django's current best practices for URL configuration.


69-84: LGTM: Consistent improvements in ajax and API URL patterns

The changes to ajax_urlpatterns and beacon_api_urlpatterns are well-implemented and consistent with the improvements made to ui_urlpatterns:

  • Replaced url() with path() for all patterns.
  • Used <uuid:parameter_name> for UUID patterns.
  • Added a trailing slash to the beacon API query endpoint for consistency.

These changes enhance the overall readability and maintainability of the URL configuration.


Line range hint 1-89: Overall: Excellent upgrade to Django's modern URL configuration

This update significantly improves the URL configuration for the beaconsite app:

  1. Consistently replaced url() with path() throughout the file.
  2. Simplified regex patterns to use more readable and maintainable path converters.
  3. Standardized UUID pattern usage with <uuid:parameter_name> syntax.
  4. Improved consistency in the use of trailing slashes.

These changes align with Django's best practices, enhancing code readability and maintainability. The transition to path() also future-proofs the code against potential deprecations of the url() function.

Great job on this upgrade! The code is now more robust and easier to understand.

backend/genepanels/urls.py (4)

4-4: LGTM: Import statement updated correctly.

The change from url to path is in line with Django's best practices. This update sets the stage for the rest of the file's changes and is implemented correctly.


11-72: Excellent update to UI URL patterns using path().

The changes to the UI URL patterns are well-implemented:

  1. All url() functions have been correctly replaced with path().
  2. Complex regex patterns have been simplified to more readable string patterns.
  3. UUID parameters now use the <uuid:parameter_name> syntax, which is cleaner and type-safe.

These updates improve code readability and maintainability while adhering to Django's recommended practices.


79-87: API URL patterns successfully updated to use path().

The API URL patterns have been correctly updated to use the path() function, maintaining consistency with the UI URL pattern changes. This ensures that the entire urls.py file follows the same modern Django URL configuration style.


Line range hint 1-90: Overall excellent update to Django URL configurations.

This change successfully modernizes the URL configurations for the genepanels app:

  1. All url() functions have been replaced with path().
  2. URL patterns are now more readable and maintainable.
  3. The use of <uuid:parameter_name> for UUID fields improves type safety.
  4. The changes are consistent across both UI and API URL patterns.

These updates align with Django's best practices and should make future maintenance easier. Great job on implementing these changes comprehensively and correctly!

backend/Pipfile (9)

18-18: LGTM: django-plugins-bihealth version update

The update from ~=0.4.0 to ~=0.5.2 is a minor version bump, which should maintain backwards compatibility. This update likely includes new features and bug fixes that could benefit the project.


24-24: LGTM: drf-keyed-list-bihealth version update

The update from ~=0.1.1 to ~=0.2.1 is a minor version bump, which should maintain backwards compatibility. This update likely includes new features and bug fixes that could benefit the project.


Line range hint 1-113: Summary of Pipfile changes

The updates in this Pipfile reflect a significant upgrade process, particularly focusing on the sodar core v1 upgrade. Key points:

  1. Several packages have been updated to newer versions, including major updates like django-sodar-core.
  2. New packages have been added, such as djangorestframework and typing-extensions.
  3. The required Python version has been bumped to 3.11.

These changes are generally positive, bringing in new features and bug fixes. However, given the scope of the changes, it's crucial to:

  1. Thoroughly test the application to ensure all functionality works as expected with the new package versions.
  2. Review the changelogs of major version bumps (like django-sodar-core) for any breaking changes or new features that need to be implemented.
  3. Ensure all development and deployment environments are updated to support Python 3.11.
  4. Run a comprehensive test suite to catch any potential issues introduced by these dependency updates.

10-10: LGTM: beautifulsoup4 version update

The update from ~=4.9 to ~=4.12.3 is a significant version jump. While beautifulsoup4 generally maintains good backwards compatibility, it's advisable to verify that this update doesn't introduce any breaking changes in your codebase.

#!/bin/bash
# Description: Check for any usage of deprecated or changed beautifulsoup4 features

# Test: Search for BeautifulSoup usage
echo "Checking BeautifulSoup usage:"
rg --type python 'BeautifulSoup'

# Test: Search for specific methods that might have changed
echo "Checking for potentially affected methods:"
rg --type python 'find_all|select|select_one'

22-22: Verify necessity and compatibility of djangorestframework

The addition of djangorestframework ~=3.15 suggests new REST API functionality or a requirement of the upgraded django-sodar-core. While this is a widely used and robust package, please ensure that:

  1. This dependency is indeed necessary for the project.
  2. It doesn't conflict with any existing packages or functionality.
  3. If it's a new requirement of django-sodar-core, it's being used correctly as per their documentation.
#!/bin/bash
# Description: Check for potential conflicts or unnecessary imports with djangorestframework

# Test: Search for existing REST framework imports that might conflict
echo "Checking for existing REST framework imports:"
rg --type python 'from\s+rest_framework\s+import'

# Test: Search for new uses of djangorestframework
echo "Checking for new djangorestframework usage:"
rg --type python 'APIView|viewsets\.ModelViewSet|serializers\.ModelSerializer'

100-100: Verify compatibility of django-auth-ldap update

The update from ~=4.1 to ~=4.6 for django-auth-ldap is a minor version bump, which should maintain backwards compatibility. However, given that LDAP authentication is a critical security component, please ensure that:

  1. You've reviewed the changelog for any security-related updates or changes.
  2. All LDAP authentication functionality in your application still works as expected after this update.
  3. Any new features or changes in this version are properly configured if needed.
#!/bin/bash
# Description: Check for django-auth-ldap usage and potential security implications

# Test: Search for django-auth-ldap imports and usage
echo "Checking django-auth-ldap usage:"
rg --type python 'from\s+django_auth_ldap\s+import|LDAPBackend'

# Test: Search for LDAP configuration in settings
echo "Checking LDAP configuration in settings:"
rg --type python 'AUTH_LDAP_SERVER_URI|AUTH_LDAP_BIND_DN|AUTH_LDAP_USER_SEARCH'

113-113: Verify compatibility with Python 3.11

Updating the required Python version from 3.10 to 3.11 can bring performance improvements and new language features. However, please ensure that:

  1. All project dependencies are compatible with Python 3.11.
  2. Development and deployment environments are updated to support Python 3.11.
  3. Any Python 3.11-specific features used in the codebase are properly documented.
  4. CI/CD pipelines are updated to use Python 3.11.
#!/bin/bash
# Description: Check for Python 3.11 compatibility issues

# Test: Search for use of deprecated features or syntax that might have changed in 3.11
echo "Checking for potential Python 3.11 compatibility issues:"
rg --type python 'collections\.Callable|asyncio\.coroutine|imp\.'

# Test: Check if there are any Python version checks in the code
echo "Checking for Python version checks:"
rg --type python 'sys\.version_info'

19-19: Verify compatibility with django-sodar-core v1.0.2

The update from ~=0.13.4 to ~=1.0.2 is a major version bump, which aligns with the PR objective of upgrading to sodar core v1. This update likely introduces significant changes and improvements. However, it may also include breaking changes.

Please ensure that:

  1. You've reviewed the changelog for any breaking changes.
  2. All affected parts of the codebase have been updated accordingly.
  3. All tests pass after this upgrade.

55-55: Pin version for typing-extensions and verify necessity

The addition of typing-extensions is noted. However, there are two points to consider:

  1. Version pinning: Using * for the version can lead to unexpected breaking changes in the future. It's recommended to pin this to a specific version, e.g., ~=4.7.1 (latest stable version as of my knowledge cutoff).

  2. Necessity: Given that the project is now using Python 3.11, which includes many typing features, verify if typing-extensions is still necessary. It might have been added as a dependency of another package, in which case it can be left as is.

Consider updating the line to:

typing-extensions = "~=4.7.1"

Also, please verify the necessity of this package given the Python 3.11 upgrade.

utils/docker/docker-entrypoint.sh (1)

63-65: Approve changes with suggestions for improvement

The addition of drop_variant_summary and create_variant_summary commands improves the migration process by ensuring the variant summary is always in sync with the latest database schema. However, consider the following suggestions:

  1. Add error handling to prevent the script from continuing if these commands fail. For example:
python manage.py drop_variant_summary || { echo "Failed to drop variant summary"; exit 1; }
python manage.py migrate || { echo "Failed to apply migrations"; exit 1; }
python manage.py create_variant_summary || { echo "Failed to create variant summary"; exit 1; }
  1. Consider adding conditional execution for these commands, especially for drop_variant_summary, to prevent accidental data loss:
if [ "$RESET_VARIANT_SUMMARY" = "true" ]; then
    python manage.py drop_variant_summary
fi
  1. Add comments explaining the purpose of these commands for future maintainers.

To verify the impact of these changes on the deployment process, run the following script:

This script will help quantify the impact of these new commands on the overall deployment time.

frontend/src/varfish/components/FilterForm/DevPane.vue (3)

70-72: LGTM! Improved textarea functionality and readability.

The changes to the textarea element are well-implemented:

  1. Separating attributes onto different lines improves readability.
  2. The addition of the :readonly attribute with !editSettingsRef binding allows for dynamic toggling of the editable state, which aligns with the toggleEditMode function in the script section.

These changes enhance both the code structure and component functionality.


90-90: LGTM! Enhanced interactivity with toggleEditMode.

The addition of the @click event binding to the toggleEditMode method is a good improvement:

  1. It adds necessary interactivity to the input element.
  2. This change works in conjunction with the :readonly attribute added to the textarea and the toggleEditMode method in the script section.
  3. The implementation creates a cohesive user experience for toggling between view and edit modes.

This modification effectively completes the edit mode toggle functionality.


Line range hint 1-101: Overall assessment: Improvements with minor suggestion.

The changes in this file generally improve the component's functionality and readability:

  1. The textarea now supports dynamic toggling between editable and read-only states.
  2. The input element correctly triggers the edit mode toggle.
  3. Code readability has been enhanced by separating attributes onto different lines.

There's one minor unnecessary change (the input id modification) that could be reverted for consistency. However, this doesn't affect the component's functionality.

Recommendation: Proceed with these changes, considering the suggestion to revert the unnecessary input id modification.

backend/cohorts/urls.py (15)

4-4: LGTM: Updated import for modern Django URL routing.

The change from url to path is in line with Django's recommended practices for URL routing. This update improves readability and maintainability of URL patterns.


10-14: LGTM: Improved URL pattern for EntrypointView.

The update to use path() with the <uuid:project> path converter is a good improvement:

  1. It's more readable than the previous regex pattern.
  2. It ensures type safety by explicitly specifying uuid for the project parameter.
  3. It maintains the same functionality as before.

This change aligns well with Django's modern URL routing practices.


18-22: LGTM: Updated URL pattern for CohortListCreateAjaxView.

The change to path() with <uuid:project> improves readability and type safety while maintaining the same functionality. This is consistent with the updates seen in other parts of the file.


23-27: LGTM: Updated URL pattern for CohortRetrieveUpdateDestroyAjaxView.

This change follows the same pattern as previous updates, replacing url() with path() and simplifying the regex to <uuid:cohort>. It maintains consistency across the file while improving readability and type safety.


28-32: LGTM: Updated URL pattern for CohortCaseCreateAjaxView.

This change is consistent with the previous updates, using path() with <uuid:project>. It maintains the same functionality while improving readability and type safety.


33-37: LGTM: Updated URL pattern for CohortCaseListAjaxView.

This change follows the established pattern, replacing url() with path() and using <uuid:cohort>. It's consistent with other changes and improves code readability.


38-42: LGTM: Updated URL pattern for CohortCaseDestroyAjaxView.

This change maintains consistency with previous updates, using path() with <uuid:cohortcase>. It improves code readability and type safety while keeping the same functionality.


43-47: LGTM: Updated URL pattern for AccessibleProjectsCasesAjaxView.

This change follows the same pattern as previous updates, replacing url() with path() and simplifying the regex to <uuid:project>. It maintains consistency and improves code readability.


48-52: LGTM: Updated URL pattern for ProjectUserPermissionsAjaxView.

This change is consistent with the previous updates, using path() with <uuid:project>. It maintains the same functionality while improving readability and type safety.


56-60: LGTM: Updated URL pattern for CohortListCreateApiView.

This change in the API URL patterns follows the same approach as seen in the UI and AJAX patterns. It replaces url() with path() and uses <uuid:project>, improving consistency and readability across the entire file.


61-65: LGTM: Updated URL pattern for CohortRetrieveUpdateDestroyApiView.

This change maintains consistency with previous updates, using path() with <uuid:cohort>. It improves code readability and type safety while keeping the same functionality for the API endpoint.


66-70: LGTM: Updated URL pattern for CohortCaseCreateApiView.

This change follows the established pattern, replacing url() with path() and using <uuid:project>. It's consistent with other changes and improves code readability for the API endpoint.


71-75: LGTM: Updated URL pattern for CohortCaseListApiView.

This change is consistent with the previous updates, using path() with <uuid:cohort>. It maintains the same functionality while improving readability and type safety for the API endpoint.


76-80: LGTM: Updated URL pattern for CohortCaseDestroyApiView.

This change follows the same pattern as previous updates, replacing url() with path() and simplifying the regex to <uuid:cohortcase>. It maintains consistency and improves code readability for the API endpoint.


81-85: LGTM: Updated URL pattern for AccessibleProjectsCasesApiView and overall file improvements.

This final change in the API URL patterns is consistent with all previous updates, using path() with <uuid:project>.

Overall, the changes in this file represent a significant improvement:

  1. All URL patterns now use the modern path() function instead of the deprecated url().
  2. The use of path converters (<uuid:...>) improves type safety and readability.
  3. The changes are consistent across UI, AJAX, and API URL patterns.
  4. The functionality of all views remains unchanged, ensuring backward compatibility.

These updates align with Django's best practices for URL routing and will make the codebase easier to maintain and understand.

backend/beaconsite/tests/test_permissions.py (5)

2-2: LGTM: Import statement updated correctly.

The import statement has been updated to use ProjectPermissionTestBase, which is consistent with the changes in the test classes.


34-34: LGTM: Base class updated correctly. Verify all test methods.

The base class for TestConsortiumViews has been updated to ProjectPermissionTestBase, which is consistent with the previous changes.

To ensure full compatibility and that all test methods work as expected with the new base class, please run the following command:

#!/bin/bash
# Run tests for TestConsortiumViews
python manage.py test beaconsite.tests.test_permissions.TestConsortiumViews

62-62: LGTM: Base class updated correctly. Verify all site-related tests.

The base class for TestSiteViews has been updated to ProjectPermissionTestBase, which is consistent with the previous changes in this file.

To ensure full compatibility and that all site-related test methods work as expected with the new base class, please run the following command:

#!/bin/bash
# Run tests for TestSiteViews
python manage.py test beaconsite.tests.test_permissions.TestSiteViews

Line range hint 1-82: Summary: Base class updates look good. Verify overall test suite compatibility.

The changes in this file consistently update the base class from TestProjectPermissionBase to ProjectPermissionTestBase for all test classes. This update appears to be part of a larger refactoring effort to standardize permission testing across the project.

While the changes look good and are consistent, it's crucial to ensure that the new base class provides all the necessary functionality for these tests.

To verify the overall compatibility of these changes with the entire test suite, please run the following command:

#!/bin/bash
# Run all tests in the beaconsite app
python manage.py test beaconsite

# If you want to focus only on permission-related tests, you can use:
# python manage.py test beaconsite.tests.test_permissions

This will help ensure that the base class change doesn't introduce any unexpected issues in the test suite.


27-27: LGTM: Base class updated correctly. Verify compatibility.

The base class for TestIndexView has been updated to ProjectPermissionTestBase, which is consistent with the import statement change.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:

backend/importer/urls.py (10)

4-4: LGTM: Updated import statement for Django URL routing.

The change from url() to path() is in line with Django's current best practices for URL routing.


11-16: LGTM: Updated UI URL patterns to use path() function.

The changes to ui_urlpatterns correctly implement the path() function with UUID path converters. This improves readability while maintaining the same functionality.


20-29: LGTM: Updated case import info API URL patterns.

The changes to case import info URL patterns correctly implement the path() function with UUID path converters. This improves readability and type safety while maintaining the same functionality.


30-39: LGTM: Updated variant set import info API URL patterns.

The changes to variant set import info URL patterns correctly implement the path() function with UUID path converters. This improves readability and type safety while maintaining the same functionality.


40-49: LGTM: Updated BAM QC file API URL patterns.

The changes to BAM QC file URL patterns correctly implement the path() function with UUID path converters. This improves readability and type safety while maintaining the same functionality.


50-59: LGTM: Updated case gene annotation file API URL patterns.

The changes to case gene annotation file URL patterns correctly implement the path() function with UUID path converters. This improves readability and type safety while maintaining the same functionality.


60-69: LGTM: Updated genotype file API URL patterns.

The changes to genotype file URL patterns correctly implement the path() function with UUID path converters. This improves readability and type safety while maintaining the same functionality.


70-79: LGTM: Updated effects file API URL patterns.

The changes to effects file URL patterns correctly implement the path() function with UUID path converters. This improves readability and type safety while maintaining the same functionality.


80-89: LGTM: Updated database info file API URL patterns.

The changes to database info file URL patterns correctly implement the path() function with UUID path converters. This improves readability and type safety while maintaining the same functionality.


Line range hint 1-92: Overall assessment: Excellent update to modern Django URL routing.

The changes in this file consistently update all URL patterns to use the path() function instead of the deprecated url() function. The use of UUID path converters improves type safety and readability. These changes align with Django's current best practices for URL routing while maintaining the same functionality.

Key improvements:

  1. Consistent use of path() function across all URL patterns.
  2. Improved readability with UUID path converters instead of regex patterns.
  3. Enhanced type safety for URL parameters.
  4. Maintained functionality and structure of the URL configuration.

These changes will make the codebase more maintainable and align it with modern Django practices.

backend/beaconsite/tests/test_permissions_ajax.py (2)

60-60: LGTM! Consider verifying test coverage.

The update to use ProjectAPIPermissionTestBase as the base class is correct and consistent with the changes made to the TestOrganisationAjaxViews class. This change aligns with the PR objectives and the larger refactoring effort.

To ensure that the change hasn't inadvertently affected test coverage, run the following script:

#!/bin/bash
# Description: Check test coverage for beaconsite app

# Test: Run tests and generate coverage report
echo "Running tests and generating coverage report for beaconsite app:"
coverage run --source='./backend/beaconsite' manage.py test beaconsite
coverage report

# Test: Check for any failing tests
echo "Checking for any failing tests in beaconsite app:"
python manage.py test beaconsite

11-11: LGTM! Verify consistency across the codebase.

The update to use ProjectAPIPermissionTestBase as the base class is correct and aligns with the PR objectives. This change appears to be part of a larger refactoring effort to standardize test base classes.

To ensure consistency across the codebase, run the following script:

✅ Verification successful

Verified: No remaining usage of TestProjectAPIPermissionBase and ProjectAPIPermissionTestBase is consistently used across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of TestProjectAPIPermissionBase

# Test: Search for TestProjectAPIPermissionBase usage
echo "Checking for any remaining usage of TestProjectAPIPermissionBase:"
rg --type python "class.*\(TestProjectAPIPermissionBase\)"

# Test: Verify consistent usage of ProjectAPIPermissionTestBase
echo "Verifying consistent usage of ProjectAPIPermissionTestBase:"
rg --type python "class.*\(ProjectAPIPermissionTestBase\)"

Length of output: 693


Script:

#!/bin/bash
# Description: Verify the usage of TestProjectAPIPermissionBase and ProjectAPIPermissionTestBase in the codebase.

echo "Checking for any remaining usage of TestProjectAPIPermissionBase:"
rg --type python "class\s+TestProjectAPIPermissionBase\b"

echo "Verifying consistent usage of ProjectAPIPermissionTestBase:"
rg --type python "class\s+ProjectAPIPermissionTestBase\b"

Length of output: 451


Script:

#!/bin/bash
# Description: Verify the usage of TestProjectAPIPermissionBase and ProjectAPIPermissionTestBase in the codebase.

echo "Checking for any remaining usage of TestProjectAPIPermissionBase:"
rg -g "*.py" "class\s+TestProjectAPIPermissionBase\b"

echo "Verifying consistent usage of ProjectAPIPermissionTestBase:"
rg -g "*.py" "class\s+ProjectAPIPermissionTestBase\b"

Length of output: 381

frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4)

64-64: LGTM: Improved template formatting

The change improves the readability of the TheAppBar component by placing the v-model:show-left-panel directive on a separate line. This is a good practice for maintaining clean and easily scannable Vue templates.


Line range hint 78-91: LGTM: Improved attribute ordering consistency

The changes in the v-list-subheader elements improve the consistency of the template by placing the v-if directive before the class attribute. This aligns better with Vue.js style guides and makes the template more uniform.


117-118: LGTM: Improved prop ordering in SvFilterApp component

The changes in the SvFilterApp component improve the structure of the template by moving the project-uuid and case-uuid props after the v-model directives. This ordering is more consistent with Vue.js best practices, placing reactive bindings first followed by static props. It enhances the readability and maintainability of the component.


Line range hint 64-118: Summary: Improved template structure and consistency

The changes in this file are primarily formatting and structure improvements that enhance the readability and consistency of the Vue template. Key improvements include:

  1. Better formatting of the TheAppBar component props.
  2. Consistent ordering of directives and attributes in v-list-subheader elements.
  3. Improved prop ordering in the SvFilterApp component, aligning with Vue.js best practices.

These changes contribute to a more maintainable and standardized codebase without introducing any functional modifications.

backend/genepanels/tests/test_permissions.py (3)

29-29: LGTM! Verify the impact of the base class change on test methods.

The class inheritance has been updated from TestProjectPermissionBase to ProjectPermissionTestBase, which is consistent with the import statement change.

To ensure this change doesn't affect the existing test methods, run the following command:

#!/bin/bash
# List all methods in ProjectPermissionTestBase
ast-grep --lang python --pattern $'class ProjectPermissionTestBase:
  $$$
  def $_($$):
    $$$
'

Compare the output with the methods used in TestGenepanelsView to ensure all required methods are still available and behave as expected.


Line range hint 30-96: Verify that inherited method behavior remains unchanged.

The test methods in TestGenepanelsView remain unchanged after the base class update. This suggests that ProjectPermissionTestBase provides a similar interface to the previous base class. However, it's crucial to ensure that the behavior of inherited methods, particularly self.assert_response, hasn't changed.

To verify the behavior of the assert_response method, run the following command:

#!/bin/bash
# Search for the definition of assert_response in ProjectPermissionTestBase
ast-grep --lang python --pattern $'class ProjectPermissionTestBase:
  $$$
  def assert_response($$$):
    $$$
'

Compare the output with the previous implementation to ensure the behavior is consistent. If there are significant differences, the test methods may need to be adjusted accordingly.


2-2: LGTM! Verify the base class change in the projectroles module.

The import statement has been updated to use ProjectPermissionTestBase instead of what was likely TestProjectPermissionBase. This change is consistent with the class inheritance modification.

To ensure this change is consistent across the project, run the following command:

If the command returns any results, those files may need to be updated as well.

backend/cases_analysis/tests/test_permissions_api.py (3)

2-2: LGTM: Import statement updated correctly.

The import statement has been updated to use ProjectAPIPermissionTestBase, which is consistent with the changes in the test class signatures. This change aligns with the PR objective of upgrading to sodar core v1.


55-55: LGTM: Class signature updated correctly, but there's a typo in the class name.

The TestCasenalysisSessionViewSet class now inherits from ProjectAPIPermissionTestBase, which is consistent with the import statement change and the previous class signature update. This change aligns with the PR objective of upgrading to sodar core v1.

However, there's a minor typo in the class name: "Casenalysis" should be "CaseAnalysis".

Consider fixing the typo in the class name:

-class TestCasenalysisSessionViewSet(ProjectAPIPermissionTestBase):
+class TestCaseAnalysisSessionViewSet(ProjectAPIPermissionTestBase):

To ensure full compatibility, please verify that all methods used from the base class are still available in ProjectAPIPermissionTestBase. Run the following command to check for any undefined attributes or methods:

#!/bin/bash
# Description: Check for potential compatibility issues with the new base class

# Test: Search for method calls that might be from the base class
rg --type python -g 'backend/cases_analysis/tests/test_permissions_api.py' '(self\.)(?!assert_response|setUp|case\b|caseanalysis\b|caseanalysissession\b)'

# Note: This script excludes known method calls (assert_response, setUp) and attributes (case, caseanalysis, caseanalysissession).
# Review the output to ensure all method calls are still valid with the new base class.

8-8: LGTM: Class signature updated correctly.

The TestCaseAnalysisViewSet class now inherits from ProjectAPIPermissionTestBase, which is consistent with the import statement change. This update aligns with the PR objective of upgrading to sodar core v1.

To ensure full compatibility, please verify that all methods used from the base class are still available in ProjectAPIPermissionTestBase. Run the following command to check for any undefined attributes or methods:

✅ Verification successful

LGTM: Class signature updated correctly.

The TestCaseAnalysisViewSet class now inherits from ProjectAPIPermissionTestBase, which is consistent with the import statement change. This update aligns with the PR objective of upgrading to sodar core v1. All method calls within the class are compatible with the new base class.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential compatibility issues with the new base class

# Test: Search for method calls that might be from the base class
rg --type python -g 'backend/cases_analysis/tests/test_permissions_api.py' '(self\.)(?!assert_response|setUp|case\b)'

# Note: This script excludes known method calls (assert_response, setUp) and the 'case' attribute.
# Review the output to ensure all method calls are still valid with the new base class.

Length of output: 443


Script:

#!/bin/bash
# Description: Check for potential compatibility issues with the new base class without using look-around

# Find all 'self.' method calls in the specified file and exclude known methods
rg --type python -g 'backend/cases_analysis/tests/test_permissions_api.py' 'self\.\w+' | grep -vE 'self\.(assert_response|setUp|case|caseanalysis|caseanalysissession)'

Length of output: 198


Script:

#!/bin/bash
# Description: Check for potential compatibility issues with the new base class without using --type

# Find all 'self.' method calls in the specified file and exclude known methods
rg 'self\.\w+' 'backend/cases_analysis/tests/test_permissions_api.py' | grep -vE 'self\.(assert_response|setUp|case|caseanalysis|caseanalysissession)'

Length of output: 1168

backend/Makefile (3)

112-114: LGTM: New internal target for makemigrations

The new _makemigrations target is a clean wrapper around the Django makemigrations command. This separation of concerns is good practice, allowing for potential future customization of the migration process.


116-117: Excellent: New public target combining migrations and formatting

The new makemigrations target is a well-designed addition. By depending on both _makemigrations and format, it ensures that:

  1. Migrations are generated correctly.
  2. All code, including newly generated migration files, is properly formatted.

This approach promotes code consistency and reduces the chance of formatting-related issues in pull requests.


112-121: Overall: Improved organization and clarity of migration tasks

The changes to the Makefile have significantly improved the organization and clarity of migration-related tasks:

  1. Introduction of _makemigrations as an internal target.
  2. Creation of a public makemigrations target that combines migration generation with formatting.
  3. Simplification of the migrate target.

These changes promote better code organization, ensure consistent formatting, and simplify the migration workflow. The new structure provides a clear separation between internal and public targets, which is a good practice in Makefile design.

Consider the suggestion to add a dependency between migrate and makemigrations to further improve the workflow consistency.

Great job on these improvements!

backend/varannos/tests/test_permissions_api.py (3)

Line range hint 1-150: Ensure comprehensive testing after base class change.

The changes to the import statement and class inheritance appear to be part of a larger refactoring effort to improve naming conventions. While the core functionality of the tests remains intact, it's crucial to verify that the new base class ProjectAPIPermissionTestBase provides all the necessary setup and teardown methods that these tests depend on.

To ensure that the changes haven't introduced any regressions, please run the following:

  1. Execute the entire test suite for the varannos app:
#!/bin/bash
# Description: Run the test suite for the varannos app

# Test: Run the tests for the varannos app. Expect: All tests to pass.
python manage.py test varannos
  1. If possible, run the entire project test suite to catch any potential side effects:
#!/bin/bash
# Description: Run the entire project test suite

# Test: Run all tests for the project. Expect: All tests to pass.
python manage.py test
  1. Check for any custom setup or teardown methods in the old base class that might need to be migrated:
#!/bin/bash
# Description: Check for custom setup or teardown methods in the old base class

# Test: Search for setUp or tearDown methods in the old base class. Expect: No results or carefully review any findings.
rg --type python "class TestProjectAPIPermissionBase\(.*\):(\n|.)*?def (setUp|tearDown)"

Please review the results of these tests and checks to ensure that the base class change hasn't introduced any unintended consequences.


8-8: LGTM! Verify the base class usage across the codebase.

The class inheritance has been updated to use ProjectAPIPermissionTestBase, which is consistent with the import statement change. The rest of the class implementation remains unchanged, suggesting that the new base class maintains the same interface and functionality.

To ensure consistency across the codebase, please run the following script to check for any remaining occurrences of the old base class:

#!/bin/bash
# Description: Check for any remaining occurrences of the old base class

# Test: Search for classes inheriting from the old base class. Expect: No results.
rg --type python "class \w+\(TestProjectAPIPermissionBase\):"

# Test: Search for classes inheriting from the new base class. Expect: At least one result (this file).
rg --type python "class \w+\(ProjectAPIPermissionTestBase\):"

2-2: LGTM! Verify the import change across the codebase.

The import statement has been updated to use ProjectAPIPermissionTestBase, which is a more descriptive name and follows better naming conventions. This change is consistent with the class inheritance update.

To ensure consistency across the codebase, please run the following script to check for any remaining occurrences of the old import:

✅ Verification successful

Import change successfully verified across the codebase. No instances of the old import remain, and the new import is consistently applied in all relevant files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining occurrences of the old import statement

# Test: Search for the old import statement. Expect: No results.
rg --type python "from projectroles.tests.test_permissions_api import TestProjectAPIPermissionBase"

# Test: Search for the new import statement. Expect: At least one result (this file).
rg --type python "from projectroles.tests.test_permissions_api import ProjectAPIPermissionTestBase"

Length of output: 283


Script:

#!/bin/bash
# Description: Check for any remaining occurrences of the old import statement

# Test: Search for the old import statement. Expect: No results.
rg 'from projectroles\.tests\.test_permissions_api import TestProjectAPIPermissionBase' --type py

# Test: Search for the new import statement. Expect: At least one result (this file).
rg 'from projectroles\.tests\.test_permissions_api import ProjectAPIPermissionTestBase' --type py

Length of output: 3014

backend/svs/urls.py (24)

2-2: LGTM: Updated import statement for modern Django URL routing

The change from url to path and re_path is appropriate and aligns with Django's modern URL routing practices.


11-15: LGTM: Improved URL pattern for import job detail view

The transition from url() to path() with UUID path converters enhances readability and type safety. This change is in line with Django best practices.


16-20: LGTM: Consistent URL pattern update for build background SV set job detail view

The change to path() with UUID converter maintains consistency with the previous update and improves the overall URL pattern structure.


21-25: LGTM: Consistent URL pattern updates across job detail views

The change to path() with UUID converter for the cleanup background SV set job detail view completes the consistent update across all job detail views. This uniformity enhances code maintainability.


29-33: LGTM: Improved URL pattern for SV fetch variants AJAX view

The transition to path() with UUID converter for the SV fetch variants AJAX view maintains consistency with previous changes and enhances readability.


34-38: LGTM: Updated URL pattern for SV quick presets AJAX view

The change to path() for the SV quick presets AJAX view is appropriate and consistent with the overall update strategy. The absence of path converters is correct for this URL pattern.


39-43: LGTM: Improved URL pattern for SV category presets API view

The transition to path() with a string converter for the category parameter in the SV category presets API view is appropriate and consistent with the overall update strategy.


44-48: LGTM: Updated URL pattern for SV inheritance presets API view

The change to path() with UUID converter for the SV inheritance presets API view maintains consistency with previous updates and improves type safety for the case parameter.


50-54: LGTM: Consistent URL pattern update for SV query settings shortcut AJAX view

The transition to path() with UUID converter for the SV query settings shortcut AJAX view maintains consistency with previous changes and enhances type safety for the case parameter.


56-60: LGTM: Updated URL pattern for SV query list create AJAX view

The change to path() with UUID converter for the SV query list create AJAX view is consistent with previous updates and improves type safety for the case parameter.


61-65: LGTM: Improved URL pattern for SV query retrieve update destroy AJAX view

The transition to path() with UUID converter for the SV query retrieve update destroy AJAX view maintains consistency with previous changes and enhances type safety for the svquery parameter.


66-70: LGTM: Updated URL pattern for SV query result set list AJAX view

The change to path() with UUID converter for the SV query result set list AJAX view is consistent with previous updates and improves type safety for the svquery parameter.


71-75: LGTM: Consistent URL pattern update for SV query result set retrieve AJAX view

The transition to path() with UUID converter for the SV query result set retrieve AJAX view maintains consistency with previous changes and enhances type safety for the svqueryresultset parameter.


76-80: LGTM: Updated URL pattern for SV query result row list AJAX view

The change to path() with UUID converter for the SV query result row list AJAX view is consistent with previous updates and improves type safety for the svqueryresultset parameter.


81-85: LGTM: Improved URL pattern for SV query result row retrieve AJAX view

The transition to path() with UUID converter for the SV query result row retrieve AJAX view maintains consistency with previous changes and enhances type safety for the svqueryresultrow parameter.


87-91: LGTM: Updated URL pattern for structural variant flags list create AJAX view

The change to path() with UUID converter for the structural variant flags list create AJAX view is consistent with previous updates and improves type safety for the case parameter.


92-96: LGTM: Consistent URL pattern update for structural variant flags list project AJAX view

The transition to path() with UUID converter for the structural variant flags list project AJAX view maintains consistency with previous changes and enhances type safety for the project parameter.


97-101: LGTM: Updated URL pattern for structural variant flags retrieve update destroy AJAX view

The change to path() with UUID converter for the structural variant flags retrieve update destroy AJAX view is consistent with previous updates and improves type safety for the structuralvariantflags parameter.


102-106: LGTM: Improved URL pattern for structural variant comment list create AJAX view

The transition to path() with UUID converter for the structural variant comment list create AJAX view maintains consistency with previous changes and enhances type safety for the case parameter.


107-111: LGTM: Updated URL pattern for structural variant comment list project AJAX view

The change to path() with UUID converter for the structural variant comment list project AJAX view is consistent with previous updates and improves type safety for the project parameter.


112-116: LGTM: Consistent URL pattern update for structural variant comment retrieve update destroy AJAX view

The transition to path() with UUID converter for the structural variant comment retrieve update destroy AJAX view maintains consistency with previous changes and enhances type safety for the structuralvariantcomment parameter.


133-139: LGTM: Updated URL pattern for worker proxy view

The change to re_path() for the worker proxy view is appropriate as it maintains the necessary regex pattern while aligning with Django's modern URL routing practices.


Line range hint 140-146: LGTM: Consistent URL pattern update for tracks proxy view

The transition to re_path() for the tracks proxy view maintains the necessary regex pattern while aligning with Django's modern URL routing practices, consistent with the previous proxy view update.


Line range hint 1-150: Overall: Excellent update to modern Django URL routing

The changes in this file represent a comprehensive update from Django's deprecated url() function to the modern path() and re_path() functions. This transition offers several benefits:

  1. Improved readability: The use of path converters (e.g., <uuid:project>) makes the URL patterns more intuitive and self-documenting.
  2. Enhanced type safety: Path converters provide built-in type checking, reducing the likelihood of runtime errors due to incorrect URL parameter types.
  3. Consistency: The changes have been applied uniformly across all URL patterns, maintaining a consistent style throughout the file.
  4. Best practices: These updates align the codebase with current Django best practices for URL routing.

The careful preservation of existing view configurations and the appropriate use of re_path() for patterns requiring regex ensure that the functionality remains unchanged while benefiting from the improved syntax.

This update significantly enhances the maintainability and robustness of the URL configuration.

backend/cases/urls.py (1)

7-11: LGTM: Modernized URL pattern definition

The update from url() to path() for the entrypoint view is a positive change, aligning with Django's current best practices. The use of the UUID converter (<uuid:project>) in the route ensures type safety for the project parameter.

backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (4)

1-14: LGTM: File structure and dependencies are correct.

The migration file follows Django's standard format. The necessary imports are present, and the dependencies are correctly specified, including the AUTH_USER_MODEL and the previous migration (0108_auto_20240807_0850).


17-96: Approved: Consistent and appropriate alterations to bg_job fields.

The changes to the bg_job fields across multiple models are consistent and follow best practices:

  1. All fields now use models.ForeignKey referencing bgjobs.backgroundjob.
  2. The on_delete=django.db.models.deletion.CASCADE ensures that when a background job is deleted, related objects are also removed, preventing orphaned records.
  3. The related_name="%(app_label)s_%(class)s_related" uses a dynamic format, which helps avoid naming conflicts in reverse relations.

These changes improve the consistency of the database schema and make it easier to manage background job relationships across the application.

Also applies to: 109-118, 131-140


97-108: Approved: Appropriate alterations to user fields in query models.

The changes to the user fields in ProjectCasesSmallVariantQuery and SmallVariantQuery models are well-designed:

  1. Both fields now use models.ForeignKey referencing the AUTH_USER_MODEL.
  2. The on_delete=django.db.models.deletion.SET_NULL ensures that when a user is deleted, the related queries are preserved with a null user reference.
  3. Setting null=True and blank=True allows these fields to be optional, which is useful for scenarios where a query might not be associated with a specific user.
  4. The related_name uses the same dynamic format as the bg_job fields, maintaining consistency.

These changes improve data integrity and flexibility in managing user-query relationships.

Also applies to: 119-130


1-141: Summary: Well-structured migration improving model relationships and consistency.

This migration makes several important changes to the database schema:

  1. It standardizes the bg_job field across multiple background job models, ensuring consistent relationships with the bgjobs.backgroundjob model.
  2. It updates the user field in query models to allow for optional user associations and proper handling of user deletions.

These changes likely improve the overall database structure and relationships between models. The migration follows Django best practices, using appropriate on_delete behaviors and dynamic related_name attributes to avoid conflicts.

Developers should be aware that this migration might require corresponding updates in the application code, particularly in areas dealing with background jobs and user queries. It's also important to ensure that any existing data is compatible with these changes, especially considering the new null=True and blank=True settings on user fields.

To ensure the changes are reflected in the models, please run the following command:

backend/variants/tests/helpers.py (3)

5-6: LGTM: Import statements updated correctly.

The import statements have been updated to reflect the new base class names for permission testing. This change aligns with the overall refactoring of the test classes.


34-34: LGTM: ApiViewTestBase updated to use new base class.

The ApiViewTestBase class has been updated to inherit from ProjectAPIPermissionTestBase, which is consistent with the changes in the import statements and aligns with the overall refactoring of test classes.


47-47: LGTM: ViewTestBase updated to use new base class.

The ViewTestBase class has been updated to inherit from ProjectPermissionTestBase, which is consistent with the changes in the import statements and aligns with the overall refactoring of test classes.

backend/cases_import/tests/test_permissions_api.py (2)

8-16: Overall impact: Refactoring of test base classes.

The changes in this file reflect a broader refactoring effort to improve test class organization and naming conventions. The actual test logic and coverage remain unchanged, which is positive. To ensure consistency, it would be beneficial to verify that similar changes have been applied across all relevant test files in the project.

Let's verify the consistency of these changes across the project:

#!/bin/bash
# Search for any remaining occurrences of the old base class name
rg --type python "TestProjectAPIPermissionBase"

# Search for files that might need similar updates
rg --type python "class.*\(.*APIPermissionTest.*\):$" -g '!backend/cases_import/tests/test_permissions_api.py'

8-8: LGTM: Import statement updated to reflect new base class name.

The import statement has been updated to use ProjectAPIPermissionTestBase, which follows a more consistent naming convention. This change likely reflects a broader refactoring of test base classes across the project.

To ensure consistency across the project, let's verify if this new base class is used in other test files:

✅ Verification successful

Verified: Import statement change is consistent across the codebase.

The update to ProjectAPIPermissionTestBase has been applied uniformly across multiple test files, ensuring consistency in base class usage throughout the project. This change aligns with the broader refactoring efforts to standardize naming conventions, enhancing the maintainability and readability of the test suite.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of ProjectAPIPermissionTestBase
rg --type python "class.*\(ProjectAPIPermissionTestBase\)" -g '!backend/cases_import/tests/test_permissions_api.py'

Length of output: 222


Script:

#!/bin/bash
# Search for other occurrences of ProjectAPIPermissionTestBase in Python files
rg --type py "class\s+ProjectAPIPermissionTestBase" -g '!backend/cases_import/tests/test_permissions_api.py'

Length of output: 110


Script:

#!/bin/bash
# Broader search for any references to ProjectAPIPermissionTestBase in Python files
rg --type py "ProjectAPIPermissionTestBase" .

Length of output: 17251

backend/beaconsite/tests/test_permissions_api.py (3)

45-45: LGTM! Verify test coverage and behavior.

The base class change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase looks good. This change is consistent with the updated import statement.

To ensure that this change hasn't inadvertently affected the test behavior or coverage:

  1. Run the tests for this specific class:
python manage.py test backend.beaconsite.tests.test_permissions_api.TestBeaconInfoApiView
  1. Check the test coverage for this file:
coverage run manage.py test backend.beaconsite.tests.test_permissions_api
coverage report -m backend/beaconsite/tests/test_permissions_api.py

Please verify that all tests pass and the coverage remains unchanged or improves.


113-113: LGTM! Verify test coverage and behavior.

The base class change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the previous class modification and looks good.

To ensure that this change hasn't inadvertently affected the test behavior or coverage:

  1. Run the tests for this specific class:
python manage.py test backend.beaconsite.tests.test_permissions_api.TestBeaconQueryApiView
  1. Check the test coverage for this file (if not already done for the previous class):
coverage run manage.py test backend.beaconsite.tests.test_permissions_api
coverage report -m backend/beaconsite/tests/test_permissions_api.py

Please verify that all tests pass and the coverage remains unchanged or improves.


10-10: LGTM! Verify the import change project-wide.

The import statement has been updated to use ProjectAPIPermissionTestBase, which is consistent with the class inheritance changes. This change looks good.

To ensure consistency across the project, please run the following command to check for any remaining occurrences of TestProjectAPIPermissionBase:

backend/variants/urls/presets.py (9)

3-3: LGTM: Import statement updated correctly

The import statement has been correctly updated to use path from django.urls instead of url from django.conf.urls. This change aligns with Django's modern URL routing practices.


12-30: LGTM: FrequencyPresets URL patterns updated correctly

The FrequencyPresets URL patterns have been successfully updated to use the path() function. The changes include:

  1. Replacing regex patterns with UUID and slug converters.
  2. Maintaining the same view functions and URL names.

These updates improve code readability and provide better type safety for URL parameters. The consistent structure across all four patterns is commendable.


33-52: LGTM: FlagsEtcPresets URL patterns updated consistently

The FlagsEtcPresets URL patterns have been correctly updated to use the path() function, following the same structure as the FrequencyPresets patterns. This includes:

  1. Consistent use of UUID and slug converters.
  2. Preservation of view functions and URL names.

The uniformity in updates across different preset types enhances the overall code consistency and maintainability.


54-73: LGTM: ImpactPresets URL patterns updated consistently

The ImpactPresets URL patterns have been successfully updated to use the path() function, maintaining consistency with the previous preset types. Key points:

  1. Consistent use of UUID and slug converters.
  2. Preservation of view functions and URL names.

This continued consistency across different preset types reinforces the code's overall structure and readability.


75-94: LGTM: QualityPresets URL patterns updated consistently

The QualityPresets URL patterns have been correctly updated to use the path() function, following the established pattern:

  1. Consistent use of UUID and slug converters.
  2. Preservation of view functions and URL names.

This ongoing consistency across different preset types continues to enhance the code's structure and maintainability.


96-115: LGTM: ChromosomePresets URL patterns updated consistently

The ChromosomePresets URL patterns have been successfully updated to use the path() function, maintaining the established pattern:

  1. Consistent use of UUID and slug converters.
  2. Preservation of view functions and URL names.

This continued consistency across all preset types reinforces the code's overall structure and improves maintainability.


119-132: LGTM: QuickPresets URL patterns updated correctly

The QuickPresets URL patterns have been successfully updated to use the path() function:

  1. Consistent use of UUID converters.
  2. Preservation of view functions and URL names.

Note: As indicated by the comment, QuickPresets intentionally lacks a clone-factory-presets pattern, which is consistent with the "only clone from other" functionality.


137-165: LGTM: PresetSet URL patterns updated correctly

The PresetSet URL patterns have been successfully updated to use the path() function:

  1. Consistent use of UUID converters where applicable.
  2. Preservation of view functions and URL names.
  3. Correct handling of the clone-factory-presets pattern without converters.

These updates maintain consistency with the rest of the file while correctly handling the unique aspects of the PresetSet patterns.


Line range hint 1-167: Excellent update to modern Django URL routing

This update successfully transitions all URL patterns from url() to path(), aligning with Django's modern URL routing practices. Key improvements include:

  1. Consistent use of UUID and slug converters across all preset types.
  2. Improved code readability and type safety for URL parameters.
  3. Maintained backwards compatibility by preserving view functions and URL names.

The uniform structure across different preset types enhances overall code consistency and maintainability. This refactoring sets a solid foundation for future development and makes the codebase more robust.

backend/cohorts/tests/test_permissions_ajax.py (4)

126-126: Verify compatibility with the new base class.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the updates in the previous two classes. Ensure that the new base class ProjectAPIPermissionTestBase provides all the necessary functionality required by this test class as well.

To verify the compatibility, you can run the following command:

#!/bin/bash
# Description: Check if ProjectAPIPermissionTestBase contains all methods used in TestCohortCaseApiView

# Test: Search for method calls in TestCohortCaseApiView
methods=$(ast-grep --lang python --pattern 'class TestCohortCaseApiView($$$):\n  $$$\n  self.$_($$$)' backend/cohorts/tests/test_permissions_ajax.py | grep -oP '(?<=self\.)\w+' | sort -u)

# Test: Check if these methods exist in ProjectAPIPermissionTestBase
for method in $methods; do
    if ! ast-grep --lang python --pattern "class ProjectAPIPermissionTestBase($$$):\n  $$$\n  def $method($$$):\n    $$$" | grep -q .; then
        echo "Warning: Method $method not found in ProjectAPIPermissionTestBase"
    fi
done

This script will help identify any potential missing methods in the new base class specific to this test class.


101-101: Verify compatibility with the new base class.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the previous class update. Ensure that the new base class ProjectAPIPermissionTestBase provides all the necessary functionality required by this test class as well.

To verify the compatibility, you can run the following command:

#!/bin/bash
# Description: Check if ProjectAPIPermissionTestBase contains all methods used in TestAccessibleProjectsCasesApiView

# Test: Search for method calls in TestAccessibleProjectsCasesApiView
methods=$(ast-grep --lang python --pattern 'class TestAccessibleProjectsCasesApiView($$$):\n  $$$\n  self.$_($$$)' backend/cohorts/tests/test_permissions_ajax.py | grep -oP '(?<=self\.)\w+' | sort -u)

# Test: Check if these methods exist in ProjectAPIPermissionTestBase
for method in $methods; do
    if ! ast-grep --lang python --pattern "class ProjectAPIPermissionTestBase($$$):\n  $$$\n  def $method($$$):\n    $$$" | grep -q .; then
        echo "Warning: Method $method not found in ProjectAPIPermissionTestBase"
    fi
done

This script will help identify any potential missing methods in the new base class specific to this test class.


9-9: Verify compatibility with the new base class.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase looks good. However, please ensure that the new base class ProjectAPIPermissionTestBase provides all the necessary functionality required by this test class.

To verify the compatibility, you can run the following command:

This script will help identify any potential missing methods in the new base class.

✅ Verification successful

Compatibility Verified with the New Base Class.

All methods from TestProjectAPIPermissionBase are present in ProjectAPIPermissionTestBase, ensuring that the change maintains the necessary functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if ProjectAPIPermissionTestBase contains all methods used in TestCohortApiView

# Test: Search for method calls in TestCohortApiView
methods=$(ast-grep --lang python --pattern 'self.$_($$$)' backend/cohorts/tests/test_permissions_ajax.py | grep -oP '(?<=self\.)\w+' | sort -u)

# Test: Check if these methods exist in ProjectAPIPermissionTestBase
for method in $methods; do
    if ! ast-grep --lang python --pattern "class ProjectAPIPermissionTestBase($$$):\n  $$$\n  def $method($$$):\n    $$$" | grep -q .; then
        echo "Warning: Method $method not found in ProjectAPIPermissionTestBase"
    fi
done

Length of output: 205


Script:

#!/bin/bash
# Description: Verify that ProjectAPIPermissionTestBase includes all methods from TestProjectAPIPermissionBase

# List all methods in TestProjectAPIPermissionBase
test_base_methods=$(ast-grep --lang python --pattern 'class TestProjectAPIPermissionBase($$$):\n  $$$\n  def $_($$$):\n    $$$' . | grep -oP 'def \K\w+' | sort -u)

# List all methods in ProjectAPIPermissionTestBase
new_base_methods=$(ast-grep --lang python --pattern 'class ProjectAPIPermissionTestBase($$$):\n  $$$\n  def $_($$$):\n    $$$' . | grep -oP 'def \K\w+' | sort -u)

# Compare the two lists
missing_methods=$(comm -23 <(echo "$test_base_methods") <(echo "$new_base_methods"))

if [ -n "$missing_methods" ]; then
    echo "Warning: The following methods are missing in ProjectAPIPermissionTestBase:"
    echo "$missing_methods"
else
    echo "All methods from TestProjectAPIPermissionBase are present in ProjectAPIPermissionTestBase."
fi

Length of output: 693


9-9: Verify global refactoring of test base classes.

The consistent change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase across all three test classes (TestCohortApiView, TestAccessibleProjectsCasesApiView, and TestCohortCaseApiView) suggests a deliberate refactoring of the test base class. This change looks good and maintains consistency throughout the file.

To ensure this refactoring has been applied consistently across the entire project, run the following command:

This script will help identify any files that might have been missed in the refactoring process and confirm the extent of the changes.

Also applies to: 101-101, 126-126

backend/variants/tests/test_ui.py (2)

164-164: LGTM: Indentation fixed in _make_user method.

The indentation of the return user statement in the _make_user method of LiveUserMixin has been corrected. This improves code readability and ensures proper execution.


164-164: LGTM: Class renamed for consistency.

The renaming of TestUIBase to UITestBase appears to be for consistency, likely aligning with a naming convention change in the projectroles package. This change improves code readability and maintainability.

To ensure this change doesn't break any imports, please run the following script:

If the script returns any results, those files may need to be updated to use the new class name UITestBase.

✅ Verification successful

To ensure all references to TestUIBase have been updated, please run the following script:


To identify the correct file type identifier for Python files, please run the following script:


To ensure all references to TestUIBase have been updated, please run the following script:


Verified: All references to TestUIBase have been successfully updated to UITestBase.

The renaming has been thoroughly checked, and no lingering references to TestUIBase were found in the Python files. This ensures that the change does not break any imports or usages within the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to TestUIBase in Python files
rg --type python 'TestUIBase'

Length of output: 60


Script:

# 
#!/bin/bash
# Search for any remaining references to TestUIBase in Python files
rg -t python 'TestUIBase'

Length of output: 56


Script:

# 
#!/bin/bash
# List all supported file types in ripgrep
rg --type-list

Length of output: 4821


Script:

# 
#!/bin/bash
# Search for any remaining references to TestUIBase in Python files using the correct file type identifier
rg -t py 'TestUIBase'

Length of output: 21

.github/workflows/main.yml (2)

Line range hint 1-324: Review summary: PostgreSQL upgrade impact on CI/CD

The main change in this workflow file is the upgrade of PostgreSQL from version 14 to 16 in the Python-Test job. While this is a significant update, no other changes were made to the workflow configuration.

Consider the following:

  1. Ensure that all jobs in the CI pipeline, especially those involving database interactions, are tested thoroughly with the new PostgreSQL version.
  2. Update the project documentation to reflect the new PostgreSQL version requirement.
  3. Verify that the upgrade doesn't introduce any performance regressions in the CI/CD process.

The change is approved, but please address the points mentioned in the previous comment regarding PostgreSQL compatibility verification.


17-17: Verify compatibility with PostgreSQL 16 upgrade

The PostgreSQL image has been updated from version 14 to 16. This is a major version upgrade that may introduce changes in behavior and features.

Consider the following actions:

  1. Ensure that all database-related tests pass with the new PostgreSQL version.
  2. Verify that the application code and ORM are compatible with PostgreSQL 16.
  3. Update the local development environment and production systems to match this version.
  4. Review the PostgreSQL 16 release notes for any features or changes that may benefit the project.

To help verify the compatibility, you can run the following script:

This script will help identify any potential areas that might need attention due to the PostgreSQL version upgrade.

✅ Verification successful

PostgreSQL 16 upgrade compatibility verified successfully

No compatibility issues detected with the PostgreSQL 16 upgrade.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for PostgreSQL version-specific code or configurations

# Test: Search for PostgreSQL version mentions
echo "Searching for PostgreSQL version mentions:"
rg --type yaml --type python "postgres(ql)?\s*:?\s*(14|15|16)"

# Test: Search for potential version-specific SQL syntax
echo "Searching for potential version-specific SQL syntax:"
rg --type python "CREATE\s+STATISTICS|CREATE\s+ACCESS\s+METHOD|CREATE\s+PROCEDURE"

# Test: Check for any migration files that might need updates
echo "Checking for recent migration files:"
fd --type f --changed-within 6months "^\d{4}_.*\.py$" backend/varfish/migrations

Length of output: 701


Script:

#!/bin/bash
# Description: Check for PostgreSQL version-specific code or configurations

# Test: Search for PostgreSQL version mentions
echo "Searching for PostgreSQL version mentions:"
rg --type yaml --type py "postgres(ql)?\s*:?\s*(14|15|16)"

# Test: Search for potential version-specific SQL syntax
echo "Searching for potential version-specific SQL syntax:"
rg --type py "CREATE\s+STATISTICS|CREATE\s+ACCESS\s+METHOD|CREATE\s+PROCEDURE"

# Test: Locate migration directories dynamically
echo "Locating migration directories:"
migration_dirs=$(fd --type d "migrations")
if [ -z "$migration_dirs" ]; then
    echo "No migration directories found."
else
    echo "Found migration directories:"
    echo "$migration_dirs"
    
    # Test: Check for recent migration files in each migration directory
    for dir in $migration_dirs; do
        echo "Checking for recent migration files in $dir:"
        fd --type f --changed-within 6months "^\d{4}_.*\.py$" "$dir"
    done
fi

Length of output: 28876

backend/cohorts/tests/test_permissions_api.py (3)

108-108: LGTM: Consistent base class update.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the previous class modification. This update maintains consistency across the test classes.


137-137: LGTM: Consistent base class update across all test classes.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent across all three test classes in this file. This update maintains consistency and likely aligns with a broader refactoring of the test infrastructure.

Summary of changes in this file:

  1. TestCohortApiView
  2. TestAccessibleProjectsCasesApiView
  3. TestCohortCaseApiView

All these classes now inherit from ProjectAPIPermissionTestBase.


9-9: Verify the impact of the new base class.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase looks good. This update likely aligns with a broader refactoring of the test infrastructure.

To ensure consistency and proper functionality, please run the following script:

Ensure that:

  1. Other test classes are consistently using ProjectAPIPermissionTestBase.
  2. ProjectAPIPermissionTestBase provides all necessary setup and teardown methods previously available in TestProjectAPIPermissionBase.
backend/svs/tests/test_permissions_ajax_queries.py (8)

11-11: Approve base class change for TestSvQueryListCreateAjaxView.

The base class for TestSvQueryListCreateAjaxView has been updated to ProjectAPIPermissionTestBase, which is consistent with the import statement change. The test methods and setup remain unchanged, indicating compatibility with the new base class.


48-48: Approve base class change for TestSvQueryRetrieveUpdateDestroyAjaxView.

The base class for TestSvQueryRetrieveUpdateDestroyAjaxView has been updated to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes. The test methods and setup remain unaltered, further confirming compatibility with the new base class.


111-111: Approve base class change for TestSvQueryResultSetListAjaxView.

The base class for TestSvQueryResultSetListAjaxView has been updated to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes. The test methods and setup remain unaltered, further confirming compatibility with the new base class.


134-134: Approve base class change for TestSvQueryResultSetRetrieveAjaxView.

The base class for TestSvQueryResultSetRetrieveAjaxView has been updated to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes. The test methods and setup remain unaltered, further confirming compatibility with the new base class.


160-160: Approve base class change for TestSvQueryResultRowListAjaxView.

The base class for TestSvQueryResultRowListAjaxView has been updated to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes. The test methods and setup remain unaltered, further confirming compatibility with the new base class.


186-186: Approve base class change for TestSvQueryResultRowRetrieveView.

The base class for TestSvQueryResultRowRetrieveView has been updated to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes. The test methods and setup remain unaltered, further confirming compatibility with the new base class.


Line range hint 1-208: Overall assessment: Consistent base class update across all test classes.

The changes in this file demonstrate a consistent update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase across all six test classes. This uniform change suggests a deliberate refactoring effort, possibly aimed at standardizing or improving the project's testing framework.

Key points:

  1. The import statement has been updated to reflect the new base class.
  2. All test classes now inherit from ProjectAPIPermissionTestBase.
  3. No changes were made to the test methods or setup in any of the classes, indicating compatibility with the new base class.

To ensure that these changes haven't introduced any unintended side effects, please run the test suite for this file and verify that all tests still pass. You can use the following command:

python manage.py test backend.svs.tests.test_permissions_ajax_queries

If any issues arise, they should be addressed before merging this pull request.


4-4: Approve import change and verify base class compatibility.

The import statement has been updated to use ProjectAPIPermissionTestBase from projectroles.tests.test_permissions_api. This change is consistent with the updates in the test classes below.

Please ensure that ProjectAPIPermissionTestBase provides all the necessary functionality that was previously available in TestProjectAPIPermissionBase. You can verify this by running the following command:

This will help locate the definition of ProjectAPIPermissionTestBase and allow you to review its methods and attributes.

backend/variants/tests/test_permissions_ajax.py (5)

20-20: LGTM! Base class updated correctly.

The base class has been successfully updated to ProjectAPIPermissionTestBase. This change is consistent with the new import statement and maintains the existing test structure.


62-62: LGTM! Base class updated consistently.

The base class has been correctly updated to ProjectAPIPermissionTestBase for this test class as well. The change is consistent with the previous updates and maintains the existing test structure.


127-127: LGTM! Base class updated consistently.

The base class has been correctly updated to ProjectAPIPermissionTestBase for this test class as well. The change is consistent with the previous updates and maintains the existing test structure.


155-155: LGTM! Base class updated consistently.

The base class has been correctly updated to ProjectAPIPermissionTestBase for this test class as well. The change is consistent with the previous updates and maintains the existing test structure.


6-6: LGTM! Verify the new import across the project.

The import statement has been correctly updated to use ProjectAPIPermissionTestBase. This change is consistent with the updates in the test classes.

To ensure this change is consistent across the project, run the following command:

✅ Verification successful

Action Required: Correct the search command to verify remaining imports.

The previous search command failed due to an unrecognized file type. Please run the following corrected command to search for any remaining imports of TestProjectAPIPermissionBase:


Import Statement Verified

The import statement has been correctly updated to use ProjectAPIPermissionTestBase at line 6. No issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the import statement
grep -n "from projectroles.tests.test_permissions_api import ProjectAPIPermissionTestBase" backend/variants/tests/test_permissions_api.py

Length of output: 222


209-209: LGTM! Base class updated consistently. Verify overall impact.

The base class for TestSmallVariantQueryResultRowRetrieveApiView has been correctly updated to ProjectAPIPermissionTestBase. This change maintains consistency with the previous updates and preserves the existing test structure.

As this completes the updates for all test classes in this file, it would be beneficial to verify that these changes don't introduce any unintended side effects on the test coverage or behavior.

To ensure all test classes are using the new base class and that no classes were missed, run the following command:

✅ Verification successful

Verified! All test classes inherit from ProjectAPIPermissionTestBase.

The base class for all relevant test classes, including TestSmallVariantQueryResultRowRetrieveApiView, has been successfully updated to ProjectAPIPermissionTestBase. No classes were found inheriting from the old base class TestProjectAPIPermissionBase, ensuring consistency across the test suite.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify all test classes are using the new base class
grep -n "class Test.*ProjectAPIPermissionTestBase" backend/variants/tests/test_permissions_api.py

Length of output: 163


Script:

#!/bin/bash
# Using ast-grep to find class inheritance
ast-grep --lang python --pattern 'class TestSmallVariantQueryResultRowRetrieveApiView(ProjectAPIPermissionTestBase):' backend/variants/tests/test_permissions_api.py

Length of output: 166


Script:

#!/bin/bash
# Search for class definitions inheriting from ProjectAPIPermissionTestBase
rg 'class\s+Test\w*\s*\(\s*ProjectAPIPermissionTestBase\s*\)' backend/variants/tests/test_permissions_api.py

Length of output: 597

backend/beaconsite/tests/test_views.py (10)

7-7: LGTM: New base class import looks good.

The import of ViewTestBase from variants.tests.helpers is correct. This change suggests a move towards using a more generalized test base class, which can improve code reuse and consistency across different apps in the project.


10-10: LGTM: Base class updated correctly.

The TestIndexView class now inherits from ViewTestBase, which is consistent with the new import. The test logic remains unchanged, indicating compatibility with the new base class.


21-21: LGTM: Base class updated correctly.

The TestConsortiumListView class now inherits from ViewTestBase, consistent with the new base class usage. The test logic remains intact, indicating compatibility with the new base class.


30-30: LGTM: Base class updated correctly.

The TestConsortiumCreateView class now inherits from ViewTestBase, maintaining consistency with the new base class usage. The test logic for both test_render and test_create methods remains unchanged, indicating full compatibility with the new base class.


63-63: LGTM: Base class updated correctly.

The TestConsortiumUpdateView class now inherits from ViewTestBase, consistent with the new base class usage throughout the file. Both test_render and test_update methods remain unchanged, demonstrating compatibility with the new base class.


113-113: LGTM: Base class updated correctly.

The TestConsortiumDeleteView class now inherits from ViewTestBase, maintaining consistency with the new base class usage. The test logic for both test_render and test_delete methods remains intact, indicating full compatibility with the new base class.


142-142: LGTM: Base class updated correctly.

The TestSiteListView class now inherits from ViewTestBase, consistent with the new base class usage throughout the file. The test logic in the test_render method remains unchanged, demonstrating compatibility with the new base class.


151-151: LGTM: Base class updated correctly.

The TestSiteCreateView class now inherits from ViewTestBase, maintaining consistency with the new base class usage. The test logic for both test_render and test_create methods remains intact, indicating full compatibility with the new base class.


187-187: LGTM: Base class updated correctly.

The TestSiteUpdateView class now inherits from ViewTestBase, consistent with the new base class usage throughout the file. Both test_render and test_update methods remain unchanged, demonstrating compatibility with the new base class.


249-249: LGTM: Base class updated correctly.

The TestSiteDeleteView class now inherits from ViewTestBase, maintaining consistency with the new base class usage. The test logic for both test_render and test_delete methods remains intact, indicating full compatibility with the new base class.

Overall assessment: Consistent base class update across all test classes.

All test classes in this file have been successfully updated to use the new ViewTestBase class. The consistency of this change across all classes and the preservation of existing test logic suggest a well-executed refactoring. This change likely contributes to better code organization and potential improvements in test setup or utility methods provided by the new base class.

To ensure the completeness of this change:

  1. Verify that the ViewTestBase class in variants.tests.helpers includes all necessary setup and utility methods previously provided by TestViewsBase.
  2. Consider updating the docstring at the beginning of the file to reflect the change in the base class used, if applicable.
  3. Ensure that any project-wide documentation referring to TestViewsBase is updated to mention ViewTestBase for consistency.

To verify the completeness of this change, you can run the following script:

This script will help ensure that all necessary methods are present in the new base class, that there are no lingering references to the old base class, and that all test files have been updated consistently.

frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3)

303-303: Approved: Consistent safeguard for gene allowlist section

This change is consistent with the safeguard added to the genomic region section. It prevents potential errors when querySettings is null or undefined.

Please refer to the previous comment regarding the suggestion to initialize querySettings with default values, as it applies to this section as well.


315-315: Approved: Improved formatting for better readability

The changes to the Multiselect and select elements are purely formatting improvements. Placing each attribute on a separate line enhances readability, especially for elements with multiple attributes. This aligns with Vue.js style guide recommendations and makes the template easier to maintain.

Also applies to: 319-321


Line range hint 1-400: Summary: Improved robustness and readability with minor suggestion

The changes in this file enhance the component's robustness by adding safeguards against null or undefined querySettings, and improve readability through better formatting. Consider initializing querySettings with default values to ensure consistent behavior. Overall, these changes are positive and align with good Vue.js practices.

frontend/src/variants/components/FilterForm/FrequencyPane.vue (3)

Line range hint 30-30: Exposing v$ for parent component access

The v$ object is now exposed, allowing parent components to access the validation state provided by useVuelidate().

This is a good practice for components that need to expose their validation state to parent components. It enhances the component's reusability and allows for more flexible form validation handling.


69-69: Minor formatting change in table class

A redundant line break has been removed from the table's class attribute.

This change improves code readability without affecting functionality.


Line range hint 1-441: Overall assessment of changes

The changes to this component primarily focus on adding developer tools and improving code structure. The new dumpFrequencies() method and the developer information section enhance debugging capabilities without affecting the core functionality of the frequency filtering.

These changes are well-implemented and provide valuable tools for development and debugging. They don't introduce any apparent issues and maintain the existing functionality of the component.

To ensure that these changes don't affect the component's behavior in production, please verify that:

  1. The developer information is only visible when filtrationComplexityMode is set to 'dev'.
  2. The exposure of v$ doesn't lead to any unintended side effects in parent components.

You can use the following script to check for any unintended exposures of developer information:

This script will help identify any other components that might be using the developer mode, ensuring that it's consistently applied across the application.

backend/cases/tests/test_permissions_ajax.py (2)

4-4: LGTM: Consistent base class update across all test classes

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase has been applied consistently across all test classes in the file. This update likely reflects an improvement in the underlying testing framework or a refactoring for better naming conventions. The functionality of the tests remains unchanged, which is good for maintaining test coverage.

Also applies to: 10-10, 97-97, 152-152, 178-178, 204-204, 288-288, 336-336, 416-416, 442-442, 465-465, 491-491, 517-517


Line range hint 1-543: Overall approval: Changes maintain test integrity

The changes made to this file, primarily the consistent update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, have been applied correctly across all test classes. The existing test coverage and structure have been maintained, ensuring that permissions for different user roles are still being properly tested across various API views.

While there are opportunities for enhancing the test suite (as mentioned in the previous comment), the current changes do not introduce any issues and successfully refactor the code as intended.

backend/cases/tests/test_permissions_api.py (13)

4-4: LGTM: Base class import updated correctly.

The import statement has been updated to use the new base class name ProjectAPIPermissionTestBase. This change is consistent with the updates made throughout the file.


10-10: LGTM: Base class updated correctly for TestCaseApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, which is consistent with the import statement and the changes throughout the file.


105-105: LGTM: Base class updated correctly for TestCasePhenotypeTermsCreateListAjaxView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


156-156: LGTM: Base class updated correctly for TestCasePhenotypeTermsRetrieveUpdateDestroyApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


238-238: LGTM: Base class updated correctly for TestAnnotationReleaseInfoListApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


264-264: LGTM: Base class updated correctly for TestSvAnnotationReleaseInfoListApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


290-290: LGTM: Base class updated correctly for TestCaseCommentCreateListApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


340-340: LGTM: Base class updated correctly for TestCaseCommentRetrieveUpdateDestroyApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


422-422: LGTM: Base class updated correctly for TestCaseGeneAnnotationListApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


448-448: LGTM: Base class updated correctly for TestCaseAlignmentStatsListApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


474-474: LGTM: Base class updated correctly for TestSampleVariantStatisticsListApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


500-500: LGTM: Base class updated correctly for TestPedigreeRelatednessListApiView.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, maintaining consistency with the previous changes.


Line range hint 1-524: LGTM: Consistent update of base class across all test classes.

The changes in this file are limited to updating the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase for all test classes. This change is consistent throughout the file and aligns with the updated import statement. The modification does not alter the functionality of the tests, maintaining the integrity of the test suite. This update likely reflects a refactoring in the projectroles app.

Recommendation: Ensure that the ProjectAPIPermissionTestBase class in the projectroles app provides the same functionality as the previous TestProjectAPIPermissionBase class to maintain the effectiveness of these permission tests.

To verify the base class change across the project, run the following command:

This will help ensure that the base class has been updated consistently across all relevant files in the project.

✅ Verification successful

To ensure that there are no remaining instances of TestProjectAPIPermissionBase, please run the following corrected shell script:


Verified: All instances of TestProjectAPIPermissionBase have been successfully updated to ProjectAPIPermissionTestBase.

The search yielded no remaining instances of TestProjectAPIPermissionBase, confirming that the base class change has been applied consistently across the project. This ensures that the permission tests maintain their intended functionality without any lingering references to the old base class.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of TestProjectAPIPermissionBase
rg "TestProjectAPIPermissionBase" --type python

Length of output: 78


Script:

# Search for any remaining instances of TestProjectAPIPermissionBase
rg "TestProjectAPIPermissionBase" --type py

Length of output: 43

frontend/src/variants/components/QueryPresets/SetEditor.vue (1)

Line range hint 441-448: Improved onMounted hook implementation

The changes in the onMounted hook enhance the initialization process. The use of async/await for store initialization and the conditional setup of quick preset sortable are good practices.

backend/genepanels/tests/test_views.py (1)

13-13: Consistent update of base class for view tests.

The change from TestViewsBase to ViewTestBase as the base class for all test classes in this file is consistent and appears to be part of a larger refactoring effort. This change should improve the consistency of view tests across the project.

To ensure this change is consistent across the project, let's check for any remaining uses of TestViewsBase:

✅ Verification successful

Correction Needed for Shell Script Usage of Ripgrep.

The previous command failed because --type python is not recognized by ripgrep. To accurately search for classes inheriting from TestViewsBase in Python files, let's adjust the command to use the correct file type specifier.


Base class change successfully verified with no remaining references to TestViewsBase.

The update from TestViewsBase to ViewTestBase has been consistently applied across all relevant test classes in backend/genepanels/tests/test_views.py. No remaining references to TestViewsBase were found in the codebase, ensuring the refactoring was thorough and complete.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

rg "class \w+\(TestViewsBase\)" --type python

Length of output: 78


Script:

#!/bin/bash
# Searching for classes that inherit from TestViewsBase in Python files
rg "class\s+\w+\(TestViewsBase\)" --type py

Length of output: 45

backend/cases/tests/test_views_ajax.py (12)

627-627: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

#!/bin/bash
# Verify test coverage for TestSampleVariantStatisticsListApiView

# Check if any test methods were removed or significantly changed
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -E 'def test_'

# Check for any changes in the setUp method
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -A 10 'def setUp'

# Run the tests for this specific class and check for any failures
python manage.py test backend.cases.tests.test_views_ajax.TestSampleVariantStatisticsListApiView

Line range hint 1-699: Overall LGTM! Ensure comprehensive test coverage.

The refactoring of all test classes to use ProjectAPIPermissionTestBase as the base class is consistent and appears to be part of a larger update to the project's testing framework. While the changes look good, it's crucial to:

  1. Run the entire test suite to ensure no regressions were introduced.
  2. Verify that the new base class provides all necessary setup and teardown operations for these tests.
  3. Check if any additional tests need to be added to cover any new functionality introduced by the base class change.
#!/bin/bash
# Run the entire test suite and check for any failures

# Run all tests in the cases app
python manage.py test cases

# Check for any test failures or errors
python manage.py test cases | grep -E "FAILED|ERROR"

# Run coverage report to ensure no decrease in test coverage
coverage run manage.py test cases
coverage report -m

228-228: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

#!/bin/bash
# Verify test coverage for TestCasePhenotypeTermsListCreateAjaxView

# Check if any test methods were removed or significantly changed
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -E 'def test_'

# Check for any changes in the setUp method
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -A 10 'def setUp'

# Run the tests for this specific class and check for any failures
python manage.py test backend.cases.tests.test_views_ajax.TestCasePhenotypeTermsListCreateAjaxView

293-293: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

#!/bin/bash
# Verify test coverage for TestCasePhenotypeTermsRetrieveUpdateDestroyAjaxView

# Check if any test methods were removed or significantly changed
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -E 'def test_'

# Check for any changes in the setUp method
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -A 10 'def setUp'

# Run the tests for this specific class and check for any failures
python manage.py test backend.cases.tests.test_views_ajax.TestCasePhenotypeTermsRetrieveUpdateDestroyAjaxView

363-363: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

#!/bin/bash
# Verify test coverage for TestCaseCommentListCreateAjaxView

# Check if any test methods were removed or significantly changed
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -E 'def test_'

# Check for any changes in the setUp method
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -A 10 'def setUp'

# Run the tests for this specific class and check for any failures
python manage.py test backend.cases.tests.test_views_ajax.TestCaseCommentListCreateAjaxView

417-417: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

#!/bin/bash
# Verify test coverage for TestCaseCommentRetrieveUpdateDestroyAjaxView

# Check if any test methods were removed or significantly changed
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -E 'def test_'

# Check for any changes in the setUp method
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -A 10 'def setUp'

# Run the tests for this specific class and check for any failures
python manage.py test backend.cases.tests.test_views_ajax.TestCaseCommentRetrieveUpdateDestroyAjaxView

488-488: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

#!/bin/bash
# Verify test coverage for TestCaseGeneAnnotationListAjaxView

# Check if any test methods were removed or significantly changed
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -E 'def test_'

# Check for any changes in the setUp method
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -A 10 'def setUp'

# Run the tests for this specific class and check for any failures
python manage.py test backend.cases.tests.test_views_ajax.TestCaseGeneAnnotationListAjaxView

516-516: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

#!/bin/bash
# Verify test coverage for TestProjectUserPermissionsAjaxView

# Check if any test methods were removed or significantly changed
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -E 'def test_'

# Check for any changes in the setUp method
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -A 10 'def setUp'

# Run the tests for this specific class and check for any failures
python manage.py test backend.cases.tests.test_views_ajax.TestProjectUserPermissionsAjaxView

599-599: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

#!/bin/bash
# Verify test coverage for TestCaseAlignmentStatsListApiView

# Check if any test methods were removed or significantly changed
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -E 'def test_'

# Check for any changes in the setUp method
git diff HEAD^ HEAD -- backend/cases/tests/test_views_ajax.py | grep -E '^\+|-' | grep -A 10 'def setUp'

# Run the tests for this specific class and check for any failures
python manage.py test backend.cases.tests.test_views_ajax.TestCaseAlignmentStatsListApiView

150-150: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.


667-667: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.


41-41: LGTM! Verify test coverage after base class change.

The update of the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring. Ensure that all existing tests still provide adequate coverage with the new base class.

backend/variants/tests/test_views_ajax_presets.py (3)

5-5: Update import statement

The import statement has been updated to use ProjectAPIPermissionTestBase from the projectroles.tests.test_permissions_api module. This change aligns with the base class modification in ApiViewTestBase.


Line range hint 32-1010: Consistent implementation of test classes

The remaining code in the file maintains a consistent structure across different preset types (FrequencyPresets, ImpactPresets, QualityPresets, ChromosomePresets, FlagsEtcPresets, QuickPresets, and PresetSet). Each test class follows a similar pattern for testing CRUD operations and cloning functionality. This consistency is commendable and makes the code easy to understand and maintain.


28-28: Update base class for API view tests

The ApiViewTestBase class now inherits from ProjectAPIPermissionTestBase instead of TestProjectAPIPermissionBase. This change likely reflects an update in the project's testing framework or a refactoring of the permission testing utilities.

To ensure this change is consistent across the project, let's check for any remaining uses of TestProjectAPIPermissionBase:

✅ Verification successful

[/run_scripts]


No Remaining Uses of TestProjectAPIPermissionBase Found

All instances have been successfully updated to ProjectAPIPermissionTestBase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining uses of TestProjectAPIPermissionBase
rg "TestProjectAPIPermissionBase" --type python

Length of output: 78


Script:

#!/bin/bash
# Search for any remaining uses of TestProjectAPIPermissionBase in Python files
rg "TestProjectAPIPermissionBase" --type py

Length of output: 43

backend/variants/tests/test_file_export.py (3)

18-18: Update import statement

The import statement has been changed from ProjectEvent to TimelineEvent. This change reflects a shift in the event tracking mechanism used in the export functionality.


978-978: Update assertion to use TimelineEvent

The assertion has been updated to check the count of TimelineEvent objects instead of ProjectEvent objects. This change is consistent with the import statement modification.


18-18: Verify impact on test behavior

The change from ProjectEvent to TimelineEvent appears to be isolated to the import statement and a single assertion. However, it's important to ensure that this change doesn't inadvertently affect the behavior of other tests in this file.

Please run the following script to check if there are any failing tests after this change:

Also applies to: 978-978

backend/variants/tests/test_permissions_ajax_presets.py (25)

2-2: LGTM: Base class import updated correctly.

The import statement has been updated to use ProjectAPIPermissionTestBase instead of TestProjectAPIPermissionBase. This change is consistent with the modifications made throughout the file.


1071-1071: LGTM: Base class updated correctly.

The base class for TestPresetSetListCreateAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:

python manage.py test backend.variants.tests.test_permissions_ajax_presets.TestPresetSetListCreateAjaxView

1037-1037: LGTM: Base class updated correctly.

The base class for TestQuickPresetsCloneOtherView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:

python manage.py test backend.variants.tests.test_permissions_ajax_presets.TestQuickPresetsCloneOtherView

596-596: LGTM: Base class updated correctly.

The base class for TestChromosomePresetsRetrieveUpdateDestroyAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


672-672: LGTM: Base class updated correctly.

The base class for TestChromosomePresetsCloneFactoryDefaultsView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


64-64: LGTM: Base class updated correctly.

The base class for TestFrequencyPresetsRetrieveUpdateDestroyAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


17-17: LGTM: Base class updated correctly.

The base class for TestFrequencyPresetsListCreateAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the import statement modification.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


521-521: LGTM: Base class updated correctly.

The base class for TestQualityPresetsCloneOtherView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


774-774: LGTM: Base class updated correctly.

The base class for TestFlagsEtcPresetsRetrieveUpdateDestroyAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


195-195: LGTM: Base class updated correctly.

The base class for TestImpactPresetsListCreateAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


850-850: LGTM: Base class updated correctly.

The base class for TestFlagsEtcPresetsCloneFactoryDefaultsView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


167-167: LGTM: Base class updated correctly.

The base class for TestFrequencyPresetsCloneOtherView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


727-727: LGTM: Base class updated correctly.

The base class for TestFlagsEtcPresetsListCreateAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


373-373: LGTM: Base class updated correctly.

The base class for TestQualityPresetsListCreateAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


140-140: LGTM: Base class updated correctly.

The base class for TestFrequencyPresetsCloneFactoryDefaultsView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


961-961: LGTM: Base class updated correctly.

The base class for TestQuickPresetsRetrieveUpdateDestroyAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


496-496: LGTM: Base class updated correctly.

The base class for TestQualityPresetsCloneFactoryDefaultsView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


242-242: LGTM: Base class updated correctly.

The base class for TestImpactPresetsRetrieveUpdateDestroyAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


905-905: LGTM: Base class updated correctly.

The base class for TestQuickPresetsListCreateAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


877-877: LGTM: Base class updated correctly.

The base class for TestFlagsEtcPresetsCloneOtherView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


345-345: LGTM: Base class updated correctly.

The base class for TestImpactPresetsCloneOtherView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


420-420: LGTM: Base class updated correctly.

The base class for TestQualityPresetsRetrieveUpdateDestroyAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


699-699: LGTM: Base class updated correctly.

The base class for TestChromosomePresetsCloneOtherView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


318-318: LGTM: Base class updated correctly.

The base class for TestImpactPresetsCloneFactoryDefaultsView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:


549-549: LGTM: Base class updated correctly.

The base class for TestChromosomePresetsListCreateAjaxView has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the previous modifications.

To ensure full compatibility, please run the following command to verify that all tests in this class pass with the new base class:

backend/variants/urls/__init__.py (1)

12-450: ⚠️ Potential issue

Potential change in URL behavior due to trailing slashes

In the previous implementation using url(), the regex patterns included /?$, allowing URLs to be accessed with or without a trailing slash. The new path() patterns specify URLs with a trailing slash, which may cause URLs without a trailing slash to return a 404 error if APPEND_SLASH is set to False in the Django settings. This could affect existing clients relying on the old behavior.

To verify the APPEND_SLASH setting and ensure it's enabled:

If APPEND_SLASH is not set to True, consider enabling it or adjusting the URL patterns to accommodate both cases by explicitly handling optional trailing slashes using re_path().

✅ Verification successful

APPEND_SLASH Verification Successful

The APPEND_SLASH setting is not explicitly defined in the Django settings files, which means it defaults to True. Therefore, the updated path() URL patterns with trailing slashes will continue to append slashes to URLs without them, maintaining the expected behavior and preventing 404 errors for existing clients.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if APPEND_SLASH is set to True in Django settings.

# Search for APPEND_SLASH in settings files. Expect: APPEND_SLASH = True
grep 'APPEND_SLASH' varfish/varfish/settings*.py

Length of output: 112


Script:

#!/bin/bash
# Description: Search for the APPEND_SLASH setting in all Python files within the repository.

# Use ripgrep to find occurrences of 'APPEND_SLASH' in any .py file
rg 'APPEND_SLASH' --glob '*.py'

Length of output: 31

backend/config/settings/base.py (6)

80-83: Addition of 'social_django' and 'projectroles.apps.ProjectrolesConfig'

The inclusion of "social_django" for OIDC authentication and "projectroles.apps.ProjectrolesConfig" appears correct and aligns with the shift from SAML to OIDC authentication.


438-438: Update 'ADMIN_URL' to a simplified string

Changing ADMIN_URL to "admin/" simplifies the admin URL configuration and is consistent with Django's URL patterns since version 2.0.


867-867: Introduction of 'ENABLE_OIDC' setting

Adding ENABLE_OIDC allows for toggling OIDC authentication. Ensure this environment variable is correctly set according to your deployment needs.


876-879: Addition of OIDC context processors

Including social_django context processors enhances template rendering for OIDC authentication, which is appropriate.


882-889: Configuration of 'SOCIAL_AUTH' settings

The settings for SOCIAL_AUTH_USER_MODEL and SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS are correctly defined to integrate with the custom user model.


880-881: ⚠️ Potential issue

Verify compatibility of 'django.db.models.JSONField'

django.db.models.JSONField is available in Django 3.1 and later. Ensure that your project is using a compatible Django version to avoid import errors.

@@ -1,10 +1,10 @@
from django.urls import reverse
from projectroles.tests.test_permissions_api import TestProjectAPIPermissionBase
from projectroles.tests.test_permissions_api import ProjectAPIPermissionTestBase
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Remaining Imports from TestProjectAPIPermissionBase Found

The following files still import TestProjectAPIPermissionBase and should be updated to use ProjectAPIPermissionTestBase:

  • backend/cases/tests/test_permissions_ajax.py
  • backend/cases/tests/test_views_ajax.py
  • backend/cases/tests/test_permissions_api.py
  • backend/seqvars/tests/test_permissions_api.py
  • backend/variants/tests/test_permissions_ajax_annos.py
  • backend/variants/tests/test/views_ajax_presets.py
  • backend/variants/tests/helpers.py
  • backend/variants/tests/test_permissions_ajax_presets.py
  • backend/variants/tests/test_permissions_ajax.py
  • backend/varannos/tests/helpers.py
  • backend/varannos/tests/test_permissions_api.py
  • backend/variants/tests/test_permissions_api.py
  • backend/svs/tests/test_permissions_ajax_queries.py
  • backend/svs/tests/test_permissions_ajax_presets.py
  • backend/cohorts/tests/test_permissions_ajax.py
  • backend/cohorts/tests/test_permissions_api.py
  • backend/cases_import/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_permissions_api.py
  • backend/cases_analysis/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_permissions_ajax.py
  • backend/beaconsite/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_views_ajax.py

Please update these imports to ensure consistency across the project.

🔗 Analysis chain

LGTM! Verify consistent usage across the project.

The import statement has been correctly updated to reflect the new base class name and location. This change aligns with the modifications in the test classes.

To ensure consistency across the project, run the following script:


Please allow me to generate a corrected script to verify the usage of ProjectAPIPermissionTestBase across the project.


Please allow me to generate a corrected script to verify the usage of ProjectAPIPermissionTestBase across the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of ProjectAPIPermissionTestBase across the project

# Test: Search for both old and new class names
echo "Occurrences of TestProjectAPIPermissionBase:"
rg --type python "TestProjectAPIPermissionBase"

echo "\nOccurrences of ProjectAPIPermissionTestBase:"
rg --type python "ProjectAPIPermissionTestBase"

# Test: Check for any remaining imports from the old location
echo "\nRemaining imports from old location:"
rg --type python "from projectroles\.tests\.test_permissions import TestProjectAPIPermissionBase"

Length of output: 752


Script:

#!/bin/bash
# Description: Verify the usage of ProjectAPIPermissionTestBase across the project

# Test: Search for both old and new class names
echo "Occurrences of TestProjectAPIPermissionBase:"
rg "TestProjectAPIPermissionBase"

echo "\nOccurrences of ProjectAPIPermissionTestBase:"
rg "ProjectAPIPermissionTestBase"

# Test: Check for any remaining imports from the old location
echo "\nRemaining imports from old location:"
rg "from projectroles\.tests\.test_permissions import TestProjectAPIPermissionBase"

Length of output: 17370


Script:

#!/bin/bash
# Description: Verify the usage of ProjectAPIPermissionTestBase across the project

# Test: Search for both old and new class names
echo "Occurrences of TestProjectAPIPermissionBase:"
rg "TestProjectAPIPermissionBase"

echo -e "\nOccurrences of ProjectAPIPermissionTestBase:"
rg "ProjectAPIPermissionTestBase"

# Test: Check for any remaining imports from the old location
echo -e "\nRemaining imports from old location:"
rg "from projectroles\.tests\.test_permissions_api import ProjectAPIPermissionTestBase"

Length of output: 20193

Comment on lines +83 to 152
path(
route="api/case/count/<uuid:project>/",
view=views_api.CaseCountApiView.as_view(),
name="api-case-count",
),
url(
regex=r"^api/case/list/(?P<project>[0-9a-f-]+)/?$",
path(
route="api/case/list/<uuid:project>/",
view=views_api.CaseListApiView.as_view(),
name="api-case-list",
),
url(
regex=r"^api/case/retrieve-update-destroy/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case/retrieve-update-destroy/<uuid:case>/",
view=views_api.CaseRetrieveUpdateDestroyApiView.as_view(),
name="api-case-retrieveupdatedestroy",
),
url(
regex=r"^api/case-comment/list-create/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-comment/list-create/<uuid:case>/",
view=views_api.CaseCommentListCreateApiView.as_view(),
name="api-casecomment-listcreate",
),
url(
regex=r"^ajax/case-comment/retrieve-update-destroy/(?P<casecomment>[0-9a-f-]+)/?$",
path(
route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
view=views_api.CaseCommentRetrieveUpdateDestroyApiView.as_view(),
name="api-casecomment-retrieveupdatedestroy",
),
url(
regex=r"^api/case-phenotype-terms/list-create/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-phenotype-terms/list-create/<uuid:case>/",
view=views_api.CasePhenotypeTermsListCreateApiView.as_view(),
name="api-casephenotypeterms-listcreate",
),
url(
regex=r"^api/case-phenotype-terms/retrieve-update-destroy/(?P<casephenotypeterms>[0-9a-f-]+)/?$",
path(
route="api/case-phenotype-terms/retrieve-update-destroy/<uuid:casephenotypeterms>/",
view=views_api.CasePhenotypeTermsRetrieveUpdateDestroyApiView.as_view(),
name="api-casephenotypeterms-retrieveupdatedestroy",
),
url(
regex=r"^api/annotation-release-info/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/annotation-release-info/list/<uuid:case>/",
view=views_api.AnnotationReleaseInfoApiView.as_view(),
name="api-annotationreleaseinfo-list",
),
url(
regex=r"^api/sv-annotation-release-info/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/sv-annotation-release-info/list/<uuid:case>/",
view=views_api.SvAnnotationReleaseInfoApiView.as_view(),
name="api-svannotationreleaseinfo-list",
),
url(
regex=r"^api/case-gene-annotation/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-gene-annotation/list/<uuid:case>/",
view=views_ajax.CaseGeneAnnotationListAjaxView.as_view(),
name="api-casegeneannotation-list",
),
url(
regex=r"^api/case-alignment-stats/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-alignment-stats/list/<uuid:case>/",
view=views_ajax.CaseAlignmentStatsListAjaxView.as_view(),
name="api-casealignmentstats-list",
),
url(
regex=r"^api/case-variant-stats/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-variant-stats/list/<uuid:case>/",
view=views_ajax.SampleVariantStatisticsListAjaxView.as_view(),
name="api-casevariantstats-list",
),
url(
regex=r"^api/case-relatedness/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-relatedness/list/<uuid:case>/",
view=views_ajax.PedigreeRelatednessListAjaxView.as_view(),
name="api-caserelatedness-list",
),
url(
regex=r"^api/user-and-global-settings/?$",
path(
route="api/user-and-global-settings/",
view=views_api.UserAndGlobalSettingsView.as_view(),
name="api-userandglobalsettings",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

LGTM with suggestions: Modernized API URL patterns with some inconsistencies

The update from url() to path() for all API URL patterns is consistent and aligns with Django's best practices. The use of UUID converters (<uuid:...>) for various parameters ensures type safety and consistency across all patterns.

There's an inconsistency in the view references for some API patterns. Some patterns are using AJAX views instead of API views. This should be corrected to ensure proper separation of concerns and consistent behavior. Please update the following patterns:

  1. Line 129: Change view=views_ajax.CaseGeneAnnotationListAjaxView.as_view() to view=views_api.CaseGeneAnnotationListApiView.as_view()
  2. Line 134: Change view=views_ajax.CaseAlignmentStatsListAjaxView.as_view() to view=views_api.CaseAlignmentStatsListApiView.as_view()
  3. Line 139: Change view=views_ajax.SampleVariantStatisticsListAjaxView.as_view() to view=views_api.SampleVariantStatisticsListApiView.as_view()
  4. Line 144: Change view=views_ajax.PedigreeRelatednessListAjaxView.as_view() to view=views_api.PedigreeRelatednessListApiView.as_view()

Make sure these API views exist in the views_api.py file. If they don't, you may need to create them or update the existing AJAX views to handle both AJAX and API requests.

Similar to the AJAX patterns, consider refactoring these API URL patterns to reduce repetition. You could use the same approach suggested for the AJAX patterns to create a more maintainable and DRY configuration.

@@ -155,7 +155,7 @@ def run_count_query(
return result


class TestViewsBase(TestCase):
class ViewTestBase(TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Resolve the redefinition of ViewTestBase class.

There appears to be an unintentional redefinition of the ViewTestBase class. This class is already defined on line 47 with different base classes and content. The redefinition could lead to confusion and potential issues in test execution.

Consider the following options to resolve this:

  1. If this is intended to be a different class, rename it to avoid conflict. For example:

    class AnotherViewTestBase(TestCase):
  2. If this is meant to replace the previous ViewTestBase, remove the earlier definition and update any references to it.

  3. If this is an oversight, remove this redefinition and merge any unique functionality into the existing ViewTestBase class.

Please clarify the intention behind this second definition and apply the appropriate resolution.

🧰 Tools
🪛 Ruff

158-158: Redefinition of unused ViewTestBase from line 47

(F811)

@@ -59,7 +59,7 @@
from variants.tests.factories import CaseFactory


class TestQueryPresetsSetViewSet(TestProjectAPIPermissionBase):
class TestQueryPresetsSetViewSet(ProjectAPIPermissionTestBase):
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using a data-driven approach for user role testing

The current implementation repeats the user role lists for each test method. Consider using a class-level attribute or a parameterized test approach to define these user roles once and reuse them across all test methods. This could improve maintainability and reduce redundancy.

Here's an example of how you could refactor this:

class TestQueryPresetsSetViewSet(ProjectAPIPermissionTestBase):
    good_users = [
        "superuser",
        "user_owner",
        "user_delegate",
        "user_contributor",
        "user_guest",
    ]
    bad_users_401 = ["anonymous"]
    bad_users_403 = ["user_no_roles", "user_finder_cat"]

    def setUp(self):
        super().setUp()
        self.querypresetsset = SeqvarsQueryPresetsSetFactory(project=self.project)
        self.good_users = [getattr(self, user) for user in self.good_users]
        self.bad_users_401 = [getattr(self, user) for user in self.bad_users_401]
        self.bad_users_403 = [getattr(self, user) for user in self.bad_users_403]

    # ... rest of the class implementation

This approach would allow you to define the user roles once and reuse them across all test methods, reducing redundancy and improving maintainability.

@@ -202,7 +202,7 @@
self.assert_response(url, bad_users_403, 403, method="DELETE", cleanup_method=cleanup)


class TestQueryPresetsVersionSetViewSet(TestProjectAPIPermissionBase):
class TestQueryPresetsVersionSetViewSet(ProjectAPIPermissionTestBase):
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider creating a base test class for common CRUD operations

The TestQueryPresetsVersionSetViewSet class has a very similar structure to TestQueryPresetsSetViewSet and other test classes in this file. To reduce code duplication and improve maintainability, consider creating a base test class that implements the common CRUD test methods. Each specific test class could then inherit from this base class and only implement unique test cases.

Here's an example of how you could refactor this:

class BaseCRUDTestCase(ProjectAPIPermissionTestBase):
    model_factory = None
    url_name = None
    data_for_create = None

    def setUp(self):
        super().setUp()
        self.object = self.model_factory(project=self.project)

    def test_list(self):
        url = reverse(f"seqvars:api-{self.url_name}-list", kwargs={"project": self.project.sodar_uuid})
        self.assert_response(url, self.good_users, 200, method="GET")
        self.assert_response(url, self.bad_users_401, 401, method="GET")
        self.assert_response(url, self.bad_users_403, 403, method="GET")

    # ... implement other common test methods (create, retrieve, patch, delete)

class TestQueryPresetsVersionSetViewSet(BaseCRUDTestCase):
    model_factory = SeqvarsQueryPresetsSetVersionFactory
    url_name = "querypresetssetversion"
    data_for_create = {"version_minor": 2}

    # ... implement only unique test methods or override if necessary

This approach would significantly reduce code duplication across your test classes and make it easier to maintain and extend your test suite.

Comment on lines +186 to +187
with transaction.atomic():
with connection.cursor() as cursor:
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Simplify nested with statements by combining them

Similarly, the nested with statements at lines 186-187 can be combined into a single with statement.

Here is the proposed change:

 def create_variants_smallvariantsummary():
     """Create the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute(SQL_OUTER % SQL_INNER)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
with transaction.atomic():
with connection.cursor() as cursor:
with transaction.atomic(), connection.cursor() as cursor:
cursor.execute(SQL_OUTER % SQL_INNER)
🧰 Tools
🪛 Ruff

186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Comment on lines +117 to +118
with transaction.atomic():
with connection.cursor() as cursor:
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Simplify nested with statements by combining them

The nested with statements at lines 117-118 can be combined into a single with statement for improved readability.

Here is the proposed change:

 def drop_variants_smallvariantsummary():
     """Drop the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute("DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
with transaction.atomic():
with connection.cursor() as cursor:
with transaction.atomic(), connection.cursor() as cursor:
🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Comment on lines +168 to +169
path(
"-.*",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use re_path() instead of path() for regex patterns

The pattern "-.*" includes regex wildcard characters. Since path() doesn't accept regex patterns and interprets the route parameter as a fixed string or with path converters, you should use re_path() for regex patterns.

Apply this diff to fix the issue:

-path(
+re_path(
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
path(
"-.*",
re_path(
"-.*",

Comment on lines +355 to 358
"api/query-case/category-presets/<str:category>/",
view=views_api.SmallVariantCategoryPresetsApiView.as_view(),
name="api-category-presets",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure category parameter validation matches previous constraints

The previous URL pattern for category-presets used a regex to restrict the category parameter to specific characters [a-zA-Z0-9\._-]+. The new str path converter in path() allows any non-empty string not containing /, which is more permissive and may introduce unintended inputs. To maintain the original input validation, consider using re_path() with the original regex pattern.

Apply this diff to enforce the same constraints as before:

-from django.urls import path
+from django.urls import path, re_path

...

-    path(
-        "api/query-case/category-presets/<str:category>/",
+    re_path(
+        r"^api/query-case/category-presets/(?P<category>[a-zA-Z0-9\._-]+)/$",
         view=views_api.SmallVariantCategoryPresetsApiView.as_view(),
         name="api-category-presets",
     ),

Committable suggestion was skipped due to low confidence.

Comment on lines +890 to +906
SOCIAL_AUTH_OIDC_OIDC_ENDPOINT = env.str("SOCIAL_AUTH_OIDC_OIDC_ENDPOINT", None)
SOCIAL_AUTH_OIDC_KEY = env.str("SOCIAL_AUTH_OIDC_KEY", "CHANGEME")
SOCIAL_AUTH_OIDC_SECRET = env.str("SOCIAL_AUTH_OIDC_SECRET", "CHANGEME")
SOCIAL_AUTH_OIDC_USERNAME_KEY = env.str("SOCIAL_AUTH_OIDC_USERNAME_KEY", "username")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure secure values for OIDC credentials

The SOCIAL_AUTH_OIDC_KEY and SOCIAL_AUTH_OIDC_SECRET are currently set to "CHANGEME". For secure authentication, replace these placeholders with the actual client ID and secret from your OIDC provider in your environment variables.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (6)
backend/genepanels/tests/test_models.py (1)

Line range hint 1-95: Summary of changes: URL structure update in test assertions

The changes in this file consistently add trailing slashes to URL assertions in test methods. This update likely reflects a broader change in the application's URL routing configuration. While these modifications are minor, they are crucial for maintaining accurate tests that reflect the expected behavior of the get_absolute_url methods.

Key points:

  1. Both TestGenePanelCategory and TestGenePanelEntry classes have been updated.
  2. The core logic of the tests remains unchanged.
  3. These changes suggest a global update to URL structures in the application.

Consider reviewing the entire codebase for any missed URL updates, especially in views, templates, and JavaScript files that may construct URLs. This will ensure consistency across the application and prevent potential routing issues.

backend/genepanels/forms.py (1)

27-31: LGTM! Consider optimizing the query for large datasets.

The changes improve the initialization of the "genes" field, providing a better user experience by populating the field with existing data for editing and starting empty for new instances. This is a good practice in Django forms.

For potential optimization, especially if dealing with large datasets, consider using values_list to fetch only the required field:

if self.instance.pk:
    rows = self.instance.genepanelentry_set.values_list('symbol', flat=True)
    initial_value = "\n".join(rows)
else:
    initial_value = ""

This approach reduces the amount of data fetched from the database, which could be beneficial for performance in cases with many gene entries.

backend/varfish/users/management/commands/initdev.py (2)

Line range hint 69-92: LGTM! Consider adding help text for --data-release and --data-case.

The new arguments enhance the flexibility of the initialization command, providing more control over the process. The choices for each argument are well-defined and align with different initialization scenarios.

Consider adding more descriptive help text for the --data-release and --data-case arguments to provide users with context about their impact on the initialization process.


Line range hint 94-117: LGTM! Consider adding error handling for invalid data_create values.

The changes in the handle method effectively incorporate the new data_create option. The use of a transaction ensures atomicity of operations, which is crucial for maintaining data consistency. The logic for handling different data_create options is clear and well-structured.

Consider adding an else clause to handle cases where data_create might have an unexpected value, even though it's constrained by the argument parser. This would make the code more robust against potential future changes.

backend/variants/migrations/0111_create_variant_summary.py (2)

14-17: Assess indexing strategy for optimal query performance

The current indexes on id and variant coordinates are useful, but depending on the query patterns against variants_smallvariantsummary, additional indexes might be beneficial. For instance, if queries frequently filter or join on chromosome and start, consider creating an index specifically on these columns.


12-12: Consider populating the materialized view immediately if necessary

The WITH NO DATA clause creates the materialized view without populating it. If immediate data availability is required after migration, you might want to remove WITH NO DATA or refresh the view after creation.

Alternatively, schedule a refresh after creation:

operations = [
    migrations.RunSQL(
        SQL_OUTER % SQL_INNER,
        """
        DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;
        """,
    ),
    migrations.RunPython(
        code=lambda apps, schema_editor: schema_editor.connection.cursor().execute("REFRESH MATERIALIZED VIEW variants_smallvariantsummary;"),
        reverse_code=migrations.RunPython.noop,
    ),
]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 85aac5f and 92fddf6.

📒 Files selected for processing (11)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/variants/tests/test_views_ajax_presets.py
🧰 Additional context used
🔇 Additional comments (11)
backend/seqmeta/tests/test_models.py (1)

15-15: LGTM! Consider verifying URL consistency.

The addition of a trailing slash to the expected URL is a good practice in Django. It helps prevent duplicate content issues and ensures consistent behavior.

To ensure consistency across the codebase, please run the following script:

This script will help verify that:

  1. Other test files use consistent URL assertions.
  2. The actual get_absolute_url methods return URLs with trailing slashes.
  3. URL patterns in urls.py files are consistent with this change.
backend/varannos/tests/test_models.py (1)

20-20: Approve URL format update with trailing slash.

The addition of a trailing slash to the expected URL in test_get_absolute_url is correct and aligns with Django's best practices for URL formatting. This change improves consistency and adheres to the standard URL structure.

To ensure consistency across the project, please run the following script to check for any other URLs that might need similar updates:

This script will help identify any other instances where URLs might need to be updated with trailing slashes for consistency.

backend/genepanels/tests/test_models.py (2)

51-51: LGTM! Check for similar changes in other test files.

The addition of a trailing slash to the expected URL is consistent with the previous change. This update ensures that the test accurately reflects the expected behavior of the get_absolute_url method for GenePanelEntry objects.

To ensure consistency across all test files, let's check for similar URL assertions:

✅ Verification successful

Verified: The trailing slash in URL assertions is consistent across all test files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for URL assertions in test files

# Test: Search for URL assertions in test files
rg --type python -g '**/tests/**/*.py' 'assertEqual.*get_absolute_url' -A 1

Length of output: 183


Script:

#!/bin/bash
# Description: Check for URL assertions in test files

# Test: Search for URL assertions in test files
rg --type py -g '**/tests/**/*.py' 'assertEqual.*get_absolute_url' -A 1

Length of output: 599


27-29: LGTM! Verify URL routing configuration.

The addition of a trailing slash to the expected URL is correct. This change likely reflects an update in the URL routing configuration of the application.

To ensure consistency across the application, let's verify the URL routing configuration:

✅ Verification successful

LGTM! URL routing is consistent with trailing slashes across the codebase.
The trailing slash added to the expected URL in the test aligns with the URL patterns defined in the urls.py files, ensuring consistency in URL routing.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check URL patterns in urls.py files for consistency with trailing slashes

# Test: Search for URL patterns in urls.py files
rg --type python -g 'urls.py' 'path\(' -A 3

Length of output: 183


Script:

#!/bin/bash
# Description: Check URL patterns in urls.py files for consistency with trailing slashes

# Test: Search for URL patterns in urls.py files
rg -g 'urls.py' 'path\(' -A 3

Length of output: 41538


Script:

#!/bin/bash
# Description: Check URL patterns in urls.py files for consistency with trailing slashes

# Test: Search for URL patterns in urls.py files
rg -g 'urls.py' 'path\(' -A 3

Length of output: 41538

backend/cases_qc/tests/test_views_api.py (1)

94-94: LGTM! Consider checking for similar occurrences.

The change from app_name to plugin_name in the app_settings.set() method call looks good. This update likely reflects changes in the AppSettingAPI interface or underlying implementation, possibly as part of a larger refactoring effort to improve plugin management or settings organization.

To ensure consistency across the codebase, it would be beneficial to check for other occurrences of app_settings.set() with app_name that might need similar updates. You can use the following script to identify potential locations:

This script will help identify other files that might need similar updates, ensuring consistency across the project.

✅ Verification successful

Issue with Previous Shell Script Execution

The previous script encountered an error due to the unrecognized file type python. To resolve this, let's modify the script to target .py files explicitly without using the --type flag.


Verification Inconclusive Due to Script Error

The previous script failed to search for app_settings.set() calls with app_name because the .ignore file was not found. As a result, we couldn't verify if there are other instances that need updating.


-->

Verification Complete: No Additional app_settings.set() Calls with app_name Found

The change from app_name to plugin_name in the app_settings.set() method call within backend/cases_qc/tests/test_views_api.py is confirmed to be the only instance requiring this update. No other occurrences of app_settings.set() with app_name were found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find other occurrences of app_settings.set() with app_name

# Search for app_settings.set() calls with app_name
echo "Searching for app_settings.set() calls with app_name:"
rg --type python 'app_settings\.set\(.*app_name' -g '!backend/cases_qc/tests/test_views_api.py'

# Search for AppSettingAPI imports
echo -e "\nSearching for AppSettingAPI imports:"
rg --type python 'from projectroles\.app_settings import AppSettingAPI'

Length of output: 439


Script:

#!/bin/bash
# Description: Find other occurrences of app_settings.set() with app_name by targeting .py files explicitly

# Search for app_settings.set() calls with app_name in .py files
echo "Searching for app_settings.set() calls with app_name in .py files:"
rg 'app_settings\.set\(.*app_name' -g '*.py' --ignore-file .ignore

# Search for AppSettingAPI imports in .py files
echo -e "\nSearching for AppSettingAPI imports in .py files:"
rg 'from projectroles\.app_settings import AppSettingAPI' -g '*.py'

Length of output: 1887


Script:

#!/bin/bash
# Description: Find other occurrences of app_settings.set() with app_name without using .ignore

# Search for app_settings.set() calls with app_name in .py files
echo "Searching for app_settings.set() calls with app_name in .py files:"
rg 'app_settings\.set\(.*app_name' -g '*.py'

# Search for AppSettingAPI imports in .py files
echo -e "\nSearching for AppSettingAPI imports in .py files:"
rg 'from projectroles\.app_settings import AppSettingAPI' -g '*.py'

Length of output: 1817

backend/varfish/users/management/commands/initdev.py (2)

285-285: LGTM! Improved naming convention.

The renaming of app_name to plugin_name in the settings configuration section is a good change. It more accurately reflects the context in which it's used, improving code clarity.


Line range hint 1-424: Overall, excellent improvements to the initialization command.

The changes in this file significantly enhance the functionality and flexibility of the initialization command for the development environment. The new command-line arguments allow for more granular control over the initialization process, particularly regarding data handling and project settings. The use of transactions ensures data consistency, and the improved naming conventions contribute to better code clarity.

These modifications will likely improve the developer experience when setting up and managing development environments, especially when dealing with different data scenarios.

backend/cases_import/tests/test_models_executor.py (1)

54-54: LGTM! Verify API compatibility.

The change from app_name to plugin_name in the app_settings.set() method call looks good. This likely reflects an update in the AppSettingAPI.

To ensure this change is consistent across the codebase, let's check for any other occurrences of app_settings.set() with app_name:

backend/variants/migrations/0111_create_variant_summary.py (2)

61-61: Confirm the exclusion logic in the WHERE clause

The WHERE NOT EXISTS condition relies on the excluded_case_ids CTE. Ensure that the logic correctly excludes only the intended case IDs and that there are no unintended side effects impacting data inclusion.

You can run the following script to list the excluded case IDs and verify they are correctly identified:

#!/bin/bash
# Description: List all case IDs that are being excluded.

# Test: Retrieve excluded case IDs. Expect: Only cases with 'exclude_from_inhouse_db' setting set to '1'.

psql -d your_database -c "
WITH excluded_case_ids AS (
    SELECT DISTINCT variants_case.id AS case_id
    FROM variants_case
    JOIN projectroles_project ON variants_case.project_id = projectroles_project.id
    JOIN projectroles_appsetting ON
        projectroles_project.id = projectroles_appsetting.project_id AND
        projectroles_appsetting.name = 'exclude_from_inhouse_db' AND
        projectroles_appsetting.value = '1'
)
SELECT * FROM excluded_case_ids;"

Review the output to ensure only the appropriate cases are excluded.


46-62: 🛠️ Refactor suggestion

Reassess the use of DISTINCT in the subquery for performance optimization

The SELECT DISTINCT in the subquery may introduce unnecessary overhead, especially with large datasets. Since the outer query performs a GROUP BY on the same columns, the DISTINCT might be redundant.

Consider removing DISTINCT to improve query performance:

-SELECT DISTINCT
+SELECT

To verify the impact of this change, you can compare the row counts with and without DISTINCT:

Check if both counts are equal to ensure the DISTINCT is unnecessary.

backend/cases_import/models/executors.py (1)

139-139: Verify consistent usage of plugin_name in app_settings.get() calls

The keyword argument has been changed from "app_name" to "plugin_name" in the app_settings.get() method. Please ensure that all other instances where AppSettingAPI.get() is called in the codebase also use "plugin_name" to maintain consistency and prevent potential bugs.

Run the following script to check for any remaining uses of "app_name":

✅ Verification successful

Please run the following script to comprehensively check for any remaining uses of "app_name" in app_settings.get() calls:


Consistent usage of plugin_name confirmed across all app_settings.get() calls.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usage of `app_settings.get()` with `app_name` as a keyword argument.

# Test: Search for `app_settings.get()` calls with `app_name` keyword. Expect: No matches found.

rg 'app_settings\.get\(\s*.*app_name=.*' --type py

Length of output: 52


Script:

# 
#!/bin/bash
# Description: Find all instances of app_settings.get() with app_name as a keyword argument, accounting for varying whitespace and argument positions.

rg 'app_settings\.get\(\s*[^)]*app_name\s*=' --type py

Length of output: 56

projectroles_appsetting.value = '1'
)
SELECT
row_number() OVER (PARTITION BY true) AS id,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure deterministic id generation in the materialized view

Using row_number() OVER (PARTITION BY true) may produce non-deterministic id values across different runs, which can lead to inconsistencies when the materialized view is refreshed. To ensure consistent id assignments, consider ordering the rows explicitly.

Apply this modification:

-row_number() OVER (PARTITION BY true) AS id,
+row_number() OVER (ORDER BY release, chromosome, start, "end", reference, alternative) AS id,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
row_number() OVER (PARTITION BY true) AS id,
row_number() OVER (ORDER BY release, chromosome, start, "end", reference, alternative) AS id,

Comment on lines +7 to +13
def is_migration_applied(app_name, migration_name):
recorder = MigrationRecorder(connection)
try:
return recorder.migration_qs.filter(app=app_name, name=migration_name).exists()
except utils.ProgrammingError:
return False # migration table does not exist yet
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid executing database queries at module level

The function is_migration_applied() is called at the module level and performs database queries during import time. This can lead to issues because the database may not be ready, and the migration tables might not exist yet. It's recommended to avoid database access at the module level in migration files.

Consider moving the database checks into the Migration class methods or using RunPython operations where the database is guaranteed to be accessible. This ensures that migrations do not fail due to unavailable database connections during the import phase.

Comment on lines 14 to 25
if not is_migration_applied('projectroles', '0001_initial'):
run_before = [] # fresh installation, will run projectroles squashed migrations
elif is_migration_applied('projectroles', '0032_alter_appsetting_value'):
run_before = [] # critical projectroles migration already applied
else:
# We will not execute the squashed projectroles migration 0001..0032 and the
# projectroles migration 0032 has not been applied yet.
run_before = [
("projectroles", "0032_alter_appsetting_value"),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Define run_before statically within the Migration class

Setting run_before at the module level based on database state introduces a dependency on the database at import time, which should be avoided. Migrations should not rely on the current state of the database when they are being loaded.

Refactor the code to define run_before statically within the Migration class without conditional logic based on database queries. If dynamic determination of run_before is necessary, consider handling it within the migration operations or adjusting the migration dependencies accordingly.

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch from 92fddf6 to 7bdd924 Compare October 9, 2024 15:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
backend/cases_import/tests/test_models_executor.py (1)

54-54: LGTM! Consider updating related documentation.

The change from app_name to plugin_name is a good improvement in terminology. This change likely reflects a conceptual shift in how the system is structured.

Consider reviewing and updating any related documentation or other parts of the codebase that might still use the term "app_name" to ensure consistency across the project.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 92fddf6 and 7bdd924.

📒 Files selected for processing (12)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/tests/helpers.py (3 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • backend/cases_import/models/executors.py
  • backend/cases_qc/tests/test_views_api.py
  • backend/genepanels/forms.py
  • backend/genepanels/tests/test_models.py
  • backend/seqmeta/tests/test_models.py
  • backend/varannos/tests/test_models.py
  • backend/varfish/users/management/commands/initdev.py
  • backend/variants/migrations/0110_drop_variant_summary.py
  • backend/variants/migrations/0111_create_variant_summary.py
  • backend/variants/tests/helpers.py
  • backend/variants/tests/test_views_ajax_presets.py
🧰 Additional context used

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch from 7bdd924 to 7c02f35 Compare October 10, 2024 07:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Outside diff range and nitpick comments (15)
backend/cases/urls.py (2)

14-80: LGTM: AJAX URL patterns updated correctly with room for optimization

All AJAX URL patterns have been successfully updated to use the path() function with appropriate UUID converters. The view references are consistent, using views_ajax for all patterns.

Consider refactoring these patterns to reduce repetition. You could create a helper function to generate URL patterns with common prefixes, like this:

def ajax_path(route, view, name):
    return path(f"ajax/{route}", view, name=f"ajax-{name}")

ajax_urlpatterns = [
    ajax_path("case/list/<uuid:project>/", views_ajax.CaseListAjaxView.as_view(), "case-list"),
    ajax_path("case/retrieve-update-destroy/<uuid:case>/", views_ajax.CaseRetrieveUpdateDestroyAjaxView.as_view(), "case-retrieveupdatedestroy"),
    # ... other patterns
]

This approach would make the URL configuration more maintainable and DRY (Don't Repeat Yourself).


Line range hint 82-153: Fix inconsistencies in API URL patterns

The API URL patterns have been updated to use path() with UUID converters, which is correct. However, there are some inconsistencies that need to be addressed:

  1. View references: Some patterns are using AJAX views instead of API views. Please update the following:

    • Line 129: Change view=views_ajax.CaseGeneAnnotationListAjaxView.as_view() to view=views_api.CaseGeneAnnotationListApiView.as_view()
    • Line 134: Change view=views_ajax.CaseAlignmentStatsListAjaxView.as_view() to view=views_api.CaseAlignmentStatsListApiView.as_view()
    • Line 139: Change view=views_ajax.SampleVariantStatisticsListAjaxView.as_view() to view=views_api.SampleVariantStatisticsListApiView.as_view()
    • Line 144: Change view=views_ajax.PedigreeRelatednessListAjaxView.as_view() to view=views_api.PedigreeRelatednessListApiView.as_view()
  2. Route prefix: The route on line 104 starts with "ajax/" instead of "api/". Please update it to:

    route="api/case-comment/retrieve-update-destroy/<uuid:casecomment>/",

After making these changes, ensure that the corresponding API views exist in the views_api.py file. If they don't, you may need to create them or update the existing AJAX views to handle both AJAX and API requests.

Similar to the AJAX patterns, consider refactoring these API URL patterns to reduce repetition. You could use the same approach suggested for the AJAX patterns to create a more maintainable and DRY configuration.

backend/varfish/users/management/commands/initdev.py (4)

Line range hint 63-85: LGTM! Consider adding validation for --data-case.

The new command-line arguments enhance the flexibility and specificity of the initialization process. The help messages are clear and informative.

Consider adding validation for the --data-case argument similar to --data-release and --data-create. This could prevent potential issues if an invalid case name is provided.

 parser.add_argument(
     "--data-case",
     default="Case_1",
-    choices=["Case_1"],
+    choices=["Case_1", "Case_2", "Case_3"],  # Add all valid case names
     help="Name of case to use when adding data or import job",
 )

Line range hint 87-114: LGTM! Consider adding a comment for clarity.

The updated handle method effectively incorporates the new data_create argument, providing flexibility in creating import jobs or cases directly. The use of transactions ensures data integrity.

Consider adding a brief comment explaining the different behaviors based on the data_create value for improved readability:

 def handle(self, *args, **options):
     """Entrypoint from command line"""
     _ = args
     category_name = options["category_name"]
     project_name = options["project_name"]
     case_name = options["case_name"]
     data_release = options["data_release"]
     data_case = options["data_case"]
     data_create = options["data_create"]

+    # Handle different scenarios based on data_create value:
+    # - "disabled": Create case directly
+    # - "job-create": Create import job and launch it asynchronously
+    # - "job-run": Create import job and run it synchronously
     job_pk: Optional[int] = None
     with transaction.atomic():
         job_pk = self._handle(
             category_name=category_name,
             project_name=project_name,
             case_name=case_name,
             data_release=data_release,
             data_case=data_case,
             data_create=data_create,
         )
     self.stderr.write(self.style.SUCCESS("-- comitting transaction --"))
     if data_create == "job-create" and job_pk is not None:
         tasks.run_caseimportactionbackgroundjob.delay(caseimportactionbackgroundjob_pk=job_pk)
         self.stderr.write(
             self.style.SUCCESS(f"Launched job (ID={job_pk}). Make sure that celery is running.")
         )
     elif data_create == "job-run" and job_pk is not None:
         self.stderr.write(self.style.SUCCESS("Executing import job..."))
         models.run_caseimportactionbackgroundjob(pk=job_pk)
         self.stderr.write(self.style.SUCCESS("... import job executed successfully."))

Line range hint 116-159: LGTM! Consider enhancing error handling.

The _handle method has been successfully updated to incorporate the new parameters and logic for creating import jobs. The changes align well with the new command-line arguments.

Consider enhancing the error handling to provide more specific error messages for different types of exceptions. This could help in debugging and troubleshooting. For example:

     try:
         self._setup_seqmeta()
         self._create_user(username="root", is_superuser=True, is_staff=True)
         self._create_user(username="devadmin", is_superuser=True, is_staff=True)
         devuser = self._create_user(username="devuser")
         category = self._create_project(
             title=category_name, owner=devuser, project_type="CATEGORY"
         )
         project = self._create_project(title=project_name, owner=devuser, parent=category)
         if data_create in ["job-create", "job-run"]:
             job = self._create_import_job(
                 case_name=case_name,
                 project=project,
                 data_release=data_release,
                 data_case=data_case,
                 user=devuser,
             )
             job_pk = job.pk
         else:  # data_create == "disabled"
             self._create_case(name=case_name, project=project)
         self.stderr.write(self.style.SUCCESS(self.style.SUCCESS("All done. Have a nice day!")))
-    except Exception as e:
+    except models.CaseImportBackgroundJob.DoesNotExist as e:
+        self.stderr.write(
+            self.style.ERROR(
+                f"Error creating import job: {str(e)}\n\n--- BEGIN TRACEBACK ---\n"
+                f"{traceback.format_exc()}--- END TRACEBACK ---\n"
+            )
+        )
+        raise CommandError("Could not create import job.") from e
+    except Project.DoesNotExist as e:
+        self.stderr.write(
+            self.style.ERROR(
+                f"Error creating project: {str(e)}\n\n--- BEGIN TRACEBACK ---\n"
+                f"{traceback.format_exc()}--- END TRACEBACK ---\n"
+            )
+        )
+        raise CommandError("Could not create project.") from e
+    except Exception as e:
         self.stderr.write(
             self.style.ERROR(
                 "A problem occured (see below). Rolling back database.\n\n--- BEGIN TRACEBACK ---\n"
                 f"{traceback.format_exc()}--- END TRACEBACK ---\n"
             )
         )
         raise CommandError("Could not initialize the database.") from e

     return job_pk

285-285: LGTM! Consider updating the variable name for consistency.

The renaming of app_name to plugin_name in the settings configuration section improves clarity and consistency with the rest of the codebase.

For complete consistency, consider updating the variable name in the surrounding code as well:

-    setting_value = {
+    plugin_settings = {
         "import_data_protocol": "file",
         "import_data_host": "",
         "import_data_path": str(pathlib.Path(__file__).parent.parent.parent.parent),
         "import_data_port": 0,
         "import_data_user": "",
     }
-    for setting_name, value in setting_value.items():
+    for setting_name, value in plugin_settings.items():
         if project_settings.get(setting_name) != value:
             app_settings.set(
                 plugin_name="cases_import",
                 setting_name=setting_name,
                 value=value,
                 project=project,
                 user=None,
             )
backend/cases_import/tests/test_models_executor.py (2)

Line range hint 279-297: Consider refactoring to reduce the number of mock patches.

The ImportCreateWithDragenQcTest class uses a large number of mock patches, which could make the test brittle to changes in the underlying implementation. Consider refactoring this test to use fewer, more general mocks or to use a fixture that sets up the necessary mocked environment.

For example, you could create a single mock for a DragenQcLoader class that handles all these individual loading functions, and then verify that this loader is called with the correct parameters.

Here's a conceptual example of how you might refactor this:

@mock.patch('cases_import.models.executors.DragenQcLoader')
def test_run(self, mock_dragen_qc_loader):
    mock_loader_instance = mock_dragen_qc_loader.return_value
    
    self.executor.run()
    
    # Verify that the loader was called with the correct parameters
    mock_loader_instance.load_all.assert_called_once_with(
        caseqc=mock.ANY,
        file_identifier_to_individual={"NA12878-PCRF450-1": "index"}
    )
    
    # You can still verify individual file loads if necessary
    mock_loader_instance.load_cnv_metrics.assert_called_once()
    mock_loader_instance.load_fragment_length_hist.assert_called_once()
    # ... and so on for other methods

This approach would make the test more resilient to changes in the underlying implementation while still verifying that all necessary data is loaded.

Also applies to: 298-516


Line range hint 1-724: Well-structured and comprehensive test suite with room for optimization.

The test suite in test_models_executor.py is comprehensive and covers various aspects of the case import process, including different QC file types and import actions. The tests are generally well-structured and provide good coverage of the functionality.

However, there are a few areas where the test suite could be improved:

  1. Some test classes, particularly ImportCreateWithDragenQcTest, use a large number of mock patches. This could make the tests brittle to changes in the underlying implementation. Consider refactoring these tests to use fewer, more general mocks or to use fixtures that set up the necessary mocked environment.

  2. The test file is quite long. Consider splitting it into multiple files, each focusing on a specific aspect of the import process (e.g., one file for Dragen QC tests, another for Samtools QC tests, etc.). This would improve maintainability and readability.

  3. Some test methods are quite long and complex. Consider breaking them down into smaller, more focused test methods to improve readability and make it easier to identify the cause of failures.

  4. There's some duplication in the setup code across different test classes. Consider extracting common setup code into utility methods or base classes to reduce duplication.

To address these points, you could:

  1. Implement the refactoring suggestion for ImportCreateWithDragenQcTest mentioned earlier.
  2. Split the file into multiple test files, e.g., test_dragen_qc_import.py, test_samtools_qc_import.py, etc.
  3. Break down long test methods into multiple, more focused methods.
  4. Create a common base class or utility methods for setup code that's shared across multiple test classes.

These changes would make the test suite more maintainable and easier to understand, while still maintaining its comprehensive coverage.

backend/seqvars/tests/test_permissions_api.py (4)

Line range hint 62-204: Consider refactoring for improved code reusability

The TestQueryPresetsSetViewSet class is well-structured, but there's potential for improvement in code reusability. Consider the following suggestions:

  1. Extract common user role definitions into class-level attributes.
  2. Create helper methods for common operations like URL generation and response assertion.
  3. Use parameterized tests to reduce code duplication in test methods.

These changes would make the tests more maintainable and easier to extend.

Here's an example of how you could refactor the class:

from parameterized import parameterized

class TestQueryPresetsSetViewSet(ProjectAPIPermissionTestBase):
    good_users = ["superuser", "user_owner", "user_delegate", "user_contributor", "user_guest"]
    bad_users_401 = ["anonymous"]
    bad_users_403 = ["user_no_roles", "user_finder_cat"]

    def setUp(self):
        super().setUp()
        self.querypresetsset = SeqvarsQueryPresetsSetFactory(project=self.project)

    def get_url(self, action, **kwargs):
        return reverse(f"seqvars:api-querypresetsset-{action}", kwargs={"project": self.project.sodar_uuid, **kwargs})

    @parameterized.expand([
        ("list", "GET", 200, 401, 403),
        ("create", "POST", 201, 401, 403),
        ("retrieve", "GET", 200, 401, 403),
        ("patch", "PATCH", 200, 401, 403),
        ("delete", "DELETE", 204, 401, 403),
    ])
    def test_endpoint(self, action, method, good_status, bad_status_401, bad_status_403):
        url = self.get_url(action, querypresetsset=self.querypresetsset.sodar_uuid if action != "list" else None)
        data = {"rank": 42} if action in ["create", "patch"] else None
        self.assert_response(url, self.good_users, good_status, method=method, data=data)
        self.assert_response(url, self.bad_users_401, bad_status_401, method=method, data=data)
        self.assert_response(url, self.bad_users_403, bad_status_403, method=method, data=data)

    # Add any specific test methods that require custom logic

This refactored version reduces code duplication and makes it easier to add or modify tests in the future.


Line range hint 205-355: Create a base test class for common functionality

The TestQueryPresetsVersionSetViewSet class has a very similar structure to TestQueryPresetsSetViewSet and potentially other test classes in this file. To reduce code duplication and improve maintainability, consider creating a base test class that implements the common functionality.

Here's an example of how you could implement this:

class BaseQueryPresetsTestCase(ProjectAPIPermissionTestBase):
    model_factory = None
    url_name = None

    good_users = ["superuser", "user_owner", "user_delegate", "user_contributor", "user_guest"]
    bad_users_401 = ["anonymous"]
    bad_users_403 = ["user_no_roles", "user_finder_cat"]

    def setUp(self):
        super().setUp()
        self.object = self.model_factory(project=self.project)

    def get_url(self, action, **kwargs):
        return reverse(f"seqvars:api-{self.url_name}-{action}", kwargs={"project": self.project.sodar_uuid, **kwargs})

    def test_list(self):
        url = self.get_url("list")
        self.assert_response(url, self.good_users, 200, method="GET")
        self.assert_response(url, self.bad_users_401, 401, method="GET")
        self.assert_response(url, self.bad_users_403, 403, method="GET")

    # Implement other common test methods (create, retrieve, patch, delete)

class TestQueryPresetsSetViewSet(BaseQueryPresetsTestCase):
    model_factory = SeqvarsQueryPresetsSetFactory
    url_name = "querypresetsset"

class TestQueryPresetsVersionSetViewSet(BaseQueryPresetsTestCase):
    model_factory = SeqvarsQueryPresetsSetVersionFactory
    url_name = "querypresetssetversion"

    def setUp(self):
        super().setUp()
        self.querypresetsset = SeqvarsQueryPresetsSetFactory(project=self.project)
        self.object = self.model_factory(
            presetsset=self.querypresetsset,
            status=SeqvarsQueryPresetsSetVersion.STATUS_DRAFT,
        )

    # Implement only unique test methods or override if necessary

This approach would significantly reduce code duplication across your test classes and make it easier to maintain and extend your test suite.


Line range hint 356-2347: Implement comprehensive test suite refactoring

The entire test file follows a repetitive structure across all test classes. This repetition emphasizes the need for a more maintainable and scalable approach to your test suite. Consider implementing a comprehensive refactoring of the entire test file to improve code reusability, maintainability, and readability.

Here's a suggested approach for refactoring the entire test suite:

  1. Create a base test class:

    class BaseAPIPermissionTestCase(ProjectAPIPermissionTestBase):
        model_factory = None
        url_name = None
        nested_url = False
    
        good_users = ["superuser", "user_owner", "user_delegate", "user_contributor", "user_guest"]
        bad_users_401 = ["anonymous"]
        bad_users_403 = ["user_no_roles", "user_finder_cat"]
    
        def setUp(self):
            super().setUp()
            self.object = self.create_test_object()
    
        def create_test_object(self):
            return self.model_factory(project=self.project)
    
        def get_url(self, action, **kwargs):
            url_kwargs = {"project": self.project.sodar_uuid} if not self.nested_url else {}
            url_kwargs.update(kwargs)
            return reverse(f"seqvars:api-{self.url_name}-{action}", kwargs=url_kwargs)
    
        def run_test(self, action, method, good_status, bad_status_401, bad_status_403, data=None):
            url = self.get_url(action, **{self.url_name: self.object.sodar_uuid} if action != "list" else {})
            self.assert_response(url, self.good_users, good_status, method=method, data=data)
            self.assert_response(url, self.bad_users_401, bad_status_401, method=method, data=data)
            self.assert_response(url, self.bad_users_403, bad_status_403, method=method, data=data)
    
        def test_list(self):
            self.run_test("list", "GET", 200, 401, 403)
    
        def test_create(self):
            data = self.get_create_data()
            self.run_test("list", "POST", 201, 401, 403, data=data)
    
        def test_retrieve(self):
            self.run_test("detail", "GET", 200, 401, 403)
    
        def test_patch(self):
            data = self.get_patch_data()
            self.run_test("detail", "PATCH", 200, 401, 403, data=data)
    
        def test_delete(self):
            self.run_test("detail", "DELETE", 204, 401, 403)
    
        def get_create_data(self):
            return {"rank": 1, "label": "test"}
    
        def get_patch_data(self):
            return {"rank": 42}
  2. Create specific test classes for each API endpoint:

    class TestQueryPresetsSetViewSet(BaseAPIPermissionTestCase):
        model_factory = SeqvarsQueryPresetsSetFactory
        url_name = "querypresetsset"
    
    class TestQueryPresetsVersionSetViewSet(BaseAPIPermissionTestCase):
        model_factory = SeqvarsQueryPresetsSetVersionFactory
        url_name = "querypresetssetversion"
        nested_url = True
    
        def create_test_object(self):
            self.querypresetsset = SeqvarsQueryPresetsSetFactory(project=self.project)
            return self.model_factory(
                presetsset=self.querypresetsset,
                status=SeqvarsQueryPresetsSetVersion.STATUS_DRAFT,
            )
    
        def get_url(self, action, **kwargs):
            url_kwargs = {"querypresetsset": self.querypresetsset.sodar_uuid}
            url_kwargs.update(kwargs)
            return super().get_url(action, **url_kwargs)
    
    # Implement other test classes similarly
  3. For classes with unique requirements, override only the necessary methods:

    class TestQuerySettingsViewSet(BaseAPIPermissionTestCase):
        model_factory = SeqvarsQuerySettingsFactory
        url_name = "querysettings"
        nested_url = True
    
        def create_test_object(self):
            self.case = CaseFactory(project=self.project)
            self.caseanalysis = CaseAnalysisFactory(case=self.case)
            self.session = CaseAnalysisSessionFactory(caseanalysis=self.caseanalysis)
            return self.model_factory(session=self.session)
    
        def get_url(self, action, **kwargs):
            url_kwargs = {"session": self.session.sodar_uuid}
            url_kwargs.update(kwargs)
            return super().get_url(action, **url_kwargs)
    
        def get_create_data(self):
            return {
                "genotype": SeqvarsQuerySettingsGenotypeSerializer(
                    SeqvarsQuerySettingsGenotypeFactory.build(querysettings=None)
                ).data,
                # Include other nested serializers here
            }

This refactoring will significantly reduce code duplication, improve maintainability, and make it easier to add new test cases or modify existing ones. It also allows for easy customization of specific test classes when needed.


Line range hint 1-2347: Summary: Comprehensive tests with room for improvement

The test_permissions_api.py file provides a thorough set of tests for API permissions across various endpoints. The current implementation is functional and covers all necessary scenarios. However, the repetitive structure presents an opportunity for significant improvement in terms of code maintainability, readability, and scalability.

Key suggestions for improvement:

  1. Implement a base test class to encapsulate common functionality.
  2. Use parameterized tests to reduce code duplication.
  3. Extract common user role definitions and URL generation logic.
  4. Refactor individual test classes to inherit from the base class and override only when necessary.

These changes would result in a more maintainable and easily extendable test suite, making it easier to add new tests or modify existing ones as the API evolves.

Consider implementing the comprehensive refactoring suggested in the previous comments to improve the overall structure and maintainability of the test suite.

backend/svs/urls.py (2)

2-2: Consider importing include if needed for URL inclusions.

At line 2, you have imported path and re_path from django.urls. If you plan to include other URL configurations using include(), ensure to import it as well:

from django.urls import path, re_path, include

If include is not needed, you can disregard this comment.


Line range hint 140-146: Review the use of a greedy regex pattern to prevent unintended matches.

The pattern (?P<url>.*) in:

re_path(
    r"^tracks/(?P<url>.*)$",
    HttpProxy.as_view(
        base_url=f"{settings.WORKER_REST_BASE_URL}/public/tracks/",
        ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
    ),
),

is greedy and will match any character sequence, including empty strings. This might lead to unexpected behavior or security issues. Consider the following:

  • Ensure that the url parameter doesn't match unintended paths.
  • Add input validation or sanitization for the url parameter within HttpProxy to prevent security vulnerabilities like path traversal attacks.

Alternatively, if the pattern should not match empty strings, adjust the regex:

-re_path(
-    r"tracks/(?P<url>.*)",
+re_path(
+    r"tracks/(?P<url>.+)",
    HttpProxy.as_view(
        base_url=f"{settings.WORKER_REST_BASE_URL}/public/tracks/",
        ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
    ),
),

This ensures that url captures at least one character.

backend/config/settings/base.py (1)

438-438: Consider making 'ADMIN_URL' configurable and non-default for enhanced security

By hardcoding the ADMIN_URL to 'admin/', you expose the default admin URL, which is commonly known and could be a target for unauthorized access attempts. It is a best practice to make the admin URL configurable via environment variables and set it to a non-standard value.

Apply this diff to make ADMIN_URL configurable:

-ADMIN_URL = "admin/"
+ADMIN_URL = env.str("ADMIN_URL", "admin/")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7bdd924 and 7c02f35.

⛔ Files ignored due to path filters (1)
  • backend/Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (78)
  • .github/workflows/main.yml (1 hunks)
  • backend/Makefile (1 hunks)
  • backend/Pipfile (4 hunks)
  • backend/beaconsite/tests/test_permissions.py (3 hunks)
  • backend/beaconsite/tests/test_permissions_ajax.py (2 hunks)
  • backend/beaconsite/tests/test_permissions_api.py (3 hunks)
  • backend/beaconsite/tests/test_views_ajax.py (1 hunks)
  • backend/beaconsite/urls.py (1 hunks)
  • backend/cases/tests/test_permissions.py (1 hunks)
  • backend/cases/tests/test_permissions_ajax.py (12 hunks)
  • backend/cases/tests/test_permissions_api.py (11 hunks)
  • backend/cases/tests/test_views.py (1 hunks)
  • backend/cases/tests/test_views_ajax.py (12 hunks)
  • backend/cases/urls.py (1 hunks)
  • backend/cases_analysis/tests/test_permissions_api.py (2 hunks)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_import/tests/test_permissions_api.py (1 hunks)
  • backend/cases_qc/tests/test_permissions_api.py (2 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/cohorts/migrations/0008_alter_cohort_user.py (1 hunks)
  • backend/cohorts/tests/test_permissions_ajax.py (3 hunks)
  • backend/cohorts/tests/test_permissions_api.py (3 hunks)
  • backend/cohorts/tests/test_views_ui.py (1 hunks)
  • backend/cohorts/urls.py (1 hunks)
  • backend/config/settings/base.py (3 hunks)
  • backend/config/urls.py (5 hunks)
  • backend/ext_gestaltmatcher/migrations/0003_alter_smallvariantquerygestaltmatcherscores_id_and_more.py (1 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/genepanels/tests/test_permissions.py (2 hunks)
  • backend/genepanels/urls.py (1 hunks)
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1 hunks)
  • backend/importer/urls.py (1 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/seqmeta/tests/test_permissions.py (2 hunks)
  • backend/seqmeta/urls.py (2 hunks)
  • backend/seqvars/tests/test_permissions_api.py (17 hunks)
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_presets.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_queries.py (6 hunks)
  • backend/svs/urls.py (2 hunks)
  • backend/varannos/tests/helpers.py (3 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_permissions.py (1 hunks)
  • backend/varannos/tests/test_permissions_api.py (1 hunks)
  • backend/varannos/urls.py (2 hunks)
  • backend/varfish/templates/users/login.html (1 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/varfish/users/urls.py (1 hunks)
  • backend/varfish/vueapp/urls.py (1 hunks)
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/models/maintenance.py (1 hunks)
  • backend/variants/tests/helpers.py (3 hunks)
  • backend/variants/tests/test_file_export.py (2 hunks)
  • backend/variants/tests/test_permissions_ajax.py (6 hunks)
  • backend/variants/tests/test_permissions_ajax_annos.py (1 hunks)
  • backend/variants/tests/test_permissions_ajax_presets.py (29 hunks)
  • backend/variants/tests/test_permissions_api.py (7 hunks)
  • backend/variants/tests/test_ui.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
  • backend/variants/urls/init.py (2 hunks)
  • backend/variants/urls/annos.py (1 hunks)
  • backend/variants/urls/presets.py (2 hunks)
  • frontend/ext/reev-frontend-lib (1 hunks)
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (1 hunks)
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4 hunks)
  • frontend/src/varfish/components/FilterForm/DevPane.vue (2 hunks)
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/EffectPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FlagsPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3 hunks)
  • frontend/src/variants/components/FilterForm/QualityPane.vue (1 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetProperties.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (61)
  • .github/workflows/main.yml
  • backend/Makefile
  • backend/Pipfile
  • backend/beaconsite/tests/test_permissions.py
  • backend/beaconsite/tests/test_permissions_ajax.py
  • backend/beaconsite/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_views_ajax.py
  • backend/beaconsite/urls.py
  • backend/cases/tests/test_permissions.py
  • backend/cases/tests/test_permissions_api.py
  • backend/cases/tests/test_views.py
  • backend/cases/tests/test_views_ajax.py
  • backend/cases_analysis/tests/test_permissions_api.py
  • backend/cases_import/models/executors.py
  • backend/cases_import/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_views_api.py
  • backend/cohorts/migrations/0008_alter_cohort_user.py
  • backend/cohorts/tests/test_permissions_ajax.py
  • backend/cohorts/tests/test_permissions_api.py
  • backend/cohorts/tests/test_views_ui.py
  • backend/ext_gestaltmatcher/migrations/0003_alter_smallvariantquerygestaltmatcherscores_id_and_more.py
  • backend/genepanels/forms.py
  • backend/genepanels/tests/test_models.py
  • backend/genepanels/tests/test_permissions.py
  • backend/genepanels/urls.py
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py
  • backend/seqmeta/tests/test_models.py
  • backend/seqmeta/tests/test_permissions.py
  • backend/seqmeta/urls.py
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py
  • backend/svs/tests/test_permissions_ajax_presets.py
  • backend/svs/tests/test_permissions_ajax_queries.py
  • backend/varannos/tests/helpers.py
  • backend/varannos/tests/test_models.py
  • backend/varannos/tests/test_permissions.py
  • backend/varannos/tests/test_permissions_api.py
  • backend/varfish/users/urls.py
  • backend/varfish/vueapp/urls.py
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py
  • backend/variants/migrations/0110_drop_variant_summary.py
  • backend/variants/migrations/0111_create_variant_summary.py
  • backend/variants/tests/helpers.py
  • backend/variants/tests/test_file_export.py
  • backend/variants/tests/test_permissions_ajax.py
  • backend/variants/tests/test_permissions_ajax_annos.py
  • backend/variants/tests/test_permissions_api.py
  • backend/variants/tests/test_views_ajax_presets.py
  • backend/variants/urls/annos.py
  • frontend/ext/reev-frontend-lib
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue
  • frontend/src/varfish/components/FilterForm/DevPane.vue
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue
  • frontend/src/variants/components/FilterForm/EffectPane.vue
  • frontend/src/variants/components/FilterForm/FlagsPane.vue
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue
  • frontend/src/variants/components/FilterForm/QualityPane.vue
  • frontend/src/variants/components/QueryPresets/SetEditor.vue
  • frontend/src/variants/components/QueryPresets/SetProperties.vue
🧰 Additional context used
🪛 Ruff
backend/variants/models/maintenance.py

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

🔇 Additional comments (110)
backend/varannos/urls.py (7)

7-11: Excellent update to modern Django URL pattern!

The change from regex-based url() to path-based path() is a great improvement. It enhances readability and leverages Django's built-in path converters for type safety. The <uuid:project> syntax ensures that only valid UUIDs will match this route.


12-16: Consistent improvement in URL pattern definition!

This change follows the same pattern as the previous one, replacing the regex-based url() with the more modern path() function. The use of <uuid:varannoset> maintains type safety and consistency across the URL patterns.


22-26: Excellent update to API URL pattern!

This change continues the trend of modernizing URL patterns. The use of path() with <uuid:project> improves readability and type safety. It's worth noting that this API endpoint combines list and create operations, which aligns well with RESTful design principles.


27-31: Consistent improvement in API URL pattern!

This change maintains the pattern of updating to path() with UUID type checking. The endpoint combines retrieve, update, and destroy operations, which is a good example of a RESTful resource-oriented API design. This approach reduces the number of endpoints needed while providing full CRUD functionality.


32-36: Consistent API pattern applied to VarAnnoSetEntry!

The update to path() with <uuid:varannoset> maintains the consistency we've seen in previous changes. It's good to see this pattern applied consistently across different models (VarAnnoSet and now VarAnnoSetEntry). This consistency in API design will make the codebase more maintainable and easier for developers to work with.


37-41: Excellent consistency in API URL patterns!

This final URL pattern change completes the update to modern Django URL routing for the varannos app. The use of path() with <uuid:varannosetentry> maintains the consistency and type safety we've seen throughout the file.

Overall, these changes bring several benefits:

  1. Improved readability and maintainability of URL patterns.
  2. Enhanced type safety with explicit UUID path converters.
  3. Consistent RESTful API design across different models.
  4. Modernized Django practices, moving away from deprecated url() function.

Great job on implementing these improvements consistently across all URL patterns!


Line range hint 1-46: Excellent modernization of URL routing!

This update to the urls.py file represents a significant improvement in several areas:

  1. Modernization: The transition from url() to path() aligns with current Django best practices.
  2. Readability: The new URL patterns are more intuitive and easier to understand at a glance.
  3. Type Safety: The use of path converters (e.g., <uuid:project>) ensures that only valid UUIDs will match these routes, reducing the risk of runtime errors.
  4. Consistency: The changes have been applied uniformly across all URL patterns, maintaining a cohesive structure.
  5. RESTful Design: The API endpoints follow RESTful principles, combining related operations (e.g., list-create, retrieve-update-destroy) into single endpoints.

These improvements will contribute to easier maintenance, better code quality, and a more robust API structure. Great work on implementing these changes consistently throughout the file!

backend/importer/urls.py (17)

4-4: LGTM: Correct import for Django's path function

The change from url to path import is correct and aligns with Django's current best practices for URL routing.


11-11: LGTM: Correct transition to path() for import-info URL

The URL pattern has been correctly updated to use the path() function. The trailing slash is added, which is consistent with Django's URL patterns.


12-16: LGTM: Improved readability with path converters

The URL pattern has been correctly updated to use the path() function. The use of <uuid:project> and <uuid:job> path converters improves readability and maintainability compared to the previous regex pattern.


20-24: LGTM: Correct transition to path() for case-import-info API URL

The URL pattern has been correctly updated to use the path() function. The <uuid:project> path converter is appropriately used for the UUID field.


25-29: LGTM: Improved clarity with path converters for case-import-info detail API URL

The URL pattern has been correctly updated to use the path() function. The use of <uuid:project> and <uuid:caseimportinfo> path converters significantly improves readability and maintainability compared to the previous regex pattern.


30-34: LGTM: Correct transition to path() for variant-set-import-info API URL

The URL pattern has been correctly updated to use the path() function. The <uuid:caseimportinfo> path converter is appropriately used for the UUID field.


35-39: LGTM: Enhanced readability for variant-set-import-info detail API URL

The URL pattern has been correctly updated to use the path() function. The use of <uuid:caseimportinfo> and <uuid:variantsetimportinfo> path converters greatly improves readability and maintainability compared to the previous regex pattern.


40-44: LGTM: Correct transition to path() for bam-qc-file API URL

The URL pattern has been correctly updated to use the path() function. The <uuid:caseimportinfo> path converter is appropriately used for the UUID field.


45-49: LGTM: Improved clarity for bam-qc-file detail API URL

The URL pattern has been correctly updated to use the path() function. The use of <uuid:caseimportinfo> and <uuid:bamqcfile> path converters significantly enhances readability and maintainability compared to the previous regex pattern.


50-54: LGTM: Correct transition to path() for case-gene-annotation-file API URL

The URL pattern has been correctly updated to use the path() function. The <uuid:caseimportinfo> path converter is appropriately used for the UUID field.


55-59: LGTM: Greatly enhanced readability for case-gene-annotation-file detail API URL

The URL pattern has been correctly updated to use the path() function. The use of <uuid:caseimportinfo> and <uuid:casegeneannotationfile> path converters dramatically improves readability and maintainability compared to the previous complex regex pattern.


60-64: LGTM: Correct transition to path() for genotype-file API URL

The URL pattern has been correctly updated to use the path() function. The <uuid:variantsetimportinfo> path converter is appropriately used for the UUID field.


65-69: LGTM: Improved clarity for genotype-file detail API URL

The URL pattern has been correctly updated to use the path() function. The use of <uuid:variantsetimportinfo> and <uuid:genotypefile> path converters significantly enhances readability and maintainability compared to the previous regex pattern.


70-74: LGTM: Correct transition to path() for effects-file API URL

The URL pattern has been correctly updated to use the path() function. The <uuid:variantsetimportinfo> path converter is appropriately used for the UUID field.


75-79: LGTM: Enhanced readability for effects-file detail API URL

The URL pattern has been correctly updated to use the path() function. The use of <uuid:variantsetimportinfo> and <uuid:effectsfile> path converters greatly improves readability and maintainability compared to the previous regex pattern.


80-89: LGTM: Successful transition to path() for all URL patterns

The final two URL patterns for database-info-file API have been correctly updated to use the path() function. The use of <uuid:variantsetimportinfo> and <uuid:databaseinfofile> path converters enhances readability and maintainability.

Overall, this file has been successfully updated to use Django's modern URL routing system. The changes improve code readability, maintainability, and align with best practices.


1-89: Excellent update: Modernized URL routing with improved readability

This update successfully transitions all URL patterns from the deprecated url() function to the modern path() function. Key improvements include:

  1. Consistent use of path converters (<uuid:...>) for UUID fields, enhancing type safety.
  2. Significantly improved readability and maintainability of URL patterns.
  3. Alignment with Django's current best practices for URL routing.

These changes will make the codebase easier to understand and maintain. Great job on this comprehensive update!

backend/cases/urls.py (3)

1-5: LGTM: Imports and app_name are correct

The imports have been updated to use path from django.urls, which is consistent with the changes made in the URL patterns. The app_name is correctly set to "cases".


6-12: LGTM: UI URL pattern updated correctly

The UI URL pattern has been successfully updated to use the path() function with a UUID converter for the project parameter. This change improves type safety and aligns with Django's best practices.


Line range hint 1-157: Summary: URL patterns updated with minor issues to address

Overall, the update from url() to path() has been successfully implemented across all URL patterns in this file. The use of UUID converters enhances type safety and aligns with Django best practices.

Key points:

  1. UI and AJAX URL patterns are correctly updated and consistent.
  2. API URL patterns have been updated but contain some inconsistencies that need to be addressed (view references and route prefixes).
  3. Suggestions for refactoring both AJAX and API URL patterns have been provided to improve maintainability.

Next steps:

  1. Fix the inconsistencies in the API URL patterns as detailed in the previous comment.
  2. Consider implementing the suggested refactoring to reduce repetition in both AJAX and API URL patterns.
  3. After making these changes, thoroughly test all endpoints to ensure they're functioning as expected.
backend/variants/tests/test_ui.py (1)

164-164: LGTM! Verify usage of the renamed class.

The renaming of TestUIBase to UITestBase and the change in the parent class look good. This change aligns with modern naming conventions and likely reflects updates in the projectroles package.

To ensure this change doesn't break any existing code, please run the following script to check for any remaining references to the old class name:

✅ Verification successful

All references to TestUIBase have been successfully updated.

No remaining occurrences of TestUIBase were found in the codebase, ensuring the renaming to UITestBase is complete and does not affect other parts of the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to TestUIBase
rg "TestUIBase" --type python

Length of output: 60


Script:

#!/bin/bash
# Search for any remaining references to TestUIBase in Python files
rg "TestUIBase" --glob "*.py"

Length of output: 29

backend/config/urls.py (6)

29-29: LGTM: Home URL pattern updated correctly

The update from url() to path() for the home view is correct and follows the recommended Django URL routing syntax.


36-70: LGTM: VarFish URL patterns updated correctly

The URL patterns for VarFish have been successfully updated to use path() instead of url(). These changes improve readability and follow Django's recommended practices for URL routing.


94-95: LGTM: Proxy URL patterns updated correctly

The proxy URL patterns have been correctly updated to use re_path() instead of url(). This change is appropriate as these patterns contain regular expressions, and re_path() is the recommended function for such cases in Django's new URL routing syntax.

Also applies to: 102-103, 110-111, 117-118, 124-125, 132-133, 139-140


182-193: LGTM: Development URL patterns updated correctly

The URL patterns for development, including error pages and debug toolbar, have been correctly updated to use path() instead of url(). These changes align with Django's recommended practices for URL routing.

Also applies to: 198-198


Line range hint 1-198: Overall assessment: URL routing update is mostly correct and beneficial

The update from url() to path() and re_path() throughout the file is a positive change that aligns with Django's current best practices for URL routing. This update improves code readability and maintainability. Most changes have been implemented correctly, with only minor issues noted:

  1. The import statement for include should be updated to use django.urls instead of django.conf.urls.
  2. The frontend serving pattern should use re_path() instead of path() due to the presence of a regex wildcard.

After addressing these minor issues, the URL routing configuration will be fully compliant with Django's recommended practices.


168-169: ⚠️ Potential issue

Use re_path() instead of path() for regex patterns

The pattern "-.*" includes a regex wildcard character. Since path() doesn't accept regex patterns and interprets the route parameter as a fixed string or with path converters, you should use re_path() for regex patterns.

Apply this diff to fix the issue:

-        path(
+        re_path(
             "-.*",
             ServeStringView.as_view(),
             name="vueapp-entrypoint",
         )

Likely invalid or redundant comment.

backend/varfish/users/management/commands/initdev.py (1)

Line range hint 1-458: Overall, the changes look good and enhance the functionality of the initdev command.

The updates to the Command class in initdev.py successfully implement new features for specifying genome release, case name, and options for running import jobs. The changes are well-structured and align with the PR objectives of upgrading to sodar core v1.

Key improvements:

  1. Added new command-line arguments for more flexible initialization.
  2. Updated the handle method to support different scenarios based on the data_create value.
  3. Modified the _handle method to incorporate new parameters and logic for creating import jobs.
  4. Renamed app_name to plugin_name in the _create_project method for better consistency.

Minor suggestions have been made to further improve code clarity and error handling, but these are not critical issues. The overall implementation is solid and ready for integration.

backend/cases/tests/test_permissions_ajax.py (14)

10-10: LGTM: Base class updated correctly.

The TestCaseAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


97-97: LGTM: Base class updated correctly.

The TestCasePhenotypeTermsCreateListAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


152-152: LGTM: Base class updated correctly.

The TestAnnotationReleaseInfoListAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


178-178: LGTM: Base class updated correctly.

The TestSvAnnotationReleaseInfoListAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


204-204: LGTM: Base class updated correctly.

The TestCasePhenotypeTermsRetrieveUpdateDestroyAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


288-288: LGTM: Base class updated correctly.

The TestCaseCommentCreateListAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


336-336: LGTM: Base class updated correctly.

The TestCaseCommentRetrieveUpdateDestroyAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


416-416: LGTM: Base class updated correctly.

The TestCaseGeneAnnotationListAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


442-442: LGTM: Base class updated correctly.

The TestProjectUserPermissionsAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


465-465: LGTM: Base class updated correctly.

The TestCaseAlignmentStatsListAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


491-491: LGTM: Base class updated correctly.

The TestSampleVariantStatisticsListAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


517-517: LGTM: Base class updated correctly.

The TestPedigreeRelatednessListAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent with the new base class usage throughout the file.


Line range hint 1-542: Summary: Consistent update of base class for permission testing

The changes in this file involve updating the base class for all test classes from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change has been applied consistently across all 12 test classes in the file. The test implementations themselves remain unchanged, which suggests that the new base class provides the same interface as the old one.

To ensure the completeness of this refactoring effort:

  1. Verify that the ProjectAPIPermissionTestBase class is properly implemented and provides all necessary methods and attributes used in these tests.
  2. Check if this change is part of a larger update to the testing framework or conventions in the project.
  3. Run the test suite to confirm that all tests still pass with the new base class.

To verify the consistency of this change across the entire project, you can run the following command:

#!/bin/bash
# Search for any remaining usage of the old base class name in Python files
rg "TestProjectAPIPermissionBase" --type python

# Search for the new base class usage to ensure it's used consistently
rg "ProjectAPIPermissionTestBase" --type python

This will help ensure that the base class has been updated consistently across all relevant files in the project.


4-4: Verify the import and usage of the new base class.

The base class for permission testing has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change appears to be consistent throughout the file. Please ensure that:

  1. The new base class ProjectAPIPermissionTestBase provides all the necessary methods and attributes used in these tests.
  2. This change is part of a broader update to the testing framework or conventions.
  3. The functionality of the tests remains unchanged with this new base class.

To verify the consistency of this change across the project, you can run the following command:

This will help ensure that the base class has been updated consistently across all relevant files.

✅ Verification successful

Import and usage of the new base class are consistent across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of the old base class name
rg "TestProjectAPIPermissionBase" --type python

Length of output: 157


Script:

#!/bin/bash
# Search for any remaining usage of the old base class name using the correct file type
rg "TestProjectAPIPermissionBase" --type py

Length of output: 43

backend/cases_import/tests/test_models_executor.py (1)

54-54: Verify the impact of changing app_name to plugin_name.

The parameter name in app_settings.set() has been changed from app_name to plugin_name. This change might be part of a larger refactoring effort or a change in the underlying API.

To ensure this change is consistent across the codebase, run the following script:

This will help verify if the change has been applied consistently throughout the project.

backend/variants/tests/test_permissions_ajax_presets.py (6)

17-17: LGTM: Consistent base class update.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring mentioned in the summary. This update helps standardize the test setup across different test classes.


64-64: LGTM: Consistent base class update.

The change to ProjectAPIPermissionTestBase is consistent with the overall refactoring effort, maintaining uniformity across test classes.


140-140: LGTM: Consistent base class update.

The change to ProjectAPIPermissionTestBase maintains consistency with the refactoring pattern observed in other test classes.


167-167: LGTM: Consistent base class update.

The change to ProjectAPIPermissionTestBase aligns with the refactoring pattern seen in other test classes, maintaining consistency throughout the test suite.


195-195: LGTM: Consistent base class update.

The change to ProjectAPIPermissionTestBase continues the consistent refactoring pattern observed in other test classes.


Line range hint 242-1271: LGTM: Comprehensive and consistent refactoring across all test classes.

All remaining test classes in this file have been consistently updated to inherit from ProjectAPIPermissionTestBase. This systematic change indicates a well-executed refactoring effort aimed at standardizing the test setup across different preset types and operations. The internal structure and test methods of each class remain unchanged, which helps maintain the integrity of the existing test coverage while potentially leveraging new functionality provided by the new base class.

Classes affected by this change include:

  • TestImpactPresetsRetrieveUpdateDestroyAjaxView
  • TestImpactPresetsCloneFactoryDefaultsView
  • TestImpactPresetsCloneOtherView
  • TestQualityPresetsListCreateAjaxView
  • TestQualityPresetsRetrieveUpdateDestroyAjaxView
  • TestQualityPresetsCloneFactoryDefaultsView
  • TestQualityPresetsCloneOtherView
  • TestChromosomePresetsListCreateAjaxView
  • TestChromosomePresetsRetrieveUpdateDestroyAjaxView
  • TestChromosomePresetsCloneFactoryDefaultsView
  • TestChromosomePresetsCloneOtherView
  • TestFlagsEtcPresetsListCreateAjaxView
  • TestFlagsEtcPresetsRetrieveUpdateDestroyAjaxView
  • TestFlagsEtcPresetsCloneFactoryDefaultsView
  • TestFlagsEtcPresetsCloneOtherView
  • TestQuickPresetsListCreateAjaxView
  • TestQuickPresetsRetrieveUpdateDestroyAjaxView
  • TestQuickPresetsCloneOtherView
  • TestPresetSetListCreateAjaxView
  • TestPresetSetListAllAjaxView
  • TestPresetSetRetrieveUpdateDestroyAjaxView
  • TestPresetSetCloneFactoryDefaultsView
  • TestPresetSetCloneOtherView

This refactoring enhances the maintainability and consistency of the test suite.

backend/cohorts/urls.py (15)

4-4: Updated import statement to use path from django.urls

The import statement correctly imports path from django.urls, which is necessary for using the path() function in place of the deprecated url() function.


10-13: UI URL pattern updated with path() and <uuid:project> converter

The UI URL pattern for the entry point is correctly updated to use path() with the <uuid:project> converter, enhancing readability and adhering to modern Django practices.


18-21: AJAX URL pattern for cohort list and creation updated

The AJAX URL pattern for listing and creating cohorts now uses path() with <uuid:project>, which aligns with the updated URL routing conventions.


23-26: AJAX URL pattern for cohort retrieve, update, and destroy updated

The URL pattern is correctly modified to use path() with <uuid:cohort> for cohort retrieval, updating, and deletion operations.


28-31: AJAX URL pattern for cohort case creation updated

The pattern for creating cohort cases now uses path() with <uuid:project>, ensuring consistency across the URL configurations.


33-36: AJAX URL pattern for cohort case listing updated

Updated to use path() with <uuid:cohort>, the URL pattern for listing cohort cases is correctly aligned with the new syntax.


38-41: AJAX URL pattern for cohort case deletion updated

The deletion URL pattern now uses path() with <uuid:cohortcase>, reflecting the appropriate path converter usage.


43-46: AJAX URL pattern for accessible projects and cases listing updated

The URL pattern utilizes path() with <uuid:project> to list accessible projects and cases, which is a correct and clear implementation.


48-51: AJAX URL pattern for user permissions updated

The pattern for user permissions now employs path() with <uuid:project>, ensuring consistency and clarity in the URL definitions.


56-59: API URL pattern for cohort list and creation updated

The API URL pattern for cohort listing and creation is updated to use path() with <uuid:project>, adhering to the updated routing conventions.


61-64: API URL pattern for cohort retrieve, update, and destroy updated

Utilizing path() with <uuid:cohort>, the URL pattern correctly handles cohort retrieval, updating, and deletion.


66-69: API URL pattern for cohort case creation updated

The creation of cohort cases now correctly uses path() with <uuid:project>, maintaining consistency across API endpoints.


71-74: API URL pattern for cohort case listing updated

The listing URL pattern for cohort cases is appropriately updated to use path() with <uuid:cohort>.


76-79: API URL pattern for cohort case deletion updated

The deletion pattern now uses path() with <uuid:cohortcase>, correctly reflecting the intended functionality.


81-84: API URL pattern for accessible projects and cases listing updated

The URL pattern for listing accessible projects and cases uses path() with <uuid:project>, ensuring clarity and consistency.

backend/variants/models/maintenance.py (3)

117-118: Combine nested with statements

As mentioned in the previous review, you can combine the nested with statements on lines 117-118 into a single line to enhance readability.

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Combine nested with statements

As mentioned in the previous review, combining the nested with statements on lines 186-187 into a single line can improve code readability.

🧰 Tools
🪛 Ruff

186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


137-180: Verify the correctness of the SQL query logic

The SQL query in SQL_INNER is complex and critical for data aggregation. It's important to ensure that cases marked with exclude_from_inhouse_db are correctly excluded from the variants_smallvariantsummary materialized view.

Run the following script to verify that excluded cases are not included in the summary:

Replace your_database_name with the actual name of your database. The script first retrieves the IDs of cases that should be excluded and then checks if any of those IDs are present in the variants_smallvariant table used to create the materialized view.

backend/variants/urls/presets.py (29)

3-3: Updated import statement to use path function

Good job replacing the deprecated url function with path by importing it from django.urls. This is in line with Django's updated URL routing practices.


12-13: Migrated URL pattern to path() with uuid converter

The URL pattern for FrequencyPresetsListCreateAjaxView has been correctly updated to use path() with the <uuid:presetset> converter. This modernizes the URL configuration and aligns with Django's recommended practices.


17-18: Updated URL pattern with uuid converter is appropriate

The migration to path() for FrequencyPresetsRetrieveUpdateDestroyAjaxView using <uuid:frequencypresets> is correctly implemented.


27-28: Updated URL pattern with uuid converter is appropriate

The path for FrequencyPresetsCloneOtherAjaxView using <uuid:frequencypresets> is correctly updated.


33-34: Migrated URL pattern to path() with uuid converter

The URL pattern for FlagsEtcPresetsListCreateAjaxView has been appropriately updated to use <uuid:presetset>.


39-39: Updated URL pattern with uuid converter is appropriate

The path for FlagsEtcPresetsRetrieveUpdateDestroyAjaxView using <uuid:flagsetcpresets> is correctly implemented.


44-44: Potential issue: slug converter allows digits in name parameter

This issue is similar to the one noted for FrequencyPresets. The use of <slug:name> may unintentionally accept digits in the name parameter.


49-49: Updated URL pattern with uuid converter is appropriate

The path for FlagsEtcPresetsCloneOtherAjaxView using <uuid:flagsetcpresets> is correctly updated.


54-55: Migrated URL pattern to path() with uuid converter

The URL pattern for ImpactPresetsListCreateAjaxView is correctly updated with <uuid:presetset>.


60-60: Updated URL pattern with uuid converter is appropriate

The path for ImpactPresetsRetrieveUpdateDestroyAjaxView using <uuid:impactpresets> is appropriately updated.


65-65: Potential issue: slug converter allows digits in name parameter

This is the same issue as previously mentioned regarding the slug converter accepting digits.


70-70: Updated URL pattern with uuid converter is appropriate

The path for ImpactPresetsCloneOtherAjaxView using <uuid:impactpresets> is correctly implemented.


75-76: Migrated URL pattern to path() with uuid converter

The URL pattern for QualityPresetsListCreateAjaxView using <uuid:presetset> is correctly updated.


81-81: Updated URL pattern with uuid converter is appropriate

The path for QualityPresetsRetrieveUpdateDestroyAjaxView using <uuid:qualitypresets> is appropriately updated.


86-86: Potential issue: slug converter allows digits in name parameter

This issue mirrors the previous concerns about the slug converter allowing digits.


91-91: Updated URL pattern with uuid converter is appropriate

The path for QualityPresetsCloneOtherAjaxView using <uuid:qualitypresets> is correctly updated.


96-97: Migrated URL pattern to path() with uuid converter

The URL pattern for ChromosomePresetsListCreateAjaxView using <uuid:presetset> is correctly updated.


102-102: Updated URL pattern with uuid converter is appropriate

The path for ChromosomePresetsRetrieveUpdateDestroyAjaxView using <uuid:chromosomepresets> is appropriately updated.


107-107: Potential issue: slug converter allows digits in name parameter

As previously noted, consider whether digits should be allowed in name and adjust accordingly.


112-112: Updated URL pattern with uuid converter is appropriate

The path for ChromosomePresetsCloneOtherAjaxView using <uuid:chromosomepresets> is correctly implemented.


119-120: Migrated URL pattern to path() with uuid converter

The URL pattern for QuickPresetsListCreateAjaxView using <uuid:presetset> is correctly updated.


125-125: Updated URL pattern with uuid converter is appropriate

The path for QuickPresetsRetrieveUpdateDestroyAjaxView using <uuid:quickpresets> is appropriately updated.


130-130: Updated URL pattern with uuid converter is appropriate

The path for QuickPresetsCloneOtherAjaxView using <uuid:quickpresets> is correctly implemented.


137-138: Migrated URL pattern to path() without parameters

The URL pattern for PresetSetListAllAjaxView has been updated appropriately.


143-143: Migrated URL pattern to path() with uuid converter

The URL pattern for PresetSetListCreateAjaxView using <uuid:project> is correctly updated.


148-148: Updated URL pattern with uuid converter is appropriate

The path for PresetSetRetrieveUpdateDestroyAjaxView using <uuid:presetset> is correctly implemented.


153-153: Migrated URL pattern to path() without parameters

The URL pattern for PresetSetCloneFactoryPresetsAjaxView has been updated appropriately.


158-158: Updated URL pattern with uuid converter is appropriate

The path for PresetSetCloneOtherAjaxView using <uuid:presetset> is correctly implemented.


163-163: Migrated URL pattern to path() with uuid converter

The URL pattern for ProjectDefaultPresetSetRetrieveAjaxView using <uuid:project> is appropriately updated.

backend/variants/urls/__init__.py (7)

1-1: Import 'path' from 'django.urls'

The import of path is necessary due to the transition from url() to path() in the URL configurations.


12-16: Refactored UI URL patterns using 'path()' with UUID converters

All UI URL patterns have been appropriately refactored from the deprecated url() function with regex patterns to the path() function utilizing <uuid:...> converters. This enhances readability and leverages Django's built-in path converters for parameter validation.

Also applies to: 18-22, 24-28, 30-34, 36-40, 41-45, 46-50, 52-56, 57-61, 62-66, 68-72, 73-77, 79-83, 84-88, 90-94, 95-99, 101-105, 107-111, 112-116, 118-122, 123-127


130-130: Simplified 'new-features' URL pattern

The new-features URL pattern has been updated to use path() without parameters, simplifying the route definition.


132-136: Updated maintenance job URL patterns

The site-wide maintenance job URL patterns have been correctly updated to use path() with <uuid:job> parameters, ensuring consistency and clarity across the URL configurations.

Also applies to: 137-141, 142-146, 147-151


156-160: Refactored AJAX URL patterns to use 'path()'

All AJAX URL patterns have been refactored to use the path() function with appropriate converters. This modernizes the URL configurations and improves code maintainability.

Also applies to: 161-165, 166-170, 171-175, 176-180, 181-185, 186-190, 191-195, 196-200, 201-205, 206-210, 211-215, 216-220, 221-225, 226-230, 231-235, 236-240, 241-245, 246-250, 251-255, 256-260, 261-265, 266-270, 271-275, 276-280, 281-285, 286-290, 291-295


299-303: API URL patterns updated with 'path()' and appropriate converters

The API URL patterns have been successfully updated from url() with regex patterns to path() using <uuid:...> and <str:...> converters. This ensures proper parameter parsing and aligns with Django's recommended practices.

Also applies to: 304-308, 309-313, 314-318, 319-323, 324-328, 329-333, 334-338, 339-343, 344-348, 349-353, 354-358, 359-363, 364-368, 369-373, 374-378, 379-383, 384-388, 389-393, 394-398, 399-403, 404-408, 409-413, 414-418, 419-423, 424-428, 429-433, 434-438, 439-443, 444-448, 449-453


355-358: No further action required on 'category' parameter validation

The category parameter in the api-category-presets URL pattern remains defined as <str:category>. Previous review comments have addressed potential input validation concerns. Since the past comment is still valid and applicable, no additional comments are necessary here.

});
</script>
{% endblock javascript %}
{% extends 'projectroles/login.html' %}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

The 'projectroles/login.html' template does not exist

The change to extend 'projectroles/login.html' fails because the template was not found in the repository. Please ensure that 'projectroles/login.html' exists or adjust the template extension accordingly.

🔗 Analysis chain

LGTM! Verify 'projectroles/login.html' exists

The change to extend 'projectroles/login.html' aligns with the PR objective of upgrading to sodar core v1. This simplifies login functionality and promotes consistency across the application.

Please run the following script to verify the existence of 'projectroles/login.html':

Additionally, please review if any custom login functionality from the previous implementation needs to be preserved or migrated to the new template.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of 'projectroles/login.html'

# Test: Check if 'projectroles/login.html' exists
if fd --type f --hidden --no-ignore "login.html" | grep -q "projectroles/login.html"; then
    echo "The 'projectroles/login.html' template exists."
else
    echo "Warning: The 'projectroles/login.html' template was not found."
fi

Length of output: 220

Comment on lines +40 to +44
"ajax/query-case/category-presets/<str:category>/",
view=views.SvCategoryPresetsApiView.as_view(),
name="ajax-category-presets",
),
url(
regex=r"^ajax/query-case/inheritance-presets/(?P<case>[0-9a-f-]+)/?$",
path(
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Ensure the category parameter constraints are preserved.

In the original url() pattern, the regex (?P<category>[a-zA-Z0-9\._-]+) restricts the category parameter to alphanumeric characters, periods, underscores, and hyphens. By changing to:

path(
    "ajax/query-case/category-presets/<str:category>/",
    view=views.SvCategoryPresetsApiView.as_view(),
    name="ajax-category-presets",
),

the <str:category> path converter accepts any non-empty string excluding slashes. This may introduce unexpected characters in category. To retain the original constraints, consider one of the following options:

  1. Use re_path() with the original regex:

    re_path(
        r"ajax/query-case/category-presets/(?P<category>[a-zA-Z0-9\._-]+)/",
        view=views.SvCategoryPresetsApiView.as_view(),
        name="ajax-category-presets",
    ),
  2. Create a custom path converter:

    Define a custom converter that enforces the required character set, then register and use it in your URL pattern.

Comment on lines +133 to 139
re_path(
r"^worker/(?P<url>.*)$",
HttpProxy.as_view(
base_url=f"{settings.WORKER_REST_BASE_URL}/public/svs/",
ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
),
),
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify re_path() pattern by removing redundant anchors.

In re_path(), the pattern is implicitly anchored at the start and end of the string, so the ^ and $ are unnecessary. You can simplify the pattern as follows:

-re_path(
-    r"^worker/(?P<url>.*)$",
+re_path(
+    r"worker/(?P<url>.*)",
    HttpProxy.as_view(
        base_url=f"{settings.WORKER_REST_BASE_URL}/public/svs/",
        ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
    ),
),

This improves readability without affecting functionality.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
re_path(
r"^worker/(?P<url>.*)$",
HttpProxy.as_view(
base_url=f"{settings.WORKER_REST_BASE_URL}/public/svs/",
ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
),
),
re_path(
r"worker/(?P<url>.*)",
HttpProxy.as_view(
base_url=f"{settings.WORKER_REST_BASE_URL}/public/svs/",
ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
),
),

Comment on lines +122 to +129
SQL_OUTER = r"""
DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;

CREATE MATERIALIZED VIEW variants_smallvariantsummary
AS
%s
WITH NO DATA;

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using parameterized queries for SQL execution

While SQL_OUTER and SQL_INNER are defined within the code, using string formatting for SQL commands can be risky if any part of the query comes from external inputs. To adhere to best practices and future-proof the code against potential SQL injection vulnerabilities, consider using parameterized queries or the execute method's ability to accept parameters.

url(
regex=r"^ajax/frequencypresets/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/?$",
path(
"ajax/frequencypresets/clone-factory-presets/<slug:name>/",
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Potential issue: slug converter allows digits in name parameter

The original URL pattern for name likely only allowed letters and underscores/hyphens ([a-zA-Z_-]+). The use of <slug:name> in the path() function allows digits ([a-zA-Z0-9_-]+), potentially broadening the accepted name values unintentionally.

To maintain the original behavior and exclude digits, consider one of the following options:

  1. Define a custom path converter that excludes digits:

    from django.urls import register_converter
    
    class NoDigitSlugConverter:
        regex = '[a-zA-Z_-]+'
    
        def to_python(self, value):
            return value
    
        def to_url(self, value):
            return value
    
    register_converter(NoDigitSlugConverter, 'nodigitslug')

    Update the URL pattern:

    - "ajax/frequencypresets/clone-factory-presets/<slug:name>/",
    + "ajax/frequencypresets/clone-factory-presets/<nodigitslug:name>/",
  2. Use re_path() with a regex to match the original pattern:

    from django.urls import re_path
    
    re_path(
        r"ajax/frequencypresets/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/",
        view=views_ajax.FrequencyPresetsCloneFactoryPresetsAjaxView.as_view(),
        name="ajax-frequencypresets-clonefactorypresets",
    ),

Comment on lines +869 to +888
if ENABLE_OIDC:
AUTHENTICATION_BACKENDS = tuple(
itertools.chain(
("social_core.backends.open_id_connect.OpenIdConnectAuth",),
AUTHENTICATION_BACKENDS,
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor 'AUTHENTICATION_BACKENDS' assignments to prevent overwriting

When both ENABLE_OIDC and ENABLE_LDAP are set to True, each conditional block reassigns AUTHENTICATION_BACKENDS, which could result in only one of the authentication methods being active.

To ensure all authentication backends are included, consider initializing AUTHENTICATION_BACKENDS as a list and appending new backends within each conditional block.

Apply this refactor:

  1. Initialize AUTHENTICATION_BACKENDS as a list if not already a list.

  2. Append new backends within the conditional blocks.

Here's how you can modify the code:

# Initially define AUTHENTICATION_BACKENDS as a list
 AUTHENTICATION_BACKENDS = [
     "rules.permissions.ObjectPermissionBackend",
     "django.contrib.auth.backends.ModelBackend",
     "django_su.backends.SuBackend",
 ]

# In OIDC configuration
if ENABLE_OIDC:
-    AUTHENTICATION_BACKENDS = tuple(
-        itertools.chain(
-            ("social_core.backends.open_id_connect.OpenIdConnectAuth",),
-            AUTHENTICATION_BACKENDS,
-        )
-    )
+    AUTHENTICATION_BACKENDS.insert(0, "social_core.backends.open_id_connect.OpenIdConnectAuth")

# In LDAP configuration
if ENABLE_LDAP:
-    AUTHENTICATION_BACKENDS = tuple(
-        itertools.chain(("projectroles.auth_backends.PrimaryLDAPBackend",), AUTHENTICATION_BACKENDS)
-    )
+    AUTHENTICATION_BACKENDS.insert(0, "projectroles.auth_backends.PrimaryLDAPBackend")

This approach ensures that all authentication backends are included without overwriting previous assignments, and the order of backends can be controlled by inserting at the beginning or appending at the end.

Committable suggestion was skipped due to low confidence.

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch from 7c02f35 to 1268b16 Compare October 10, 2024 08:24
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

🧹 Outside diff range and nitpick comments (35)
backend/variants/models/maintenance.py (1)

137-180: Well-structured complex SQL query with minor optimization potential

The SQL_INNER query is well-designed and uses several good practices:

  1. Utilizes a CTE for excluded_case_ids, improving readability.
  2. Correctly aggregates data and groups results.
  3. Uses row_number() to generate unique id values.
  4. Properly joins tables to exclude cases based on project settings.

Consider a minor optimization: The DISTINCT in the subquery (line 162) might be unnecessary if case_id is already unique for each combination of variant attributes. If that's the case, removing it could slightly improve performance:

 FROM (
-    SELECT DISTINCT
+    SELECT
         variants.release,
         variants.chromosome,
         variants.start,
         variants."end",
         variants.bin,
         variants.reference,
         variants.alternative,
         variants.num_hom_ref,
         variants.num_het,
         variants.num_hom_alt,
         variants.num_hemi_ref,
         variants.num_hemi_alt,
         variants.case_id
     FROM variants_smallvariant AS variants
     WHERE NOT EXISTS (SELECT 1 from excluded_case_ids AS e WHERE e.case_id = variants.case_id)
 ) AS variants_per_case

This change would only be appropriate if you're certain that case_id is unique for each variant combination. If you're unsure, it's safer to keep the DISTINCT clause.

backend/varfish/users/management/commands/initdev.py (2)

Line range hint 118-157: LGTM: Comprehensive handling of initialization scenarios

The _handle method has been successfully updated to accommodate the new data_create option, allowing for flexible initialization scenarios. The implementation correctly creates either an import job or a case based on the provided option.

Suggestion for improvement:
Consider adding a brief comment explaining the purpose of the job_pk variable at the beginning of the method, as it's not immediately clear why it's initialized as None.

Example:

# Initialize job_pk to None; it will be set if an import job is created
job_pk: Optional[int] = None

This minor addition would enhance code readability.


285-285: LGTM: Improved naming consistency

The renaming of app_name to plugin_name in the app_settings.set() call improves clarity and consistency in the codebase.

Suggestion for improvement:
For complete consistency, consider updating the comment above this section to reflect the new terminology. For example:

# Ensure the settings are configured as needed for the plugin.

This minor update would align the comment with the new naming convention.

backend/variants/tests/test_views_ajax_presets.py (9)

122-129: LGTM! Consider adding more assertions.

The removal of mocking in favor of directly testing the view's behavior is a good change. It makes the test more robust and less prone to breaking due to implementation changes.

Consider adding more assertions to verify other aspects of the response, such as the status code and the structure of the returned data. For example:

self.assertEqual(response.status_code, 201)
self.assertIn('label', response.json())
self.assertEqual(response.json()['label'], 'my label')

146-153: LGTM! Consider adding more assertions.

The removal of mocking in favor of directly testing the view's behavior is consistent with the previous changes and improves the test's robustness.

Consider adding more assertions to verify other aspects of the response, such as the status code and the structure of the returned data. For example:

self.assertEqual(response.status_code, 201)
self.assertIn('label', response.json())
self.assertEqual(response.json()['label'], 'my label')
self.assertIn('frequencypresets', response.json())
self.assertEqual(response.json()['frequencypresets'], str(self.frequencypresets.sodar_uuid))

244-251: LGTM! Consider adding more assertions.

The removal of mocking in favor of directly testing the view's behavior is consistent with the previous changes and improves the test's robustness.

Consider adding more assertions to verify other aspects of the response, such as the status code and the structure of the returned data. For example:

self.assertEqual(response.status_code, 201)
self.assertIn('label', response.json())
self.assertEqual(response.json()['label'], 'my label')
self.assertIn('name', response.json())
self.assertEqual(response.json()['name'], 'the-name')

268-275: LGTM! Consider adding more assertions.

The removal of mocking in favor of directly testing the view's behavior is consistent with the previous changes and improves the test's robustness.

Consider adding more assertions to verify other aspects of the response, such as the status code and the structure of the returned data. For example:

self.assertEqual(response.status_code, 201)
self.assertIn('label', response.json())
self.assertEqual(response.json()['label'], 'my label')
self.assertIn('impactpresets', response.json())
self.assertEqual(response.json()['impactpresets'], str(self.impactpresets.sodar_uuid))

366-373: LGTM! Consider adding more assertions.

The removal of mocking in favor of directly testing the view's behavior is consistent with the previous changes and improves the test's robustness.

Consider adding more assertions to verify other aspects of the response, such as the status code and the structure of the returned data. For example:

self.assertEqual(response.status_code, 201)
self.assertIn('label', response.json())
self.assertEqual(response.json()['label'], 'my label')
self.assertIn('name', response.json())
self.assertEqual(response.json()['name'], 'the-name')

390-397: LGTM! Consider adding more assertions.

The removal of mocking in favor of directly testing the view's behavior is consistent with the previous changes and improves the test's robustness.

Consider adding more assertions to verify other aspects of the response, such as the status code and the structure of the returned data. For example:

self.assertEqual(response.status_code, 201)
self.assertIn('label', response.json())
self.assertEqual(response.json()['label'], 'my label')
self.assertIn('qualitypresets', response.json())
self.assertEqual(response.json()['qualitypresets'], str(self.qualitypresets.sodar_uuid))

732-739: LGTM! Consider adding more assertions.

The removal of mocking in favor of directly testing the view's behavior is consistent with the previous changes and improves the test's robustness.

Consider adding more assertions to verify other aspects of the response, such as the status code and the structure of the returned data. For example:

self.assertEqual(response.status_code, 201)
self.assertIn('label', response.json())
self.assertEqual(response.json()['label'], 'my label')
self.assertIn('quickpresets', response.json())
self.assertEqual(response.json()['quickpresets'], str(self.quickpresets.sodar_uuid))

Line range hint 842-872: LGTM! Consider adding more assertions and error handling tests.

The removal of mocking in favor of directly testing the view's behavior is consistent with the previous changes and improves the tests' robustness. This applies to both TestPresetSetCloneFactoryPresetsAjaxView and TestPresetSetCloneOtherAjaxView classes.

Consider adding more assertions to verify other aspects of the response, such as the status code and the structure of the returned data. For example:

self.assertEqual(response.status_code, 201)
self.assertIn('label', response.json())
self.assertEqual(response.json()['label'], 'my label')

Additionally, consider adding tests for error handling scenarios, such as:

  1. Attempting to clone with invalid data
  2. Attempting to clone a non-existent preset set
  3. Attempting to clone without proper permissions

These tests will ensure that the views handle edge cases and error conditions correctly.


Line range hint 1-872: Overall LGTM! Consider implementing suggested improvements.

The changes made to this test file are consistent and improve the robustness of the tests. The removal of mocking in favor of directly testing view behavior is a positive change that will make the tests less brittle and more representative of actual system behavior.

To further improve the test suite:

  1. Add more detailed assertions to each test, verifying various aspects of the response data.
  2. Implement error handling tests for each view to ensure proper behavior in edge cases.
  3. Consider adding integration tests that cover the interaction between different preset types and preset sets.

These improvements will enhance the overall quality and coverage of your test suite.

backend/config/settings/base.py (1)

864-893: OIDC configuration added

The OpenID Connect (OIDC) configuration has been successfully added to the settings file. This is a good addition for enhancing authentication options. However, there are a few points to consider:

  1. The SOCIAL_AUTH_OIDC_KEY and SOCIAL_AUTH_OIDC_SECRET are set to "CHANGEME" by default. While this is a common practice for placeholder values, it's crucial to ensure these are replaced with actual values in production.

  2. The SOCIAL_AUTH_OIDC_USERNAME_KEY is set to "username" by default. Depending on your OIDC provider, you might need to adjust this to match the correct claim (e.g., "preferred_username" or "sub").

  3. Consider adding SOCIAL_AUTH_OIDC_SCOPE to specify the desired OIDC scopes.

  4. It might be beneficial to add SOCIAL_AUTH_OIDC_ID_TOKEN_MAX_AGE to set a maximum age for the ID token.

Consider adding the following configurations for enhanced security and flexibility:

SOCIAL_AUTH_OIDC_SCOPE = ['openid', 'profile', 'email']
SOCIAL_AUTH_OIDC_ID_TOKEN_MAX_AGE = 600  # 10 minutes

Also, ensure to replace the placeholder values for SOCIAL_AUTH_OIDC_KEY and SOCIAL_AUTH_OIDC_SECRET with actual values in your production environment.

backend/variants/tests/test_permissions_ajax_presets.py (17)

Line range hint 140-165: LGTM with a minor suggestion: TestFrequencyPresetsCloneFactoryDefaultsView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test_post method are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

Consider parameterizing the factory preset name "dominant_strict" to make the test more flexible and easier to maintain. This could be done by creating a class variable or a constant at the module level.


Line range hint 195-240: LGTM with a suggestion: TestImpactPresetsListCreateAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_list and test_create) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

Consider creating a base test class for common preset test functionality, as there are similarities between this class and TestFrequencyPresetsListCreateAjaxView. This could reduce code duplication and make maintenance easier.


Line range hint 242-316: LGTM with a suggestion: TestImpactPresetsRetrieveUpdateDestroyAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_retrieve, test_update, and test_destroy) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

As mentioned earlier, consider creating a base test class for common preset test functionality. This class shares many similarities with TestFrequencyPresetsRetrieveUpdateDestroyAjaxView, and a base class could significantly reduce code duplication across all preset types.


Line range hint 318-343: LGTM with suggestions: TestImpactPresetsCloneFactoryDefaultsView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test_post method are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

  1. Consider creating a base test class for clone factory defaults functionality, as this class is very similar to TestFrequencyPresetsCloneFactoryDefaultsView.
  2. Parameterize the factory preset name "null_variant" to make the test more flexible and consistent with other similar tests.

Line range hint 345-371: LGTM with a suggestion: TestImpactPresetsCloneOtherView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method properly initializes the required test data, and the test_post method covers all necessary permission checks for different user types. The URL construction and assertions are accurate.

Consider creating a base test class for clone other functionality, as this class is very similar to TestFrequencyPresetsCloneOtherView. This would reduce code duplication and improve maintainability across different preset types.


Line range hint 373-418: LGTM with a suggestion: TestQualityPresetsListCreateAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_list and test_create) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

As suggested earlier, consider creating a base test class for common preset test functionality. This class shares many similarities with TestFrequencyPresetsListCreateAjaxView and TestImpactPresetsListCreateAjaxView. A base class could significantly reduce code duplication across all preset types and improve maintainability.


Line range hint 420-494: LGTM with a suggestion: TestQualityPresetsRetrieveUpdateDestroyAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_retrieve, test_update, and test_destroy) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

As suggested earlier, consider creating a base test class for common preset test functionality. This class shares many similarities with TestFrequencyPresetsRetrieveUpdateDestroyAjaxView and TestImpactPresetsRetrieveUpdateDestroyAjaxView. A base class could significantly reduce code duplication across all preset types, improve maintainability, and ensure consistency in testing across different preset types.


Line range hint 496-519: LGTM with suggestions: TestQualityPresetsCloneFactoryDefaultsView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test_post method are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

  1. Consider creating a base test class for clone factory defaults functionality, as this class is very similar to TestFrequencyPresetsCloneFactoryDefaultsView and TestImpactPresetsCloneFactoryDefaultsView.
  2. Parameterize the factory preset name "strict" to make the test more flexible and consistent with other similar tests.
  3. Implement a shared mechanism for managing different preset names across various preset types to ensure consistency and ease of maintenance.

Line range hint 521-547: LGTM with a suggestion: TestQualityPresetsCloneOtherView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method properly initializes the required test data, and the test_post method covers all necessary permission checks for different user types. The URL construction and assertions are accurate.

Consider creating a base test class for clone other functionality, as this class is very similar to TestFrequencyPresetsCloneOtherView and TestImpactPresetsCloneOtherView. This would reduce code duplication, improve maintainability, and ensure consistency in testing across different preset types.


Line range hint 549-594: LGTM with a suggestion: TestChromosomePresetsListCreateAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_list and test_create) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

As suggested earlier for similar classes, consider creating a base test class for common preset test functionality. This class shares many similarities with other *PresetsListCreateAjaxView classes. A base class could significantly reduce code duplication across all preset types, improve maintainability, and ensure consistency in testing.


Line range hint 596-670: LGTM with a suggestion: TestChromosomePresetsRetrieveUpdateDestroyAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_retrieve, test_update, and test_destroy) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

As suggested earlier for similar classes, consider creating a base test class for common preset test functionality. This class shares many similarities with other *PresetsRetrieveUpdateDestroyAjaxView classes. A base class could significantly reduce code duplication across all preset types, improve maintainability, and ensure consistency in testing for retrieve, update, and destroy operations.


Line range hint 672-697: LGTM with suggestions: TestChromosomePresetsCloneFactoryDefaultsView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test_post method are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

  1. Consider creating a base test class for clone factory defaults functionality, as this class is very similar to other *PresetsCloneFactoryDefaultsView classes.
  2. Parameterize the factory preset name "whole_genome" to make the test more flexible and consistent with other similar tests.
  3. Implement a shared mechanism for managing different preset names across various preset types to ensure consistency and ease of maintenance.

Line range hint 699-725: LGTM with a suggestion: TestChromosomePresetsCloneOtherView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method properly initializes the required test data, and the test_post method covers all necessary permission checks for different user types. The URL construction and assertions are accurate.

Consider creating a base test class for clone other functionality, as this class is very similar to other *PresetsCloneOtherView classes. This would reduce code duplication, improve maintainability, and ensure consistency in testing across different preset types.


Line range hint 727-772: LGTM with a suggestion: TestFlagsEtcPresetsListCreateAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_list and test_create) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

As suggested earlier for similar classes, consider creating a base test class for common preset test functionality. This class shares many similarities with other *PresetsListCreateAjaxView classes. A base class could significantly reduce code duplication across all preset types, improve maintainability, and ensure consistency in testing for list and create operations.


Line range hint 774-848: LGTM with a suggestion: TestFlagsEtcPresetsRetrieveUpdateDestroyAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_retrieve, test_update, and test_destroy) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

As suggested earlier for similar classes, consider creating a base test class for common preset test functionality. This class shares many similarities with other *PresetsRetrieveUpdateDestroyAjaxView classes. A base class could significantly reduce code duplication across all preset types, improve maintainability, and ensure consistency in testing for retrieve, update, and destroy operations.


Line range hint 850-875: LGTM with suggestions: TestFlagsEtcPresetsCloneFactoryDefaultsView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test_post method are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.

  1. Consider creating a base test class for clone factory defaults functionality, as this class is very similar to other *PresetsCloneFactoryDefaultsView classes.
  2. Parameterize the factory preset name "defaults" to make the test more flexible and consistent with other similar tests.
  3. Implement a shared mechanism for managing different preset names across various preset types to ensure consistency and ease of maintenance.

Line range hint 877-903: LGTM with a suggestion: TestFlagsEtcPresetsCloneOtherView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method properly initializes the required test data, and the test_post method covers all necessary permission checks for different user types. The URL construction and assertions are accurate.

Consider creating a base test class for clone other functionality, as this class is very similar to other *PresetsCloneOtherView classes. This would reduce code duplication, improve maintainability, and ensure consistency in testing across different preset types.

backend/cases_import/models/executors.py (1)

Line range hint 1037-1060: Consider enhancing error handling and logging

While the current implementation has improved error handling and logging, consider the following enhancements:

  1. Add more specific error handling for each major operation in the _run_create_or_update method. This could help in identifying and diagnosing issues more precisely.

  2. Implement more detailed logging throughout the _run_create_or_update method to track the progress of each step (e.g., file creation, QC import, variant import). This would provide better visibility into the import process and aid in troubleshooting.

Example:

def _run_create_or_update(self):
    try:
        # ... existing code ...
        
        self.caseimportbackgroundjob.add_log_entry("Starting external file creation")
        self._create_external_files(case, family)
        
        self.caseimportbackgroundjob.add_log_entry("Starting QC file import")
        self._run_qc_file_import(case)
        
        # ... continue for each major step ...
        
    except Exception as e:
        self.caseimportbackgroundjob.add_log_entry(f"Error during case import: {str(e)}", LOG_LEVEL_ERROR)
        raise

This approach would provide more granular error handling and logging, improving the overall robustness and observability of the import process.

backend/seqvars/tests/test_permissions_api.py (4)

Line range hint 62-204: Consider improving code organization and reusability

The TestQueryPresetsSetViewSet class is well-structured and covers all necessary CRUD operations with proper permission checks. However, there are opportunities to enhance code organization and reduce repetition:

  1. Consider extracting common user groups (e.g., good_users, bad_users_401, bad_users_403) into class-level attributes or helper methods to reduce redundancy across test methods.

  2. The URL construction and cleanup logic is repeated in each test method. Consider creating helper methods to generate URLs and handle cleanup tasks.

  3. The data preparation for create and patch operations could be moved to setup methods or helper functions to improve readability and maintainability.

Here's an example of how you could refactor the class to improve organization:

class TestQueryPresetsSetViewSet(ProjectAPIPermissionTestBase):
    def setUp(self):
        super().setUp()
        self.querypresetsset = SeqvarsQueryPresetsSetFactory(project=self.project)
        self.good_users = [
            self.superuser,
            self.user_owner,
            self.user_delegate,
            self.user_contributor,
        ]
        self.bad_users_401 = [self.anonymous]
        self.bad_users_403 = [self.user_no_roles, self.user_guest, self.user_finder_cat]

    def get_list_url(self):
        return reverse(
            "seqvars:api-querypresetsset-list",
            kwargs={"project": self.project.sodar_uuid},
        )

    def get_detail_url(self):
        return reverse(
            "seqvars:api-querypresetsset-detail",
            kwargs={
                "project": self.project.sodar_uuid,
                "querypresetsset": self.querypresetsset.sodar_uuid,
            },
        )

    def cleanup(self):
        for obj in SeqvarsQueryPresetsSet.objects.exclude(sodar_uuid=self.querypresetsset.sodar_uuid):
            obj.delete()

    # ... rest of the methods using the helper methods and attributes

This refactoring would make the code more DRY and easier to maintain.


Line range hint 205-355: Consider creating a base test class for common CRUD operations

The TestQueryPresetsVersionSetViewSet class, along with other similar test classes in this file, follows a repetitive pattern for testing CRUD operations. To improve code maintainability and reduce duplication, consider creating a base test class that implements the common CRUD test methods.

Here's an example of how you could implement a base test class:

class BaseCRUDTestCase(ProjectAPIPermissionTestBase):
    factory_class = None
    viewset_name = None
    
    def setUp(self):
        super().setUp()
        self.obj = self.factory_class(project=self.project)
        self.good_users = [
            self.superuser,
            self.user_owner,
            self.user_delegate,
            self.user_contributor,
        ]
        self.bad_users_401 = [self.anonymous]
        self.bad_users_403 = [self.user_no_roles, self.user_guest, self.user_finder_cat]

    def get_list_url(self):
        return reverse(f"seqvars:api-{self.viewset_name}-list", kwargs={"project": self.project.sodar_uuid})

    def get_detail_url(self):
        return reverse(
            f"seqvars:api-{self.viewset_name}-detail",
            kwargs={
                "project": self.project.sodar_uuid,
                self.viewset_name: self.obj.sodar_uuid,
            },
        )

    def test_list(self):
        url = self.get_list_url()
        self.assert_response(url, self.good_users, 200, method="GET")
        self.assert_response(url, self.bad_users_401, 401, method="GET")
        self.assert_response(url, self.bad_users_403, 403, method="GET")

    # ... implement other common test methods (create, retrieve, patch, delete)

class TestQueryPresetsVersionSetViewSet(BaseCRUDTestCase):
    factory_class = SeqvarsQueryPresetsSetVersionFactory
    viewset_name = "querypresetssetversion"

    # ... implement only unique test methods or override if necessary

This approach would significantly reduce code duplication across your test classes and make it easier to maintain and extend your test suite. Each specific test class would inherit from BaseCRUDTestCase and only need to implement unique test cases or override methods if necessary.


Line range hint 356-2346: Refactor the entire test suite for better maintainability

The test classes in this file (TestQueryPresetsFrequencyViewSet, TestQueryPresetsQualityViewSet, etc.) all follow a similar pattern for testing CRUD operations on different models related to sequence variant queries. While the implementation is correct and thorough, the repetitive nature of these classes suggests several opportunities for improvement:

  1. Create a base test class: As suggested earlier, implement a base test class that encapsulates common CRUD test methods. This will significantly reduce code duplication across all test classes.

  2. Use parameterized tests: For tests that differ only in the data they use (e.g., different user roles), consider using parameterized tests to reduce repetition within each test class.

  3. Implement helper methods or fixtures: Create helper methods or pytest fixtures for common setup tasks, such as creating test objects or generating URLs.

  4. Group related test classes: Consider grouping related test classes into separate files or using nested classes to improve organization.

Here's an example of how you could refactor the entire test suite:

import pytest
from django.urls import reverse

class BaseCRUDTestCase(ProjectAPIPermissionTestBase):
    model_class = None
    factory_class = None
    viewset_name = None
    
    @pytest.fixture(autouse=True)
    def setup_test_data(self):
        self.obj = self.factory_class(project=self.project)
        self.good_users = [
            self.superuser,
            self.user_owner,
            self.user_delegate,
            self.user_contributor,
        ]
        self.bad_users_401 = [self.anonymous]
        self.bad_users_403 = [self.user_no_roles, self.user_guest, self.user_finder_cat]

    def get_list_url(self):
        return reverse(f"seqvars:api-{self.viewset_name}-list", kwargs={"project": self.project.sodar_uuid})

    def get_detail_url(self):
        return reverse(
            f"seqvars:api-{self.viewset_name}-detail",
            kwargs={
                "project": self.project.sodar_uuid,
                self.viewset_name: self.obj.sodar_uuid,
            },
        )

    @pytest.mark.parametrize("user_group,expected_status", [
        ("good_users", 200),
        ("bad_users_401", 401),
        ("bad_users_403", 403),
    ])
    def test_list(self, user_group, expected_status):
        url = self.get_list_url()
        users = getattr(self, user_group)
        self.assert_response(url, users, expected_status, method="GET")

    # ... implement other common test methods (create, retrieve, patch, delete)

class TestQueryPresetsSetViewSet(BaseCRUDTestCase):
    model_class = SeqvarsQueryPresetsSet
    factory_class = SeqvarsQueryPresetsSetFactory
    viewset_name = "querypresetsset"

    # ... implement only unique test methods or override if necessary

# ... other test classes following the same pattern

This refactoring would:

  • Reduce code duplication
  • Improve maintainability
  • Make it easier to add new test cases or modify existing ones
  • Provide a consistent structure across all test classes

Consider applying this refactoring approach to all test classes in this file to significantly improve the overall quality and maintainability of your test suite.


Line range hint 1-2346: Overall assessment and recommendations for improvement

The test_permissions_api.py file provides a comprehensive set of tests for API permissions related to sequence variants. The tests cover all necessary CRUD operations and user roles, ensuring robust permission checks. However, the current implementation has several areas for improvement:

  1. Code duplication: There's significant repetition across test classes, which can make maintenance and updates challenging.

  2. Lack of abstraction: Common patterns are repeated rather than abstracted into reusable components.

  3. Test organization: The file is quite long and could benefit from better organization.

To address these issues and improve the overall quality of the test suite, consider the following recommendations:

  1. Implement a base test class for common CRUD operations to reduce code duplication.
  2. Use parameterized tests for scenarios that differ only in input data or expected outcomes.
  3. Create helper methods or fixtures for common setup tasks and URL generation.
  4. Consider splitting the test suite into multiple files, grouping related test classes together.
  5. Implement a more DRY (Don't Repeat Yourself) approach by extracting common user groups, URL patterns, and cleanup logic into reusable components.

These changes would significantly improve the maintainability, readability, and extensibility of your test suite, making it easier to add new tests or modify existing ones as your API evolves.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7c02f35 and 1268b16.

⛔ Files ignored due to path filters (1)
  • backend/Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (79)
  • .github/workflows/main.yml (4 hunks)
  • backend/Makefile (1 hunks)
  • backend/Pipfile (4 hunks)
  • backend/beaconsite/tests/test_permissions.py (3 hunks)
  • backend/beaconsite/tests/test_permissions_ajax.py (2 hunks)
  • backend/beaconsite/tests/test_permissions_api.py (3 hunks)
  • backend/beaconsite/tests/test_views_ajax.py (1 hunks)
  • backend/beaconsite/urls.py (1 hunks)
  • backend/cases/tests/test_permissions.py (1 hunks)
  • backend/cases/tests/test_permissions_ajax.py (12 hunks)
  • backend/cases/tests/test_permissions_api.py (11 hunks)
  • backend/cases/tests/test_views.py (1 hunks)
  • backend/cases/tests/test_views_ajax.py (12 hunks)
  • backend/cases/urls.py (1 hunks)
  • backend/cases_analysis/tests/test_permissions_api.py (2 hunks)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_import/tests/test_permissions_api.py (1 hunks)
  • backend/cases_qc/tests/test_permissions_api.py (2 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/cohorts/migrations/0008_alter_cohort_user.py (1 hunks)
  • backend/cohorts/tests/test_permissions_ajax.py (3 hunks)
  • backend/cohorts/tests/test_permissions_api.py (3 hunks)
  • backend/cohorts/tests/test_views_ui.py (1 hunks)
  • backend/cohorts/urls.py (1 hunks)
  • backend/config/settings/base.py (3 hunks)
  • backend/config/urls.py (5 hunks)
  • backend/ext_gestaltmatcher/migrations/0003_alter_smallvariantquerygestaltmatcherscores_id_and_more.py (1 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/genepanels/tests/test_permissions.py (2 hunks)
  • backend/genepanels/urls.py (1 hunks)
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1 hunks)
  • backend/importer/urls.py (1 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/seqmeta/tests/test_permissions.py (2 hunks)
  • backend/seqmeta/urls.py (2 hunks)
  • backend/seqvars/tests/test_permissions_api.py (17 hunks)
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_presets.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_queries.py (6 hunks)
  • backend/svs/urls.py (2 hunks)
  • backend/varannos/tests/helpers.py (3 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_permissions.py (1 hunks)
  • backend/varannos/tests/test_permissions_api.py (1 hunks)
  • backend/varannos/urls.py (2 hunks)
  • backend/varfish/templates/users/login.html (1 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/varfish/users/urls.py (1 hunks)
  • backend/varfish/vueapp/urls.py (1 hunks)
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/models/maintenance.py (1 hunks)
  • backend/variants/tests/helpers.py (3 hunks)
  • backend/variants/tests/test_file_export.py (2 hunks)
  • backend/variants/tests/test_permissions_ajax.py (6 hunks)
  • backend/variants/tests/test_permissions_ajax_annos.py (1 hunks)
  • backend/variants/tests/test_permissions_ajax_presets.py (29 hunks)
  • backend/variants/tests/test_permissions_api.py (7 hunks)
  • backend/variants/tests/test_ui.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
  • backend/variants/urls/init.py (2 hunks)
  • backend/variants/urls/annos.py (1 hunks)
  • backend/variants/urls/presets.py (2 hunks)
  • frontend/ext/reev-frontend-lib (1 hunks)
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (1 hunks)
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4 hunks)
  • frontend/src/varfish/components/FilterForm/DevPane.vue (2 hunks)
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/EffectPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FlagsPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3 hunks)
  • frontend/src/variants/components/FilterForm/QualityPane.vue (1 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetProperties.vue (1 hunks)
  • utils/docker/Dockerfile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (60)
  • .github/workflows/main.yml
  • backend/Makefile
  • backend/Pipfile
  • backend/beaconsite/tests/test_permissions.py
  • backend/beaconsite/tests/test_permissions_ajax.py
  • backend/beaconsite/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_views_ajax.py
  • backend/beaconsite/urls.py
  • backend/cases/tests/test_permissions.py
  • backend/cases/tests/test_permissions_ajax.py
  • backend/cases/tests/test_views.py
  • backend/cases/tests/test_views_ajax.py
  • backend/cases_analysis/tests/test_permissions_api.py
  • backend/cases_import/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_views_api.py
  • backend/cohorts/migrations/0008_alter_cohort_user.py
  • backend/cohorts/tests/test_permissions_ajax.py
  • backend/cohorts/tests/test_permissions_api.py
  • backend/cohorts/tests/test_views_ui.py
  • backend/ext_gestaltmatcher/migrations/0003_alter_smallvariantquerygestaltmatcherscores_id_and_more.py
  • backend/genepanels/forms.py
  • backend/genepanels/tests/test_models.py
  • backend/genepanels/tests/test_permissions.py
  • backend/genepanels/urls.py
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py
  • backend/seqmeta/tests/test_models.py
  • backend/seqmeta/tests/test_permissions.py
  • backend/seqmeta/urls.py
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py
  • backend/svs/tests/test_permissions_ajax_presets.py
  • backend/svs/tests/test_permissions_ajax_queries.py
  • backend/varannos/tests/helpers.py
  • backend/varannos/tests/test_models.py
  • backend/varannos/tests/test_permissions.py
  • backend/varannos/tests/test_permissions_api.py
  • backend/varfish/templates/users/login.html
  • backend/varfish/users/urls.py
  • backend/varfish/vueapp/urls.py
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py
  • backend/variants/migrations/0110_drop_variant_summary.py
  • backend/variants/migrations/0111_create_variant_summary.py
  • backend/variants/tests/helpers.py
  • backend/variants/tests/test_file_export.py
  • backend/variants/tests/test_permissions_ajax.py
  • backend/variants/tests/test_permissions_ajax_annos.py
  • backend/variants/tests/test_permissions_api.py
  • backend/variants/urls/annos.py
  • frontend/ext/reev-frontend-lib
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue
  • frontend/src/varfish/components/FilterForm/DevPane.vue
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue
  • frontend/src/variants/components/FilterForm/EffectPane.vue
  • frontend/src/variants/components/FilterForm/FlagsPane.vue
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue
  • frontend/src/variants/components/FilterForm/QualityPane.vue
  • frontend/src/variants/components/QueryPresets/SetEditor.vue
  • frontend/src/variants/components/QueryPresets/SetProperties.vue
🧰 Additional context used
🪛 Ruff
backend/variants/models/maintenance.py

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

🔇 Additional comments (58)
backend/varannos/urls.py (7)

7-11: LGTM: Improved URL pattern for VarAnnoSetListView

The change from url() to path() and the use of <uuid:project> instead of a regex pattern is a good improvement. It enhances readability and ensures type safety for the project parameter.


12-16: LGTM: Enhanced URL pattern for VarAnnoSetDetailView

The update to use path() with <uuid:varannoset> is consistent with the previous change. It improves readability and ensures type safety for the varannoset parameter.


22-26: LGTM: Improved API URL pattern for VarAnnoSetListCreateApiView

The change to use path() with <uuid:project> for the API URL is consistent with the previous updates. It enhances readability and ensures type safety for the project parameter in the API.


27-31: LGTM: Enhanced API URL pattern for VarAnnoSetRetrieveUpdateDestroyApiView

The update to use path() with <uuid:varannoset> for the API URL is consistent with the previous changes. It improves readability and ensures type safety for the varannoset parameter in the API.


32-36: LGTM: Improved API URL pattern for VarAnnoSetEntryListCreateApiView

The change to use path() with <uuid:varannoset> for the API URL is consistent with the previous updates. It enhances readability and ensures type safety for the varannoset parameter in the API for VarAnnoSet entries.


37-41: LGTM: Consistent improvement in URL patterns

The update to use path() with <uuid:varannosetentry> for the API URL is consistent with all previous changes. This final change completes the transition from url() to path() for all URL patterns in this file.

Overall, these changes have significantly improved the URL routing by:

  1. Enhancing readability
  2. Ensuring type safety for parameters
  3. Following Django's recommended practices
  4. Providing a more maintainable and consistent URL structure

Great job on implementing these improvements consistently across all URL patterns!


Line range hint 1-46: Excellent update to URL routing using path()

This change successfully updates all URL patterns in the varannos app to use the path() function from django.urls instead of the deprecated url() function. The modifications:

  1. Improve code readability
  2. Enhance type safety by using uuid type for parameters
  3. Follow Django's recommended practices
  4. Provide a more maintainable URL structure

These updates will make the codebase more robust and easier to maintain. Great job on implementing this change consistently across all URL patterns!

backend/cohorts/urls.py (15)

4-4: LGTM: Correct import for path()

The change from from django.conf.urls import url to from django.urls import path is correct and aligns with Django's recommended practices for URL routing.


10-14: LGTM: Improved URL pattern for vueapp

The transition from url() to path() is well-implemented:

  1. The uuid path converter replaces the regex pattern, improving readability and type safety.
  2. The trailing slash is now enforced by default, ensuring consistent URL patterns.

This change aligns with Django's best practices for URL routing.


18-22: LGTM: Correct transition to path() for cohort list-create

The URL pattern for cohort list-create has been successfully updated to use path():

  • The uuid path converter is correctly used for the project parameter.
  • The URL structure remains consistent with the previous version.

This change improves code readability and maintainability.


23-27: LGTM: Proper update to path() for cohort retrieve-update-destroy

The URL pattern for cohort retrieve-update-destroy has been correctly updated:

  • The path() function is used appropriately.
  • The uuid path converter is correctly applied to the cohort parameter.
  • The URL structure maintains consistency with the previous pattern.

This change contributes to a more modern and maintainable URL configuration.


28-32: LGTM: Correct implementation of path() for cohortcase create

The URL pattern for cohortcase create has been properly updated:

  • The path() function is used correctly.
  • The uuid path converter is appropriately applied to the project parameter.
  • The URL structure maintains consistency with the previous pattern.

This change aligns with the overall improvement in URL configuration.


33-37: LGTM: Proper transition to path() for cohortcase list

The URL pattern for cohortcase list has been correctly updated:

  • The path() function is used appropriately.
  • The uuid path converter is correctly applied to the cohort parameter.
  • The URL structure maintains consistency with the previous pattern.

This change contributes to the overall improvement in URL routing clarity.


38-42: LGTM: Correct update to path() for cohortcase destroy

The URL pattern for cohortcase destroy has been properly updated:

  • The path() function is used correctly.
  • The uuid path converter is appropriately applied to the cohortcase parameter.
  • The URL structure maintains consistency with the previous pattern.

This change aligns with the modernization of URL configurations in the project.


43-47: LGTM: Proper implementation of path() for accessible-projects-cases list

The URL pattern for accessible-projects-cases list has been correctly updated:

  • The path() function is used appropriately.
  • The uuid path converter is correctly applied to the project parameter.
  • The URL structure maintains consistency with the previous pattern.

This change contributes to the overall improvement in URL configuration readability.


48-52: LGTM: Correct update to path() for user-permissions

The URL pattern for user-permissions has been properly updated:

  • The path() function is used correctly.
  • The uuid path converter is appropriately applied to the project parameter.
  • The URL structure maintains consistency with the previous pattern.

Note: The original regex pattern was missing the leading ^, which is now implicitly handled by path(), improving the URL matching.


56-60: LGTM: Proper transition to path() for API cohort list-create

The URL pattern for API cohort list-create has been correctly updated:

  • The path() function is used appropriately.
  • The uuid path converter is correctly applied to the project parameter.
  • The URL structure maintains consistency with the previous pattern.

This change aligns with the overall improvement in API URL routing.


61-65: LGTM: Correct implementation of path() for API cohort retrieve-update-destroy

The URL pattern for API cohort retrieve-update-destroy has been properly updated:

  • The path() function is used correctly.
  • The uuid path converter is appropriately applied to the cohort parameter.
  • The URL structure maintains consistency with the previous pattern.

This change contributes to a more modern and maintainable API URL configuration.


66-70: LGTM: Proper update to path() for API cohortcase create

The URL pattern for API cohortcase create has been correctly updated:

  • The path() function is used appropriately.
  • The uuid path converter is correctly applied to the project parameter.
  • The URL structure maintains consistency with the previous pattern.

This change aligns with the overall improvement in API URL routing clarity.


71-75: LGTM: Correct transition to path() for API cohortcase list

The URL pattern for API cohortcase list has been properly updated:

  • The path() function is used correctly.
  • The uuid path converter is appropriately applied to the cohort parameter.
  • The URL structure maintains consistency with the previous pattern.

This change contributes to the overall modernization of API URL configurations.


76-80: LGTM: Proper implementation of path() for API cohortcase destroy

The URL pattern for API cohortcase destroy has been correctly updated:

  • The path() function is used appropriately.
  • The uuid path converter is correctly applied to the cohortcase parameter.
  • The URL structure maintains consistency with the previous pattern.

This change aligns with the overall improvement in API URL routing.


81-85: LGTM: Correct update to path() for API accessible-projects-cases list

The URL pattern for API accessible-projects-cases list has been properly updated:

  • The path() function is used correctly.
  • The uuid path converter is appropriately applied to the project parameter.
  • The URL structure maintains consistency with the previous pattern.

Overall, the changes in this file successfully transition all URL patterns from url() to path(), improving readability, type safety, and maintainability of the URL configurations. The consistent use of uuid path converters for all UUID parameters enhances the robustness of the routing system.

backend/importer/urls.py (4)

4-4: LGTM: Updated import statement

The change from url to path is correct and aligns with Django's current best practices for URL routing.


11-16: LGTM: Updated ui_urlpatterns to use path()

The changes to ui_urlpatterns are correct:

  • Properly replaced url() with path().
  • Correctly used path converters <uuid:project> and <uuid:job> for UUID fields.
  • Maintained existing view functions and URL names.

These updates align with Django's recommended URL routing practices.


20-89: LGTM: Updated api_urlpatterns to use path()

The changes to api_urlpatterns are correct and consistent:

  • Successfully replaced all url() calls with path().
  • Appropriately used path converters (e.g., <uuid:project>, <uuid:caseimportinfo>, <uuid:variantsetimportinfo>) for UUID fields.
  • Maintained existing view functions and URL names.
  • Improved readability by simplifying URL patterns.

These updates align with Django's recommended URL routing practices and maintain the existing API structure.


Line range hint 1-92: Summary: Successful migration to Django's path() function

The changes in this file successfully migrate all URL patterns from the deprecated url() function to the recommended path() function. Key points:

  1. Consistent updates across both ui_urlpatterns and api_urlpatterns.
  2. Appropriate use of path converters for UUID fields.
  3. Maintained existing view functions and URL names, preserving functionality.
  4. Improved code readability by simplifying URL patterns.

These changes align with Django's current best practices for URL routing and should improve maintainability of the codebase.

backend/variants/models/maintenance.py (3)

122-134: Well-structured SQL command for materialized view management

The SQL_OUTER command is well-designed and follows good practices:

  1. It uses IF EXISTS when dropping the view, preventing errors if the view doesn't exist.
  2. The WITH NO DATA clause in the create statement allows for separate data population, which can be more efficient for large datasets.
  3. Appropriate indexes are created, including a unique index on the id column and a composite index for efficient querying.

These practices contribute to robust and efficient database management.


114-188: Summary of changes and suggestions

The new functions drop_variants_smallvariantsummary and create_variants_smallvariantsummary, along with the SQL commands SQL_OUTER and SQL_INNER, provide a robust mechanism for managing the SmallVariantSummary materialized view.

Key points:

  1. Both functions can be improved by simplifying nested with statements.
  2. The SQL commands are well-structured and follow good practices.
  3. A minor optimization in SQL_INNER has been suggested, removing DISTINCT if appropriate.
  4. While the use of string interpolation for SQL commands is generally discouraged, it's acceptable in this specific case as the SQL strings are constants.

Overall, these changes enhance the functionality for managing the SmallVariantSummary materialized view. Implementing the suggested minor improvements will further refine the code quality.

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


183-188: Caution with SQL string interpolation

The overall structure of the function is good, using a transaction to ensure atomicity. However, it's worth noting the use of string interpolation (%) for combining SQL commands.

While in this specific case both SQL_OUTER and SQL_INNER are defined within the code and not influenced by external input (minimizing SQL injection risks), it's generally a good practice to avoid string interpolation for SQL commands. Consider using parameterized queries where possible in other parts of the codebase.

To verify that SQL_OUTER and SQL_INNER are indeed constants and not influenced by external input, you can run the following command:

This will show the definitions of SQL_OUTER and SQL_INNER, allowing us to confirm they are indeed constant string literals.

✅ Verification successful

SQL string interpolation is safe as SQL_OUTER and SQL_INNER are constants

The definitions of SQL_OUTER and SQL_INNER have been verified to be constant string literals within backend/variants/models/maintenance.py, ensuring they are not influenced by external input. This minimizes the risk of SQL injection.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that SQL_OUTER and SQL_INNER are constants
rg --type python -A 10 'SQL_OUTER\s*=' backend/variants/models/maintenance.py
rg --type python -A 10 'SQL_INNER\s*=' backend/variants/models/maintenance.py

Length of output: 221


Script:

#!/bin/bash
# Revised scripts to verify that SQL_OUTER and SQL_INNER are constants
rg 'SQL_OUTER\s*=' backend/variants/models/maintenance.py -A 10
rg 'SQL_INNER\s*=' backend/variants/models/maintenance.py -A 10

Length of output: 959

🧰 Tools
🪛 Ruff

186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

backend/variants/tests/test_ui.py (1)

164-164: LGTM! Verify the base class change.

The renaming of TestUIBase to UITestBase improves clarity and follows common naming conventions for test classes.

Please ensure that the base class projectroles.tests.test_ui.UITestBase exists and provides the expected functionality. Run the following script to verify:

utils/docker/Dockerfile (3)

Line range hint 1-241: Approve overall Dockerfile structure with final build verification.

The multi-stage build process and overall structure of the Dockerfile have been well-maintained while making necessary version upgrades. This approach minimizes the risk of introducing new issues.

To ensure the changes haven't inadvertently affected the build process, please run the following verification steps:

  1. Build the Docker image:

  2. Run a container from the built image:

  3. Inside the container, verify the installed versions:

  4. Test the application startup:

These steps will help ensure that the image builds successfully and the application starts without issues.

✅ Verification successful

Dockerfile structure and PostgreSQL version approved, with minor notes.

The Dockerfile maintains its multi-stage build process and overall structure, which is good for minimizing the risk of introducing new issues. The changes appear to be focused on updating dependencies and versions:

  1. The base Python image has been updated to 3.11-bookworm.
  2. PostgreSQL client version 14 is now installed, which is compatible with the README requirement of PostgreSQL >=12.

Notes:

  • The README mentions PostgreSQL >=12 as a dependency, while the Dockerfile installs PostgreSQL client 14. This is compatible and up-to-date.
  • No specific PostgreSQL version is enforced in the configuration files, allowing for flexibility in the server version used.

The Dockerfile changes and structure are approved. The PostgreSQL version used (14) is compatible with the project requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

   docker build -t varfish-server:test .
   

Length of output: 282809


Script:

   docker run --rm -it varfish-server:test /bin/bash
   

Length of output: 125


Script:

   python --version
   psql --version
   

Length of output: 181


Script:

   docker run --rm -p 8080:8080 varfish-server:test
   

Length of output: 124


Script:

#!/bin/bash
# Check Dockerfile contents
cat utils/docker/Dockerfile

# Look for docker-compose files
find . -name "docker-compose*.y*ml" -type f -exec cat {} +

# Check for README files
find . -name "README*" -type f -exec cat {} +

# Check for PostgreSQL version in project configuration
grep -r "postgresql" . | grep -i "version"

Length of output: 11616


42-42: Approve Python version upgrade with compatibility check.

The upgrade to Python 3.11 is a positive change, bringing performance improvements and new features. However, it's crucial to ensure that all project dependencies are compatible with Python 3.11.

Please run the following script to check for any potential compatibility issues:

✅ Verification successful

Python 3.11 upgrade confirmed. Recommend thorough testing.

The upgrade from Python 3.10 to 3.11 has been successfully implemented in the project. The Pipfile in the backend directory explicitly sets python_version = "3.11", and the Pipfile.lock file reflects this change with appropriate version markers for dependencies.

To ensure full compatibility:

  1. Run the project's test suite to verify that all functionality works with Python 3.11.
  2. Check for any deprecation warnings that might have been introduced in Python 3.11.
  3. Review the Python 3.11 release notes for any features or optimizations you might want to leverage in your project.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Python version compatibility in dependencies

# Test: Check if any dependencies specify Python version < 3.11
rg --type=toml 'python_version\s*<\s*"?3\.11"?' backend/Pipfile

# Test: Look for any Python version specifications in requirements files
fd -e txt -e in requirements | xargs rg 'python_version|Python=='

# Test: Check for any version-specific code in Python files
rg -t py '(sys\.version_info|python_version)'

Length of output: 282809


Script:

#!/bin/bash
# Search for Python version specifications in common configuration files

# Search in requirements.txt files
echo "Searching in requirements.txt files:"
find . -name "requirements*.txt" -type f -exec grep -H "python_version" {} +

# Search in Pipfile
echo "Searching in Pipfile:"
find . -name "Pipfile" -type f -exec grep -H "python_version" {} +

# Search in setup.py files
echo "Searching in setup.py files:"
find . -name "setup.py" -type f -exec grep -H "python_version" {} +

# Search in any YAML files (like GitHub Actions workflows)
echo "Searching in YAML files:"
find . -name "*.yml" -o -name "*.yaml" -type f -exec grep -H "python-version" {} +

# Search for any mentions of Python 3.11 in all files
echo "Searching for Python 3.11 mentions:"
grep -r "python 3.11" .
grep -r "python3.11" .
grep -r "python_version.*3.11" .

Length of output: 1288


59-59: Approve PostgreSQL client upgrade with compatibility verification.

The upgrade to PostgreSQL client 14 is a good step to maintain compatibility with newer PostgreSQL server versions. However, it's important to ensure that this change doesn't introduce any issues with existing database interactions.

Please run the following script to check for any potential compatibility issues:

Additionally, please ensure that:

  1. The application's database interactions are thoroughly tested with the new client version.
  2. Any CI/CD pipelines are updated to use PostgreSQL 14 for testing.
  3. The production environment is prepared for this change if it's using an older PostgreSQL version.

Also applies to: 66-66

✅ Verification successful

Approve PostgreSQL upgrade with documentation update recommendation

The upgrade from PostgreSQL client 12 to 14 has been successfully implemented in the Dockerfile. No references to PostgreSQL 12 were found in Python files or critical configuration files, indicating that the codebase has been properly updated to work with the new version.

However, there are a couple of outdated references to PostgreSQL 12 in the documentation:

  1. In CHANGELOG.md: "Installing same postgres version as in docker-compose server (12)."
  2. In docs/admin_install.rst: A reference to "postgres:12" in what appears to be a Docker container listing.

To maintain consistency, it is recommended to update these documentation files to reflect the upgrade to PostgreSQL 14.

The lack of version-specific PostgreSQL references in configuration files suggests that the configurations are appropriately version-agnostic, which is a good practice for maintainability.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify PostgreSQL client compatibility

# Test: Check for any hardcoded PostgreSQL version numbers in Python files
rg -t py 'postgresql.*12|psycopg2.*12'

# Test: Look for any PostgreSQL-specific SQL syntax that might have changed
fd -e sql | xargs rg '\b12\b'

# Test: Check for any version-specific PostgreSQL configuration
fd -e yml -e yaml -e conf -e config | xargs rg 'postgresql.*12|postgres.*12'

Length of output: 282809


Script:

#!/bin/bash
# Check Dockerfile for PostgreSQL 14 upgrade
echo "Checking Dockerfile for PostgreSQL 14:"
grep -n "postgres.*14" utils/docker/Dockerfile

# Check for PostgreSQL 12 references in Python files
echo -e "\nChecking Python files for PostgreSQL 12 references:"
rg -t py "postgresql.*12|psycopg2.*12"

# Check configuration files for PostgreSQL version references
echo -e "\nChecking configuration files for PostgreSQL version references:"
rg -t yml -t yaml -t conf -t config "postgresql.*1[24]|postgres.*1[24]"

# Check for any remaining PostgreSQL 12 references
echo -e "\nChecking for any remaining PostgreSQL 12 references:"
rg "postgresql.*12|postgres.*12" --type-not py --type-not yml --type-not yaml --type-not conf --type-not config

Length of output: 867


Script:

#!/bin/bash
# Check configuration files for PostgreSQL version references
echo "Checking configuration files for PostgreSQL version references:"
find . -name "*.yml" -o -name "*.yaml" -o -name "*.conf" -o -name "*.config" | xargs grep -n "postgresql.*1[24]\|postgres.*1[24]"

# Check for any remaining PostgreSQL 12 references
echo -e "\nChecking for any remaining PostgreSQL 12 references:"
grep -r "postgresql.*12\|postgres.*12" . --exclude="*.py" --exclude="*.yml" --exclude="*.yaml" --exclude="*.conf" --exclude="*.config"

# List all files containing 'postgres' for manual review if needed
echo -e "\nListing files containing 'postgres' for potential manual review:"
grep -r -l "postgres" .

Length of output: 4016

backend/varfish/users/management/commands/initdev.py (3)

Line range hint 69-91: LGTM: Enhanced command-line options for initialization

The new command-line arguments (--data-release, --data-case, --data-import-job, and --data-create) significantly improve the flexibility of the initialization process. These additions allow for more granular control over the development environment setup, particularly in terms of data creation and import job handling.


Line range hint 93-116: LGTM: Well-structured handling of new initialization options

The handle method has been effectively updated to accommodate the new data_create option. The implementation demonstrates good practices:

  1. The core logic is wrapped in a transaction, ensuring data consistency.
  2. Long-running tasks (job execution) are placed outside the transaction, preventing potential issues with long-running transactions.
  3. The method provides clear feedback to the user about the actions taken.

This structure allows for flexible initialization scenarios while maintaining robustness.


Line range hint 1-428: Overall assessment: Well-implemented enhancements to initialization command

The changes to the initdev.py file significantly improve the flexibility and functionality of the initialization command. Key improvements include:

  1. Addition of new command-line arguments for fine-grained control over data creation and import jobs.
  2. Well-structured handling of new initialization options, including proper transaction management.
  3. Comprehensive implementation of various initialization scenarios.
  4. Improved naming consistency.

The code maintains good practices in error handling, user feedback, and overall structure. The minor suggestions for improvement (adding clarifying comments) would further enhance the code's readability, but they are not critical issues.

Great job on these enhancements!

backend/cases/tests/test_permissions_api.py (1)

4-4: LGTM! Consistent base class update across test classes.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase has been applied consistently across all test classes in this file. This refactoring improves naming consistency and doesn't affect the functionality of the tests.

Let's verify if this change is consistent across the entire codebase:

Also applies to: 10-10, 105-105, 156-156, 238-238, 264-264, 290-290, 340-340, 422-422, 448-448, 474-474, 500-500

✅ Verification successful

Verification Successful! All instances of TestProjectAPIPermissionBase have been replaced with ProjectAPIPermissionTestBase across the codebase. The refactoring maintains consistency and does not affect the functionality of the tests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining occurrences of TestProjectAPIPermissionBase
# and new occurrences of ProjectAPIPermissionTestBase

echo "Checking for any remaining TestProjectAPIPermissionBase:"
rg "TestProjectAPIPermissionBase" --type python

echo "Checking for new ProjectAPIPermissionTestBase:"
rg "ProjectAPIPermissionTestBase" --type python

echo "Checking for any test classes still inheriting from TestProjectAPIPermissionBase:"
ast-grep --lang python --pattern 'class $NAME(TestProjectAPIPermissionBase)'

Length of output: 980


Script:

#!/bin/bash
# Description: Check for any remaining occurrences of TestProjectAPIPermissionBase
# and new occurrences of ProjectAPIPermissionTestBase using the correct file type.

echo "Checking for any remaining TestProjectAPIPermissionBase:"
rg "TestProjectAPIPermissionBase" -t py

echo "Checking for new ProjectAPIPermissionTestBase:"
rg "ProjectAPIPermissionTestBase" -t py

echo "Checking for any test classes still inheriting from TestProjectAPIPermissionBase:"
ast-grep --lang python --pattern 'class $NAME(TestProjectAPIPermissionBase)'

Length of output: 17830

backend/variants/tests/test_views_ajax_presets.py (1)

3-3: LGTM! Verify the new base class implementation.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase looks good. This update is consistently applied across all test classes in the file, which is a positive change for maintainability.

To ensure the new base class is correctly implemented and doesn't introduce any regressions, please run the following command:

Also applies to: 26-26

backend/config/settings/base.py (2)

Line range hint 1-1093: Overall assessment of changes

The changes to this settings file primarily focus on adding OpenID Connect (OIDC) authentication support and updating the ADMIN_URL configuration. These modifications enhance the authentication options and simplify the admin URL setup.

Key points:

  1. OIDC configuration has been successfully added.
  2. ADMIN_URL has been simplified to a string format.
  3. New environment variables have been introduced for OIDC settings.

The changes are generally well-implemented, with only minor suggestions for improvement in the OIDC configuration. Ensure that placeholder values are replaced with actual credentials in the production environment, and consider adding a few additional OIDC-related settings for enhanced security and flexibility.

Remember to test these changes thoroughly in a staging environment before deploying to production, especially to verify that the ADMIN_URL change doesn't affect existing functionality.


438-438: ADMIN_URL updated to use a string instead of regex

The ADMIN_URL has been changed from a regex pattern to a simple string "admin/". This change simplifies the configuration and is generally fine for most use cases.

However, be aware that this change might affect any existing code or configurations that expect the ADMIN_URL to be a regex pattern. Ensure that this change is consistent with your project's requirements and doesn't break any existing functionality.

To ensure this change doesn't affect other parts of the codebase, you may want to search for any uses of ADMIN_URL:

✅ Verification successful

Verification Successful: ADMIN_URL Change is Safe

The change of ADMIN_URL from a regex pattern to the string "admin/" has been reviewed and does not affect other parts of the codebase.

  • Affected File:
    • backend/config/urls.py uses ADMIN_URL with Django's path, which correctly handles string URLs.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for uses of ADMIN_URL in Python files
rg "ADMIN_URL" --type python

Length of output: 59


Script:

#!/bin/bash
# Search for uses of ADMIN_URL in Python files using the correct file type specifier
rg "ADMIN_URL" --type py

Length of output: 223

backend/variants/tests/test_permissions_ajax_presets.py (4)

Line range hint 17-62: LGTM: TestFrequencyPresetsListCreateAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_list and test_create) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate.


Line range hint 64-138: LGTM: TestFrequencyPresetsRetrieveUpdateDestroyAjaxView implementation is correct and thorough.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_retrieve, test_update, and test_destroy) are implemented correctly, covering all necessary permission checks for different user types. The URL construction and assertions are accurate. The test_destroy method's approach of creating a new FrequencyPresetsFactory for each user ensures test independence, which is a good practice.


Line range hint 167-193: LGTM: TestFrequencyPresetsCloneOtherView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method properly initializes the required test data, and the test_post method covers all necessary permission checks for different user types. The URL construction and assertions are accurate.


Line range hint 905-959: LGTM with suggestions: TestQuickPresetsListCreateAjaxView implementation is correct.

The class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The setUp method and test methods (test_list and `test

backend/cases_import/models/executors.py (6)

139-139: Minor change in _build_fs_options method

The keyword argument used when calling app_settings.get() has been changed from "app_name" to "plugin_name". This change is likely to align with updated naming conventions or to better reflect the nature of the setting.


Line range hint 1037-1039: Improved error handling in _run method

The _run method now includes a more robust error handling approach by using a try-except block to catch ParseError exceptions when parsing the phenopackets Family data. This change enhances the reliability of the import process by providing more informative error messages.


Line range hint 1041-1045: New transaction handling in _run_create_or_update

The creation of a new case or updating an existing case's state is now wrapped in a transaction. This ensures atomicity of these operations, which is a good practice for maintaining data consistency.


Line range hint 1046-1048: Conditional file clearing in update scenario

The code now only clears external and internal files when the action is an update. This is a sensible approach to avoid unnecessary file operations during case creation.


Line range hint 1049-1060: Comprehensive case import process

The _run_create_or_update method now includes a series of steps for the case import process, including:

  1. Creating external file entries
  2. Importing quality control files
  3. Importing and annotating sequence variants
  4. Importing and annotating structural variants
  5. Updating the case state to "done"

This structured approach ensures a complete and orderly import process.


Line range hint 1062-1069: Improved logging in _create_or_update_case

The method now logs whether it's creating a new case or updating an existing one. This enhances the traceability of the import process.

backend/cases/urls.py (2)

1-149: Successful Migration to path() and UUID Converters

Great job updating the URL patterns from the deprecated url() function to the modern path() function. The consistent use of <uuid:...> converters enhances type safety and aligns with Django's best practices.


103-107: Consistency Check for API Endpoints

Please verify that all API URL patterns are correctly using the views_api module and have routes prefixed with 'api'. This ensures a clear separation between AJAX and API functionalities.

Run the following script to identify any inconsistencies:

Also applies to: 128-147

✅ Verification successful

Consistency Check Passed

All API URL patterns in backend/cases/urls.py are correctly using the views_api module and have routes prefixed with 'api'. No inconsistencies found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find API URL patterns using AJAX views or incorrect route prefixes.

# Find patterns in api_urlpatterns that use views_ajax
rg --type python --block-md -A 5 "api_urlpatterns" backend/cases/urls.py | rg "view=views_ajax"

# Find routes in api_urlpatterns that start with 'ajax' instead of 'api'
rg --type python --block-md -A 5 "api_urlpatterns" backend/cases/urls.py | rg "route=\"ajax/"

Length of output: 1076


Script:

#!/bin/bash
# Description: Find API URL patterns using AJAX views or incorrect route prefixes.

# Find patterns in api_urlpatterns that use views_ajax
rg --type python "api_urlpatterns" backend/cases/urls.py | rg "view=views_ajax"

# Find routes in api_urlpatterns that start with 'ajax' instead of 'api'
rg --type python "api_urlpatterns" backend/cases/urls.py | rg 'route="ajax/'

Length of output: 216


Script:

#!/bin/bash
# Description: Find API URL patterns using AJAX views or incorrect route prefixes.

# Find patterns in api_urlpatterns that use views_ajax
rg "api_urlpatterns" backend/cases/urls.py | rg "view=views_ajax"

# Find routes in api_urlpatterns that start with 'ajax' instead of 'api'
rg "api_urlpatterns" backend/cases/urls.py | rg 'route="ajax/'

Length of output: 126

backend/variants/urls/presets.py (2)

3-3: Correctly updated import statement

The import statement has been updated to import path from django.urls, replacing url from django.conf.urls, which is appropriate for Django 2.0 and above.


12-164: Verify that new path() patterns maintain original URL behavior

The URL patterns have been transitioned from using url() with regex patterns to path() with path converters. Please ensure that the new path() patterns accurately reflect the original URL structures and parameter validations.

Specifically, verify that:

  • UUIDs are correctly captured using <uuid:...>.
  • Slugs are appropriately used with <slug:...>, keeping in mind any changes in allowed characters compared to the original regex patterns.

You can run the following script to compare the old regex patterns with the new path() patterns:

This script will help you manually verify that the new path() definitions match the behavior of the original regex patterns.

backend/variants/urls/__init__.py (1)

Line range hint 1-450: Migration to path() with path converters is correct and improves maintainability

The refactoring from url() with regex patterns to path() using path converters enhances readability and aligns with modern Django practices. Utilizing <uuid:...> ensures accurate URL parameter parsing for UUIDs, and the overall URL routing functionality is preserved.

backend/svs/urls.py (2)

2-2: Successful Update to Django URL Imports

The import statement has been correctly updated to use path and re_path from django.urls, which is recommended in newer versions of Django after deprecating the old url() function.


133-140: Verify the Use of Anchors in re_path() Patterns

In the re_path() patterns at lines 133-140, you have included ^ and $ anchors:

re_path(
    r"^worker/(?P<url>.*)$",
    HttpProxy.as_view(...),
),

While re_path() does not implicitly anchor the patterns, consider whether the anchors are necessary for your use case. If the goal is to match any URL starting with worker/, you might remove the anchors for greater flexibility:

re_path(
    r"worker/(?P<url>.*)",
    HttpProxy.as_view(...),
),

However, if you intend to match the entire URL precisely, keeping the anchors is appropriate.

backend/config/urls.py (1)

Line range hint 1-198: LGTM!

The migration from url() to path() and re_path() is appropriately handled throughout the URL routing configuration. The updates align with Django's recommended practices, enhancing code clarity and maintainability.

Comment on lines +890 to +905
SOCIAL_AUTH_OIDC_OIDC_ENDPOINT = env.str("SOCIAL_AUTH_OIDC_OIDC_ENDPOINT", None)
SOCIAL_AUTH_OIDC_KEY = env.str("SOCIAL_AUTH_OIDC_KEY", "CHANGEME")
SOCIAL_AUTH_OIDC_SECRET = env.str("SOCIAL_AUTH_OIDC_SECRET", "CHANGEME")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure secure values for OIDC credentials

The SOCIAL_AUTH_OIDC_KEY and SOCIAL_AUTH_OIDC_SECRET are currently set to "CHANGEME". For secure authentication, replace these placeholders with the actual client ID and secret from your OIDC provider in your environment variables.

Update your environment variables or deployment configuration to set these values:

SOCIAL_AUTH_OIDC_KEY=your_actual_client_id
SOCIAL_AUTH_OIDC_SECRET=your_actual_client_secret

Remember to keep these values confidential and never commit them to version control.

Comment on lines +143 to 147
path(
route="api/case-relatedness/list/<uuid:case>/",
view=views_ajax.PedigreeRelatednessListAjaxView.as_view(),
name="api-caserelatedness-list",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent View References in API URL Patterns

On line 144, the URL pattern references an AJAX view within the API patterns. Updating it to use the appropriate API view will maintain consistency.

Apply this diff to correct the view reference:

-            view=views_ajax.PedigreeRelatednessListAjaxView.as_view(),
+            view=views_api.PedigreeRelatednessListApiView.as_view(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
path(
route="api/case-relatedness/list/<uuid:case>/",
view=views_ajax.PedigreeRelatednessListAjaxView.as_view(),
name="api-caserelatedness-list",
),
path(
route="api/case-relatedness/list/<uuid:case>/",
view=views_api.PedigreeRelatednessListApiView.as_view(),
name="api-caserelatedness-list",
),

Comment on lines +103 to 107
path(
route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
view=views_api.CaseCommentRetrieveUpdateDestroyApiView.as_view(),
name="api-casecomment-retrieveupdatedestroy",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent Route Prefix in API URL Patterns

The route on line 104 starts with 'ajax' within the api_urlpatterns section, which may lead to confusion. For consistency and clarity, consider changing the route prefix from 'ajax' to 'api'.

Apply this diff to fix the inconsistency:

-            route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
+            route="api/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
path(
route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
view=views_api.CaseCommentRetrieveUpdateDestroyApiView.as_view(),
name="api-casecomment-retrieveupdatedestroy",
),
path(
route="api/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
view=views_api.CaseCommentRetrieveUpdateDestroyApiView.as_view(),
name="api-casecomment-retrieveupdatedestroy",
),

Comment on lines +133 to 137
path(
route="api/case-alignment-stats/list/<uuid:case>/",
view=views_ajax.CaseAlignmentStatsListAjaxView.as_view(),
name="api-casealignmentstats-list",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent View References in API URL Patterns

Similarly, the API URL pattern on line 134 references an AJAX view. Updating it to the corresponding API view will ensure consistent API behavior.

Apply this diff to correct the view reference:

-            view=views_ajax.CaseAlignmentStatsListAjaxView.as_view(),
+            view=views_api.CaseAlignmentStatsListApiView.as_view(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
path(
route="api/case-alignment-stats/list/<uuid:case>/",
view=views_ajax.CaseAlignmentStatsListAjaxView.as_view(),
name="api-casealignmentstats-list",
),
path(
route="api/case-alignment-stats/list/<uuid:case>/",
view=views_api.CaseAlignmentStatsListApiView.as_view(),
name="api-casealignmentstats-list",
),

Comment on lines +128 to 132
path(
route="api/case-gene-annotation/list/<uuid:case>/",
view=views_ajax.CaseGeneAnnotationListAjaxView.as_view(),
name="api-casegeneannotation-list",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent View References in API URL Patterns

The API URL pattern on line 129 is referencing an AJAX view instead of an API view. This could blur the separation of concerns between AJAX and API endpoints. Please update the view to use the appropriate API view.

Apply this diff to correct the view reference:

-            view=views_ajax.CaseGeneAnnotationListAjaxView.as_view(),
+            view=views_api.CaseGeneAnnotationListApiView.as_view(),

Committable suggestion was skipped due to low confidence.

Comment on lines +138 to 142
path(
route="api/case-variant-stats/list/<uuid:case>/",
view=views_ajax.SampleVariantStatisticsListAjaxView.as_view(),
name="api-casevariantstats-list",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent View References in API URL Patterns

The pattern on line 139 should reference an API view instead of an AJAX view for consistency.

Apply this diff to correct the view reference:

-            view=views_ajax.SampleVariantStatisticsListAjaxView.as_view(),
+            view=views_api.SampleVariantStatisticsListApiView.as_view(),

Committable suggestion was skipped due to low confidence.

Comment on lines +11 to 24
path(
"<uuid:project>/import/<uuid:job>/",
view=views.ImportStructuralVariantsJobDetailView.as_view(),
name="import-job-detail",
),
url(
regex=r"^build-bg-sv/(?P<job>[0-9a-f-]+)/?$",
path(
"build-bg-sv/<uuid:job>/",
view=views.BuildBackgroundSvSetJobDetailView.as_view(),
name="build-bg-sv-set-job-detail",
),
url(
regex=r"^cleanup-bg-sv/(?P<job>[0-9a-f-]+)/?$",
path(
"cleanup-bg-sv/<uuid:job>/",
view=views.CleanupBackgroundSvSetJobDetailView.as_view(),
name="cleanup-bg-sv-set-job-detail",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure Consistent Trailing Slash Behavior in URL Patterns

When converting from url() to path(), be cautious about how trailing slashes are handled. The previous url() patterns used /?$, allowing both versions with and without a trailing slash. The path() function requires explicit handling of trailing slashes.

For the following URL patterns:

  • Lines 11-15: path("<uuid:project>/import/<uuid:job>/", ...)
  • Lines 16-20: path("build-bg-sv/<uuid:job>/", ...)
  • Lines 21-25: path("cleanup-bg-sv/<uuid:job>/", ...)

Ensure that the application's settings and middleware (APPEND_SLASH and CommonMiddleware) are configured to handle trailing slashes as intended. If users may access these URLs with or without a trailing slash, you might consider one of the following:

  1. Add a second pattern without the trailing slash:
    path("<uuid:project>/import/<uuid:job>", ...),
  2. Use re_path() with a regex that accepts an optional trailing slash:
    re_path(r"^build-bg-sv/(?P<job>[0-9a-f-]+)/?$", ...),

Comment on lines +29 to +35
path(
"ajax/fetch-variants/<uuid:case>/",
view=views.SvFetchVariantsAjaxView.as_view(),
name="ajax-variants-fetch",
),
url(
regex=r"^ajax/query-case/quick-presets/?$",
path(
"ajax/query-case/quick-presets",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Address Potential Changes in URL Matching for 'quick-presets'

The original pattern for ajax/query-case/quick-presets allowed an optional trailing slash due to /?$ in the regex:

url(regex=r"^ajax/query-case/quick-presets/?$", ...)

The updated pattern:

path("ajax/query-case/quick-presets", ...)

does not accept a trailing slash. To maintain the previous behavior where both versions are accepted, consider one of the following:

  1. Add a trailing slash to the pattern string:
    path("ajax/query-case/quick-presets/", ...)
  2. Use re_path() with an optional trailing slash in the regex:
    re_path(r"^ajax/query-case/quick-presets/?$", ...)
  3. Ensure that APPEND_SLASH and CommonMiddleware are properly configured.

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch 2 times, most recently from 6bd452d to 56b6696 Compare October 16, 2024 09:34
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (12)
backend/variants/models/maintenance.py (2)

114-119: Simplify nested with statements and approve implementation

The function drop_variants_smallvariantsummary() is well-implemented and serves its purpose correctly. However, we can improve its readability by combining the nested with statements.

Please consider the following change:

 def drop_variants_smallvariantsummary():
     """Drop the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute("DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary")

This change maintains the same functionality while simplifying the code structure.

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


137-180: SQL_INNER implementation is robust with a minor optimization opportunity

The SQL_INNER query is well-structured and effectively aggregates variant data while excluding certain cases based on project settings. The use of a CTE for excluded cases and the DISTINCT clause in the subquery are good practices.

Consider a minor optimization: move the DISTINCT clause to the outer query to potentially improve performance. Here's the suggested change:

-    SELECT DISTINCT
+    SELECT
         variants.release,
         variants.chromosome,
         variants.start,
         variants."end",
         variants.bin,
         variants.reference,
         variants.alternative,
         variants.num_hom_ref,
         variants.num_het,
         variants.num_hom_alt,
         variants.num_hemi_ref,
         variants.num_hemi_alt,
         variants.case_id
     FROM variants_smallvariant AS variants
     WHERE NOT EXISTS (SELECT 1 from excluded_case_ids AS e WHERE e.case_id = variants.case_id)
 ) AS variants_per_case
-GROUP BY (release, chromosome, start, "end", bin, reference, alternative)
+GROUP BY DISTINCT (release, chromosome, start, "end", bin, reference, alternative)

This change might improve query performance by reducing the amount of data processed in the subquery.

backend/varfish/users/management/commands/initdev.py (3)

Line range hint 64-89: LGTM! Consider clarifying help text for --data-create.

The new command-line arguments enhance the flexibility and control of the initialization process, particularly for data creation and import jobs. The choices for each argument are well-defined, which helps prevent input errors.

Consider updating the help text for the --data-create argument to more clearly explain the differences between "job-create" and "job-run" options:

 parser.add_argument(
     "--data-create",
     default="disabled",
     choices=["disabled", "job-create", "job-run"],
-    help="Run import job for case",
+    help="Control data creation: 'disabled' (default), 'job-create' (create job without running), or 'job-run' (create and run job)",
 )

Line range hint 91-114: LGTM! Consider adding error handling for unexpected data_create values.

The changes in the handle method effectively implement the functionality for the new data_create argument, allowing for the creation and optional execution of import jobs. The use of transaction.atomic() ensures data integrity during these operations.

Consider adding an else clause to handle unexpected data_create values, even though they should be prevented by the argument choices:

 elif data_create == "job-run" and job_pk is not None:
     self.stderr.write(self.style.SUCCESS("Executing import job..."))
     models.run_caseimportactionbackgroundjob(pk=job_pk)
     self.stderr.write(self.style.SUCCESS("... import job executed successfully."))
+else:
+    self.stderr.write(self.style.WARNING(f"Unexpected data_create value: {data_create}"))

Line range hint 1-431: Overall improvements to initialization command flexibility and functionality.

The changes in this file significantly enhance the Django management command for initializing a development environment. Key improvements include:

  1. Addition of new command-line arguments for more granular control over data creation and import jobs.
  2. Expanded functionality in the handle method to support creating and optionally running import jobs.
  3. Minor refactoring for improved naming consistency.

These changes provide developers with more flexibility in setting up development environments, particularly when working with different data scenarios. The code maintains good practices such as using transactions for database operations.

Consider adding comprehensive logging throughout the initialization process. This would help in debugging and monitoring, especially when the command is used in automated scripts or CI/CD pipelines. For example:

import logging

logger = logging.getLogger(__name__)

class Command(BaseCommand):
    def handle(self, *args, **options):
        logger.info("Starting initialization process")
        # ... existing code ...
        logger.info("Initialization process completed")
backend/variants/tests/test_views_ajax_presets.py (2)

122-129: LGTM! Consider applying similar changes to other test classes.

The removal of mocking in favor of direct assertions on the response is a good improvement. This change simplifies the test and makes it more robust.

If not already done, consider applying similar changes to other test classes in this file and across the project for consistency.


Line range hint 1-872: Excellent refactoring of test suite for improved robustness and maintainability.

The changes made to this file represent a significant improvement in the testing approach:

  1. Updating the base class from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase.
  2. Consistently removing mocking in favor of direct assertions across all preset types and operations.
  3. Simplifying test methods while maintaining thorough coverage.

These changes will likely result in a more robust and maintainable test suite. The consistency of the refactoring across different preset types and operations is commendable and indicates a well-planned effort.

Consider documenting the new testing approach (if not already done) to ensure that future contributions to the test suite follow this improved pattern.

backend/seqvars/tests/test_permissions_api.py (4)

Line range hint 62-204: Consider enhancing the TestQueryPresetsSetViewSet class

While the overall structure of the TestQueryPresetsSetViewSet class is good, there are a few areas that could be improved:

  1. The setUp method could be more robust by creating all necessary objects upfront, reducing redundancy in individual test methods.
  2. Test method names could be more descriptive, clearly indicating what aspect of the operation they're testing (e.g., test_list_returns_200_for_authorized_users).
  3. The cleanup process in create and delete tests could be optimized to use bulk operations or more efficient querying.

Here's an example of how you could enhance the setUp method:

def setUp(self):
    super().setUp()
    self.querypresetsset = SeqvarsQueryPresetsSetFactory(project=self.project)
    self.list_url = reverse(
        "seqvars:api-querypresetsset-list",
        kwargs={"project": self.project.sodar_uuid},
    )
    self.detail_url = reverse(
        "seqvars:api-querypresetsset-detail",
        kwargs={
            "project": self.project.sodar_uuid,
            "querypresetsset": self.querypresetsset.sodar_uuid,
        },
    )
    self.post_data = {
        "rank": 1,
        "label": "test",
    }

This setup would allow you to simplify your test methods and make them more readable.


Line range hint 205-355: Consider refactoring to reduce duplication in test classes

The TestQueryPresetsVersionSetViewSet class is very similar in structure to TestQueryPresetsSetViewSet and other test classes in this file. To reduce code duplication and improve maintainability, consider creating a base test class that implements the common CRUD test methods.

Here's an example of how you could refactor this:

class BaseCRUDTestCase(ProjectAPIPermissionTestBase):
    factory_class = None
    viewset_name = None

    def setUp(self):
        super().setUp()
        self.obj = self.factory_class(project=self.project)
        self.list_url = reverse(f"seqvars:api-{self.viewset_name}-list", kwargs={"project": self.project.sodar_uuid})
        self.detail_url = reverse(f"seqvars:api-{self.viewset_name}-detail", kwargs={"project": self.project.sodar_uuid, self.viewset_name: self.obj.sodar_uuid})

    def test_list(self):
        # Common list test implementation

    def test_create(self):
        # Common create test implementation

    def test_retrieve(self):
        # Common retrieve test implementation

    def test_update(self):
        # Common update test implementation

    def test_delete(self):
        # Common delete test implementation

class TestQueryPresetsVersionSetViewSet(BaseCRUDTestCase):
    factory_class = SeqvarsQueryPresetsSetVersionFactory
    viewset_name = 'querypresetssetversion'

    # Add or override specific tests as needed

This approach would significantly reduce code duplication across your test classes and make it easier to maintain and extend your test suite.


Line range hint 356-2347: Consider a major refactoring of the test file structure

The current structure of this test file involves significant code duplication across multiple test classes. While each class tests a different model, they all follow the same pattern for CRUD operations and permission testing. This repetition makes the file harder to maintain and increases the risk of inconsistencies when updating tests.

Consider implementing the following refactoring strategy:

  1. Create a base test class that encapsulates the common CRUD and permission testing logic.
  2. Use parameterized tests to handle the different models and their specific requirements.
  3. Implement factory methods for creating test data and URLs to centralize these operations.

Here's a high-level example of how this could look:

import pytest
from django.urls import reverse

class BaseAPIPermissionTest(ProjectAPIPermissionTestBase):
    @pytest.fixture(params=[
        (SeqvarsQueryPresetsSetFactory, 'querypresetsset'),
        (SeqvarsQueryPresetsSetVersionFactory, 'querypresetssetversion'),
        # Add other model/viewset pairs here
    ])
    def api_obj(self, request):
        factory, viewset_name = request.param
        obj = factory(project=self.project)
        list_url = reverse(f"seqvars:api-{viewset_name}-list", kwargs={"project": self.project.sodar_uuid})
        detail_url = reverse(f"seqvars:api-{viewset_name}-detail", kwargs={"project": self.project.sodar_uuid, viewset_name: obj.sodar_uuid})
        return obj, list_url, detail_url, viewset_name

    def test_list(self, api_obj):
        obj, list_url, _, _ = api_obj
        # Common list test implementation

    def test_create(self, api_obj):
        obj, list_url, _, viewset_name = api_obj
        # Common create test implementation

    def test_retrieve(self, api_obj):
        obj, _, detail_url, _ = api_obj
        # Common retrieve test implementation

    def test_update(self, api_obj):
        obj, _, detail_url, _ = api_obj
        # Common update test implementation

    def test_delete(self, api_obj):
        obj, _, detail_url, _ = api_obj
        # Common delete test implementation

This approach would significantly reduce the amount of code in the file, make it easier to add tests for new models, and ensure consistency across all API permission tests. It also allows for easy addition of model-specific tests where needed.

Additionally, consider splitting this large test file into smaller, more focused files. You could have one file per model or group related models' tests together. This would improve navigation and maintenance of the test suite.


Line range hint 1-2347: Overall assessment of the test file

The test file demonstrates a comprehensive approach to testing CRUD operations and permissions for various API endpoints. The tests cover different user roles and ensure proper access control, which is crucial for maintaining security in the application.

However, there are several areas where the file could be improved:

  1. Code duplication: There's significant repetition across test classes, which could be reduced through refactoring.
  2. Maintainability: The current structure makes it challenging to update or add new tests consistently.
  3. Readability: The file's length and repetitive nature make it difficult to navigate and understand quickly.

To address these issues, consider the following recommendations:

  1. Implement a base test class with common CRUD and permission testing logic.
  2. Use parameterized tests to handle different models and their specific requirements.
  3. Split the file into smaller, more focused test files, possibly organized by model or feature.
  4. Enhance the setUp methods to reduce redundancy in individual test methods.
  5. Use more descriptive test method names to clearly indicate what's being tested.
  6. Optimize cleanup processes in create and delete tests for better performance.

These changes would significantly improve the maintainability, readability, and efficiency of your test suite, making it easier to extend and update in the future.

backend/variants/urls/presets.py (1)

3-3: Consider importing re_path for regex patterns

Although you have updated the import to use path, if you have any URL patterns that require complex regex matching (not shown in this snippet), you might need to import re_path from django.urls for compatibility with those patterns.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1268b16 and 56b6696.

⛔ Files ignored due to path filters (1)
  • backend/Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (77)
  • .github/workflows/main.yml (4 hunks)
  • backend/Makefile (1 hunks)
  • backend/Pipfile (4 hunks)
  • backend/beaconsite/tests/test_permissions.py (3 hunks)
  • backend/beaconsite/tests/test_permissions_ajax.py (2 hunks)
  • backend/beaconsite/tests/test_permissions_api.py (3 hunks)
  • backend/beaconsite/tests/test_views_ajax.py (1 hunks)
  • backend/beaconsite/urls.py (1 hunks)
  • backend/cases/tests/test_permissions.py (1 hunks)
  • backend/cases/tests/test_permissions_ajax.py (12 hunks)
  • backend/cases/tests/test_permissions_api.py (11 hunks)
  • backend/cases/tests/test_views.py (1 hunks)
  • backend/cases/tests/test_views_ajax.py (12 hunks)
  • backend/cases/urls.py (1 hunks)
  • backend/cases_analysis/tests/test_permissions_api.py (2 hunks)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_import/tests/test_permissions_api.py (1 hunks)
  • backend/cases_qc/tests/test_permissions_api.py (2 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/cohorts/migrations/0008_alter_cohort_user.py (1 hunks)
  • backend/cohorts/tests/test_permissions_ajax.py (3 hunks)
  • backend/cohorts/tests/test_permissions_api.py (3 hunks)
  • backend/cohorts/tests/test_views_ui.py (1 hunks)
  • backend/cohorts/urls.py (1 hunks)
  • backend/config/settings/base.py (3 hunks)
  • backend/config/urls.py (5 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/genepanels/tests/test_permissions.py (2 hunks)
  • backend/genepanels/urls.py (1 hunks)
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1 hunks)
  • backend/importer/urls.py (1 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/seqmeta/tests/test_permissions.py (2 hunks)
  • backend/seqmeta/urls.py (2 hunks)
  • backend/seqvars/tests/test_permissions_api.py (17 hunks)
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_presets.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_queries.py (6 hunks)
  • backend/svs/urls.py (2 hunks)
  • backend/varannos/tests/helpers.py (3 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_permissions.py (1 hunks)
  • backend/varannos/tests/test_permissions_api.py (1 hunks)
  • backend/varannos/urls.py (2 hunks)
  • backend/varfish/templates/users/login.html (1 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/varfish/users/urls.py (1 hunks)
  • backend/varfish/vueapp/urls.py (1 hunks)
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/models/maintenance.py (1 hunks)
  • backend/variants/tests/helpers.py (3 hunks)
  • backend/variants/tests/test_file_export.py (2 hunks)
  • backend/variants/tests/test_permissions_ajax.py (6 hunks)
  • backend/variants/tests/test_permissions_ajax_annos.py (1 hunks)
  • backend/variants/tests/test_permissions_ajax_presets.py (29 hunks)
  • backend/variants/tests/test_permissions_api.py (7 hunks)
  • backend/variants/tests/test_ui.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
  • backend/variants/urls/init.py (2 hunks)
  • backend/variants/urls/annos.py (1 hunks)
  • backend/variants/urls/presets.py (2 hunks)
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (1 hunks)
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4 hunks)
  • frontend/src/varfish/components/FilterForm/DevPane.vue (2 hunks)
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/EffectPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FlagsPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3 hunks)
  • frontend/src/variants/components/FilterForm/QualityPane.vue (1 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetProperties.vue (1 hunks)
  • utils/docker/Dockerfile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (63)
  • .github/workflows/main.yml
  • backend/Makefile
  • backend/Pipfile
  • backend/beaconsite/tests/test_permissions.py
  • backend/beaconsite/tests/test_permissions_ajax.py
  • backend/beaconsite/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_views_ajax.py
  • backend/beaconsite/urls.py
  • backend/cases/tests/test_permissions.py
  • backend/cases/tests/test_permissions_ajax.py
  • backend/cases/tests/test_permissions_api.py
  • backend/cases/tests/test_views.py
  • backend/cases/tests/test_views_ajax.py
  • backend/cases_analysis/tests/test_permissions_api.py
  • backend/cases_import/models/executors.py
  • backend/cases_import/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_views_api.py
  • backend/cohorts/migrations/0008_alter_cohort_user.py
  • backend/cohorts/tests/test_permissions_ajax.py
  • backend/cohorts/tests/test_permissions_api.py
  • backend/cohorts/tests/test_views_ui.py
  • backend/cohorts/urls.py
  • backend/genepanels/forms.py
  • backend/genepanels/tests/test_models.py
  • backend/genepanels/tests/test_permissions.py
  • backend/genepanels/urls.py
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py
  • backend/seqmeta/tests/test_models.py
  • backend/seqmeta/tests/test_permissions.py
  • backend/seqmeta/urls.py
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py
  • backend/svs/tests/test_permissions_ajax_presets.py
  • backend/svs/tests/test_permissions_ajax_queries.py
  • backend/varannos/tests/helpers.py
  • backend/varannos/tests/test_models.py
  • backend/varannos/tests/test_permissions.py
  • backend/varannos/tests/test_permissions_api.py
  • backend/varannos/urls.py
  • backend/varfish/templates/users/login.html
  • backend/varfish/users/urls.py
  • backend/varfish/vueapp/urls.py
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py
  • backend/variants/migrations/0110_drop_variant_summary.py
  • backend/variants/migrations/0111_create_variant_summary.py
  • backend/variants/tests/helpers.py
  • backend/variants/tests/test_file_export.py
  • backend/variants/tests/test_permissions_ajax.py
  • backend/variants/tests/test_permissions_ajax_annos.py
  • backend/variants/tests/test_permissions_api.py
  • backend/variants/urls/annos.py
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue
  • frontend/src/varfish/components/FilterForm/DevPane.vue
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue
  • frontend/src/variants/components/FilterForm/EffectPane.vue
  • frontend/src/variants/components/FilterForm/FlagsPane.vue
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue
  • frontend/src/variants/components/FilterForm/QualityPane.vue
  • frontend/src/variants/components/QueryPresets/SetEditor.vue
  • frontend/src/variants/components/QueryPresets/SetProperties.vue
  • utils/docker/Dockerfile
🧰 Additional context used
🪛 Ruff
backend/variants/models/maintenance.py

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

🔇 Additional comments (60)
backend/importer/urls.py (7)

4-4: LGTM: Correct import for Django's modern URL routing

The change from url to path import is correct and aligns with Django's modern URL routing practices.


11-15: LGTM: Correct implementation of path() for "import-info" URL

The URL pattern has been correctly updated to use path() instead of url(). The simplified URL string maintains the same functionality while improving readability.


12-16: LGTM: Improved type safety with path converters

The URL pattern has been correctly updated to use path() with UUID path converters. This change not only simplifies the URL pattern but also improves type safety by ensuring that only valid UUIDs are matched.


20-24: LGTM: Correct implementation of path() for API URL

The API URL pattern has been correctly updated to use path() with a UUID path converter. This change maintains functionality while improving readability and type safety.


25-29: LGTM: Correct update to path() for complex API URL

The complex API URL pattern with multiple parameters has been correctly updated to use path() with UUID path converters. This change simplifies the URL pattern while maintaining functionality and improving type safety.


30-89: LGTM: Comprehensive update of all API URL patterns

All remaining API URL patterns have been successfully updated to use path() with appropriate UUID path converters. These changes:

  1. Improve code readability by replacing complex regex patterns with simple path converters.
  2. Enhance type safety by ensuring only valid UUIDs are matched in the URLs.
  3. Maintain existing functionality by preserving the same views and names for each pattern.
  4. Align the codebase with Django's modern URL routing practices.

This comprehensive update ensures consistency across all URL patterns in the file.


1-89: Excellent update to modern Django URL routing

This update successfully modernizes the URL routing for the importer app by:

  1. Replacing all url() functions with path().
  2. Utilizing type-safe UUID path converters instead of regex patterns.
  3. Maintaining existing functionality while improving code readability.
  4. Aligning the codebase with Django's current best practices.

These changes will likely result in more maintainable code and reduce the potential for URL-related bugs. Great job on this comprehensive update!

backend/variants/models/maintenance.py (2)

122-134: SQL_OUTER implementation looks good

The SQL_OUTER command is well-structured and follows best practices:

  • It safely drops the existing view if it exists.
  • It creates the materialized view with a placeholder for the inner query.
  • It sets up appropriate indexes for optimizing query performance.

114-188: Overall assessment: Well-implemented with minor improvement suggestions

The new functions drop_variants_smallvariantsummary() and create_variants_smallvariantsummary(), along with the SQL commands SQL_OUTER and SQL_INNER, are well-implemented and serve their purposes effectively. They provide robust functionality for managing the SmallVariantSummary materialized view.

Key points:

  1. The use of transactions ensures atomicity of operations.
  2. SQL commands are well-structured and include performance optimizations.
  3. The code effectively handles the exclusion of certain cases based on project settings.

Suggested improvements:

  1. Combine nested with statements for better readability.
  2. Consider using parameterized queries for enhanced security practices.
  3. Minor optimization in the SQL_INNER query by moving the DISTINCT clause.

These changes will further enhance the code's readability, performance, and security without altering its core functionality.

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

backend/config/urls.py (7)

29-29: LGTM: Updated URL pattern for home view

The change from url() to path() for the home view is correct and follows modern Django practices. The use of ProjectRolesHomeView is consistent with the previous implementation.


36-70: LGTM: Updated URL patterns for VarFish apps

All URL patterns have been correctly updated from url() to path(). The changes are consistent across all app includes and views, following modern Django practices. No logical changes to the routing have been made, ensuring that the existing functionality is preserved.


Line range hint 94-145: LGTM: Updated proxy URL patterns

The proxy URL patterns have been correctly updated from url() to re_path(). This change is appropriate as these patterns use regular expressions for routing. The update is consistent across all proxy URL patterns, maintaining the existing functionality while adhering to modern Django practices.


182-193: LGTM: Updated error handling routes for development

The error handling routes for development have been correctly updated to use path(). This change is appropriate as these patterns don't use regular expressions. The update is consistent across all error handling routes (400, 403, 404, and 500), maintaining the existing functionality while adhering to modern Django practices.


198-198: LGTM: Updated debug toolbar URL pattern

The debug toolbar URL pattern has been correctly updated to use path(). This change is appropriate as the pattern doesn't use regular expressions. The update is consistent with the other changes in the file, adhering to modern Django practices.


Line range hint 1-198: Overall assessment: Good progress on modernizing URL routing

The changes in this file represent a significant improvement in adopting modern Django URL routing practices. The transition from url() to path() and re_path() is largely correct and consistent throughout the file. However, two minor issues were identified:

  1. The include import should be updated to use django.urls instead of django.conf.urls.
  2. One instance of path() should be changed to re_path() for a pattern containing a regex.

After addressing these minor issues, the URL routing configuration will be fully modernized and consistent with best practices.


168-171: ⚠️ Potential issue

Use re_path() instead of path() for regex patterns

The pattern "-.*" includes regex wildcard characters. Since path() doesn't accept regex patterns and interprets the route parameter as a fixed string or with path converters, you should use re_path() for regex patterns.

Apply this diff to fix the issue:

-path(
+re_path(

Likely invalid or redundant comment.

backend/varfish/users/management/commands/initdev.py (1)

285-285: LGTM! Improved naming consistency.

The renaming of app_name to plugin_name in the app_settings.set() call improves code consistency and readability without affecting functionality.

backend/cases_import/tests/test_models_executor.py (2)

Line range hint 1-1: Overall test coverage looks comprehensive.

This test file provides extensive coverage for various import scenarios, including different types of QC data (Dragen, Samtools, cramino, ngs-bits). The tests are well-structured, use appropriate mocking for external dependencies, and cover create, update, and delete actions. This comprehensive approach helps ensure the robustness of the import process.


54-54: LGTM! Verify consistent usage across the codebase.

The change from app_name to plugin_name in the app_settings.set() call looks good. This likely reflects a terminology change in the AppSettingAPI.

To ensure consistency, let's check for any remaining uses of app_name in similar contexts:

backend/variants/tests/test_views_ajax_presets.py (7)

146-153: LGTM! Consistent improvement in test implementation.

The changes in this test class are consistent with the previous modifications, removing mocking in favor of direct assertions. This improves the test's simplicity and robustness.


244-251: LGTM! Consistent application of improved testing approach.

The changes in this test class continue the pattern of removing mocking in favor of direct assertions. This consistent application of the new testing approach across different preset types is commendable.


268-275: LGTM! Maintaining consistency across different preset types.

The changes in this test class for ImpactPresets continue the pattern of removing mocking and using direct assertions. The consistency in applying this improved testing approach across different preset types is excellent.


366-373: LGTM! Consistent improvement for QualityPresets tests.

The changes in this test class for QualityPresets maintain the pattern of removing mocking and using direct assertions. This consistent application of the improved testing approach across different preset types enhances the overall quality of the test suite.


390-397: LGTM! Consistent refactoring for QualityPresets clone tests.

The changes in this test class for cloning QualityPresets maintain the pattern of removing mocking and using direct assertions. This consistent refactoring approach across different preset types and operations (factory and other cloning) is commendable.


488-495: LGTM! Comprehensive and consistent refactoring across all preset types.

The changes in the test classes for ChromosomePresets, FlagsEtcPresets, QuickPresets, and PresetSet all follow the same pattern of removing mocking and using direct assertions. This consistent application of the improved testing approach across all preset types and operations (list, create, retrieve, update, delete, clone) is excellent. It demonstrates a thorough and well-executed refactoring effort that will likely improve the maintainability and reliability of the test suite.

Also applies to: 512-519, 610-617, 634-641, 732-739, 842-848, 861-869


3-3: LGTM! Verify impact on other test files.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase looks good. This update likely provides more appropriate functionality for testing API permissions.

To ensure consistency across the project, please run the following script to check if this base class change has been applied in other test files:

Also applies to: 26-26

✅ Verification successful

All test files correctly use ProjectAPIPermissionTestBase.

No instances of TestProjectAPIPermissionBase found in other test files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of TestProjectAPIPermissionBase in other test files

# Search for files still using TestProjectAPIPermissionBase
rg --type python "class.*\(TestProjectAPIPermissionBase\)" tests/

Length of output: 98


Script:

#!/bin/bash
# Description: Check for usage of TestProjectAPIPermissionBase in other test files

# Search for files still using TestProjectAPIPermissionBase without specifying type
rg "class.*\(TestProjectAPIPermissionBase\)" tests/

Length of output: 100


Script:

#!/bin/bash
# Description: Check for usage of TestProjectAPIPermissionBase in backend/variants tests

# Search for classes inheriting from TestProjectAPIPermissionBase in the specified tests directory
rg "class\s+\w*\(TestProjectAPIPermissionBase\)" backend/variants/tests/

Length of output: 74

backend/config/settings/base.py (1)

438-438: LGTM: ADMIN_URL simplification

The change from a regex pattern to a simple string for ADMIN_URL is appropriate and doesn't introduce any security concerns.

backend/variants/tests/test_permissions_ajax_presets.py (25)

Line range hint 1-13: LGTM: Import changes look good.

The import of ProjectAPIPermissionTestBase from projectroles.tests.test_permissions_api is appropriate for the refactoring of test classes. Other imports remain unchanged and are necessary for the tests.


Line range hint 17-62: LGTM: Class refactoring looks good.

The TestFrequencyPresetsListCreateAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.


Line range hint 64-138: LGTM: Class refactoring looks good.

The TestFrequencyPresetsRetrieveUpdateDestroyAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.


Line range hint 140-165: LGTM: Class refactoring looks good.

The TestFrequencyPresetsCloneFactoryDefaultsView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.


Line range hint 167-193: LGTM: Class refactoring looks good.

The TestFrequencyPresetsCloneOtherView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.


Line range hint 195-240: LGTM: Class refactoring looks good.

The TestImpactPresetsListCreateAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.


Line range hint 242-316: LGTM: Class refactoring looks good.

The TestImpactPresetsRetrieveUpdateDestroyAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.


Line range hint 318-343: LGTM: Class refactoring looks good.

The TestImpactPresetsCloneFactoryDefaultsView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.


Line range hint 345-371: LGTM: Class refactoring looks good.

The TestImpactPresetsCloneOtherView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.


Line range hint 373-418: LGTM: Class refactoring looks good with a minor change.

The TestQualityPresetsListCreateAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.

Note: There's a minor change in the good_users list, now using self.owner_as.user instead of self.user_owner. This is likely due to a change in the base class's attribute naming and should be consistent across all test classes.


Line range hint 420-494: LGTM: Class refactoring looks good.

The TestQualityPresetsRetrieveUpdateDestroyAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous class and aligns with the new base class structure.


Line range hint 496-519: LGTM: Class refactoring looks good.

The TestQualityPresetsCloneFactoryDefaultsView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 521-547: LGTM: Class refactoring looks good.

The TestQualityPresetsCloneOtherView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 549-594: LGTM: Class refactoring looks good.

The TestChromosomePresetsListCreateAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 596-670: LGTM: Class refactoring looks good.

The TestChromosomePresetsRetrieveUpdateDestroyAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 672-697: LGTM: Class refactoring looks good.

The TestChromosomePresetsCloneFactoryDefaultsView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 699-725: LGTM: Class refactoring looks good.

The TestChromosomePresetsCloneOtherView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 727-772: LGTM: Class refactoring looks good.

The TestFlagsEtcPresetsListCreateAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 774-848: LGTM: Class refactoring looks good.

The TestFlagsEtcPresetsRetrieveUpdateDestroyAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 850-875: LGTM: Class refactoring looks good.

The TestFlagsEtcPresetsCloneFactoryDefaultsView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 877-903: LGTM: Class refactoring looks good.

The TestFlagsEtcPresetsCloneOtherView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 905-959: LGTM: Class refactoring looks good.

The TestQuickPresetsListCreateAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 961-1035: LGTM: Class refactoring looks good.

The TestQuickPresetsRetrieveUpdateDestroyAjaxView class has been successfully updated to inherit from ProjectAPIPermissionTestBase. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class. The change from self.user_owner to self.owner_as.user is consistent with the previous classes and aligns with the new base class structure.


Line range hint 1037-1271: LGTM: Consistent refactoring across all remaining classes.

The following classes have been successfully updated to inherit from ProjectAPIPermissionTestBase:

  • TestQuickPresetsCloneOtherView
  • TestPresetSetListCreateAjaxView
  • TestPresetSetListAllAjaxView
  • TestPresetSetRetrieveUpdateDestroyAjaxView
  • TestPresetSetCloneFactoryDefaultsView
  • TestPresetSetCloneOtherView

For all these classes:

  1. The test methods remain unchanged, preserving the existing test behavior while benefiting from the new base class.
  2. The change from self.user_owner to self.owner_as.user is consistent and aligns with the new base class structure.

This refactoring maintains the integrity of the tests while updating them to use the new base class.


Line range hint 1-1271: Summary: Successful and consistent refactoring of test classes.

This pull request successfully refactors all test classes in the test_permissions_ajax_presets.py file to use ProjectAPIPermissionTestBase as the base class. Key points:

  1. All classes now inherit from ProjectAPIPermissionTestBase instead of TestProjectAPIPermissionBase.
  2. The change from self.user_owner to self.owner_as.user is applied consistently across all classes, likely reflecting a change in the new base class's structure.
  3. Test methods and their logic remain unchanged, which preserves existing test coverage and functionality.

This refactoring enhances code consistency and potentially leverages improvements in the new base class while maintaining the integrity of the existing tests. The changes appear to be well-executed and consistent throughout the file.

backend/svs/urls.py (4)

2-2: Imports updated appropriately

The import of path and re_path from django.urls is correct and necessary due to the replacement of the deprecated url() function.


11-24: URL patterns correctly transitioned to path()

The URL patterns have been successfully updated from using url() to path(). The use of <uuid:project> and <uuid:job> path converters accurately captures UUID parameters.


29-35: Consistent use of path() with appropriate parameters

The ajax URL patterns have been updated properly, and the parameters are correctly specified. Ensure that any clients interacting with these endpoints are aware of any changes in URL structures.


133-140: Use of re_path() for regex-based patterns is appropriate

The transition to re_path() for patterns requiring regular expressions maintains the necessary functionality. The patterns are correctly specified, and the proxy settings are properly configured.

backend/cases/urls.py (1)

1-152: LGTM: URL patterns updated to use path()

The migration from url() to path() is correctly implemented across all URL patterns. Utilizing <uuid:...> converters enhances URL parameter handling and aligns with Django's recommended practices.

backend/variants/urls/presets.py (2)

23-23: Potential issue with <slug:name> allowing digits

As noted previously, using <slug:name> in the URL pattern allows digits ([a-zA-Z0-9_-]+), potentially widening the accepted name values unintentionally. If the original pattern intended to exclude digits, this change might introduce unexpected behavior.


12-163: Verify consistency of parameter converters across URL patterns

Ensure that all URL patterns use appropriate parameter converters matching the expected data types. For instance, confirm that identifiers intended to be UUIDs use <uuid:...> and those meant to be slugs use <slug:...>.

You can run the following script to identify any inconsistencies in parameter converters:

backend/variants/urls/__init__.py (1)

Line range hint 1-450: URL patterns updated appropriately with path() and path converters

The migration from the deprecated url() function with regex patterns to path() with path converters enhances the readability and maintainability of the URL configurations. The use of <uuid:...> and <str:...> path converters correctly handles UUIDs and string parameters, ensuring proper URL parameter validation.

@@ -161,7 +161,7 @@ def _make_user(cls, user_name, superuser):
return user


class TestUIBase(projectroles.tests.test_ui.TestUIBase):
class UITestBase(projectroles.tests.test_ui.UITestBase):
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Base class projectroles.tests.test_ui.UITestBase not found.

The UITestBase class in backend/variants/tests/test_ui.py inherits from projectroles.tests.test_ui.UITestBase, but the base class definition could not be located in the repository. Please verify that the base class exists and that the import path is correct.

🔗 Analysis chain

Approve class renaming and verify base class.

The renaming of TestUIBase to UITestBase is consistent and improves clarity. However, ensure that the base class projectroles.tests.test_ui.UITestBase has also been updated in the projectroles package.

Run the following script to verify the base class name:


Please run the following script to verify the base class name:


Please run the following script to locate the UITestBase class definition:


Please run the following script to verify if the base class TestUIBase has been renamed in the projectroles package:


Please run the following script to locate the TestUIBase class definition:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the base class name in the projectroles package

# Test: Search for the UITestBase class definition in the projectroles package
rg --type python -g 'projectroles/**/*.py' 'class UITestBase'

Length of output: 94


Script:

#!/bin/bash
# Description: Verify the base class name in the projectroles package

# Test: Search for the UITestBase class definition in the projectroles package
rg -g '*.py' 'class UITestBase' projectroles/

Length of output: 101


Script:

#!/bin/bash
# Description: Locate the UITestBase class definition in the repository

# Test: Search for the UITestBase class definition across all Python files
rg -g '*.py' 'class UITestBase' .

Length of output: 128


Script:

#!/bin/bash
# Description: Verify if the base class TestUIBase has been renamed to UITestBase in the projectroles package

# Test: Search for the TestUIBase class definition in the projectroles package
rg -g '*.py' 'class TestUIBase' projectroles/

Length of output: 101


Script:

#!/bin/bash
# Description: Locate the TestUIBase class definition in the repository

# Test: Search for the TestUIBase class definition across all Python files
rg -g '*.py' 'class TestUIBase' .

Length of output: 35

Comment on lines +864 to +906
ENABLE_SAML = env.bool("ENABLE_SAML", False)
SAML2_AUTH = {
# Required setting
#
# Pysaml2 Saml client settings, cf.
# https://pysaml2.readthedocs.io/en/latest/howto/config.html
"SAML_CLIENT_SETTINGS": {
# The optional entity ID string to be passed in the 'Issuer'
# element of authn request, if required by the IDP.
"entityid": env.str("SAML_CLIENT_ENTITY_ID", "SODARcore"),
"entitybaseurl": env.str("SAML_CLIENT_ENTITY_URL", "https://localhost:8000"),
"metadata": {
"local": [
env.str(
"SAML_CLIENT_METADATA_FILE", "metadata.xml"
), # The auto(dynamic) metadata configuration URL of SAML2
],
},
"service": {
"sp": {
"idp": env.str(
"SAML_CLIENT_IDP",
"https://sso.hpc.bihealth.org/auth/realms/cubi",
),
# Keycloak expects client signature
"authn_requests_signed": "true",
# Enforce POST binding which is required by keycloak
"binding": "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
},
},
"key_file": env.str("SAML_CLIENT_KEY_FILE", "key.pem"),
"cert_file": env.str("SAML_CLIENT_CERT_FILE", "cert.pem"),
"xmlsec_binary": env.str("SAML_CLIENT_XMLSEC1", "/usr/bin/xmlsec1"),
"encryption_keypairs": [
{
"key_file": env.str("SAML_CLIENT_KEY_FILE", "key.pem"),
"cert_file": env.str("SAML_CLIENT_CERT_FILE", "cert.pem"),
}
],
},
# Custom target redirect URL after the user get logged in. Default to
# /admin if not set. This setting will be overwritten if you have parameter
# ?next= specificed in the login URL.
"DEFAULT_NEXT_URL": "/",
# Optional settings
"NEW_USER_PROFILE": {
"USER_GROUPS": env.list("SAML_NEW_USER_GROUPS", default=[]),
"ACTIVE_STATUS": env.bool("SAML_NEW_USER_ACTIVE_STATUS", True),
"STAFF_STATUS": env.bool("SAML_NEW_USER_STAFF_STATUS", True),
"SUPERUSER_STATUS": env.bool("SAML_NEW_USER_SUPERUSER_STATUS", False),
},
"ATTRIBUTES_MAP": env.dict(
"SAML_ATTRIBUTES_MAP",
default={
"email": "urn:oid:1.2.840.113549.1.9.1",
"username": "username",
"first_name": "urn:oid:2.5.4.42",
"last_name": "urn:oid:2.5.4.4",
},
),
# Optional SAML Trigger
# Very unlikely to be needed in configuration, since it requires
# changes to the codebase
# 'TRIGGER': {
# 'FIND_USER': 'path.to.your.find.user.hook.method',
# 'NEW_USER': 'path.to.your.new.user.hook.method',
# 'CREATE_USER': 'path.to.your.create.user.hook.method',
# 'BEFORE_LOGIN': 'path.to.your.login.hook.method',
# },
}

# 'ASSERTION_URL': 'https://your.url.here', # Custom URL to validate incoming SAML requests against
assertion_url = env.str("SAML_ASSERTION_URL", None)
if assertion_url is not None:
SAML2_AUTH = {**SAML2_AUTH, **{"ASSERTION_URL": assertion_url}}
if ENABLE_OIDC:
AUTHENTICATION_BACKENDS = tuple(
itertools.chain(
("social_core.backends.open_id_connect.OpenIdConnectAuth",),
AUTHENTICATION_BACKENDS,
)
)
TEMPLATES[0]["OPTIONS"]["context_processors"] += [
"social_django.context_processors.backends",
"social_django.context_processors.login_redirect",
]
SOCIAL_AUTH_JSONFIELD_ENABLED = True
SOCIAL_AUTH_JSONFIELD_CUSTOM = "django.db.models.JSONField"
SOCIAL_AUTH_USER_MODEL = AUTH_USER_MODEL
SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS = [
"username",
"name",
"first_name",
"last_name",
"email",
]
SOCIAL_AUTH_OIDC_OIDC_ENDPOINT = env.str("SOCIAL_AUTH_OIDC_OIDC_ENDPOINT", None)
SOCIAL_AUTH_OIDC_KEY = env.str("SOCIAL_AUTH_OIDC_KEY", "CHANGEME")
SOCIAL_AUTH_OIDC_SECRET = env.str("SOCIAL_AUTH_OIDC_SECRET", "CHANGEME")
SOCIAL_AUTH_OIDC_USERNAME_KEY = env.str("SOCIAL_AUTH_OIDC_USERNAME_KEY", "username")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

OIDC implementation looks good, but consider improving secret handling

The OIDC implementation is well-structured and follows best practices:

  • Using environment variables for configuration
  • Properly updating AUTHENTICATION_BACKENDS
  • Adding necessary context processors

However, there's a potential security issue:

  • SOCIAL_AUTH_OIDC_KEY and SOCIAL_AUTH_OIDC_SECRET have hardcoded default values ("CHANGEME").

Consider removing the default values for SOCIAL_AUTH_OIDC_KEY and SOCIAL_AUTH_OIDC_SECRET. Instead, raise an error if these are not provided when ENABLE_OIDC is True. This ensures that production environments don't accidentally use insecure default values.

Example implementation:

if ENABLE_OIDC:
    SOCIAL_AUTH_OIDC_KEY = env.str("SOCIAL_AUTH_OIDC_KEY")
    SOCIAL_AUTH_OIDC_SECRET = env.str("SOCIAL_AUTH_OIDC_SECRET")
    if not SOCIAL_AUTH_OIDC_KEY or not SOCIAL_AUTH_OIDC_SECRET:
        raise ValueError("SOCIAL_AUTH_OIDC_KEY and SOCIAL_AUTH_OIDC_SECRET must be set when ENABLE_OIDC is True")

This change will prevent accidental use of insecure default values in production environments.

url(
regex=r"^ajax/project-default-presetset/retrieve/(?P<project>[a-zA-Z0-9\._-]+)/?$",
path(
"ajax/project-default-presetset/retrieve/<uuid:project>/",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Change in project parameter from slug to UUID

The URL pattern at line 163 changes the project parameter from accepting slugs ([a-zA-Z0-9\._-]+) to strictly accepting UUIDs with <uuid:project>. This could lead to issues if project was previously used with non-UUID identifiers.

Consider the following options to address this:

  • Option 1: Use <slug:project> if project is not always a UUID

    -    "ajax/project-default-presetset/retrieve/<uuid:project>/",
    +    "ajax/project-default-presetset/retrieve/<slug:project>/",
  • Option 2: Ensure all project identifiers are UUIDs

    Verify that all references to project use UUIDs throughout the codebase.

Committable suggestion was skipped due to low confidence.

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch from 56b6696 to 9e3b6cf Compare October 16, 2024 14:21
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 90.69767% with 28 lines in your changes missing coverage. Please review.

Project coverage is 91%. Comparing base (67f67c7) to head (2fdd358).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
backend/config/settings/base.py 20% 16 Missing ⚠️
backend/variants/models/maintenance.py 40% 6 Missing ⚠️
...d/variants/migrations/0110_drop_variant_summary.py 82% 4 Missing ⚠️
backend/config/urls.py 75% 1 Missing ⚠️
...variants/migrations/0111_create_variant_summary.py 90% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #2010    +/-   ##
======================================
  Coverage     91%     91%            
======================================
  Files        674     681     +7     
  Lines      38408   38794   +386     
======================================
+ Hits       35067   35533   +466     
+ Misses      3341    3261    -80     
Files with missing lines Coverage Δ
backend/beaconsite/tests/test_permissions.py 100% <100%> (ø)
backend/beaconsite/tests/test_permissions_ajax.py 100% <100%> (ø)
backend/beaconsite/tests/test_permissions_api.py 100% <100%> (ø)
backend/beaconsite/tests/test_views_ajax.py 50% <100%> (ø)
backend/beaconsite/urls.py 100% <100%> (ø)
backend/cases/tests/test_permissions.py 100% <100%> (ø)
backend/cases/tests/test_permissions_ajax.py 100% <100%> (ø)
backend/cases/tests/test_permissions_api.py 100% <100%> (ø)
backend/cases/tests/test_views.py 100% <100%> (ø)
backend/cases/tests/test_views_ajax.py 100% <100%> (ø)
... and 45 more

... and 7 files with indirect coverage changes

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch 2 times, most recently from 24dc661 to 78c038c Compare October 16, 2024 15:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (12)
backend/variants/urls/__init__.py (1)

Line range hint 1-463: Overall LGTM with a suggestion for improvement

The refactoring of URL patterns from url() to path() has been done correctly and consistently throughout the file. All UUID fields are using the appropriate path converters, and the structure of the URL patterns has been maintained.

As a minor suggestion for improvement, consider grouping related URL patterns into separate files or using Django's include() function to organize the patterns better. This could help improve the readability and maintainability of the URL configuration, especially given the large number of patterns in this file.

backend/cases_import/tests/test_models_executor.py (1)

Line range hint 1-1000: Comprehensive test coverage with room for minor improvements

The test suite demonstrates excellent coverage of various import scenarios, including create, update, and delete actions, as well as different types of QC data imports. The use of mock patches is appropriate for isolating tests from external dependencies.

To further improve the code:

  1. Consider using a decorator or helper function to reduce the repetitive mock patching in test methods, especially in classes like ImportCreateWithDragenQcTest.

  2. Some test method names are quite long. While descriptive, they could potentially be shortened without losing clarity.

These are minor suggestions, and overall, the test structure and coverage are commendable.

Here's an example of how you could reduce repetition in mock patches:

def mock_dragen_loaders(test_method):
    mocks = [
        'cases_qc.io.dragen.load_cnv_metrics',
        'cases_qc.io.dragen.load_fragment_length_hist',
        # ... add all other mock targets
    ]
    def wrapper(self):
        with mock.patch.multiple(mock.patch.DEFAULT, **{m: mock.DEFAULT for m in mocks}):
            return test_method(self)
    return wrapper

class ImportCreateWithDragenQcTest(ExecutorTestMixin, TestCaseSnapshot, TestCase):
    # ...

    @mock_dragen_loaders
    def test_run(self):
        # Your test code here
        # You can access mocks via self.mock_<function_name>

This approach can significantly reduce boilerplate code in your test methods.

backend/variants/tests/test_views_ajax_presets.py (3)

842-851: LGTM: Improved test coverage for PresetSet cloning.

The simplification of the test method and the addition of an assertion for the number of PresetSet objects improve the test's comprehensiveness.

Consider adding an assertion to verify the label of the newly created PresetSet:

 self.assertEqual(response.status_code, 201)
 self.assertEqual(response.json()["project"], str(self.project.sodar_uuid))
 self.assertEqual(PresetSet.objects.count(), 1)
+self.assertEqual(PresetSet.objects.first().label, "my label")

861-872: LGTM: Improved test coverage for PresetSet cloning from another set.

The additions of assertions before and after the clone operation provide a more comprehensive test of the cloning functionality.

For consistency with the previous test, consider adding an assertion to verify the label of the newly created PresetSet:

 self.assertEqual(response.status_code, 201)
 self.assertEqual(response.json()["project"], str(self.project.sodar_uuid))
 self.assertEqual(PresetSet.objects.count(), 2)
+self.assertEqual(PresetSet.objects.latest('id').label, "my label")

Line range hint 1-872: Overall: Excellent improvements to test robustness and maintainability.

The changes throughout this file represent a significant step towards more reliable and maintainable tests. Key improvements include:

  1. Standardization of the base test class.
  2. Removal of mocks in favor of direct assertions on response data.
  3. Additional assertions to verify the state before and after operations.
  4. Simplified test methods that are easier to read and maintain.

These changes will likely result in more stable tests that better represent real-world usage of the API endpoints.

Consider documenting these testing patterns and best practices in a central location (e.g., a TESTING.md file in the project root) to ensure consistency across all test files in the project.

backend/variants/tests/test_permissions_ajax_presets.py (1)

Line range hint 345-365: Inconsistent user role representation in good_users list.

In the test_post method, the good_users list uses self.owner_as.user instead of self.user_owner, which is inconsistent with other test classes in this file. This might be an unintended change or a deliberate modification in user role representation.

Consider updating the good_users list to maintain consistency:

 good_users = [
     self.superuser,
-    self.owner_as.user,
+    self.user_owner,
     self.user_delegate,
     self.user_contributor,
 ]
backend/seqvars/tests/test_permissions_api.py (5)

Line range hint 62-204: Consider refactoring to reduce code duplication

The TestQueryPresetsSetViewSet class, along with other similar test classes in this file, follows a consistent pattern for testing CRUD operations and permissions. To improve maintainability and reduce code duplication, consider creating a base test class that implements common test methods and utility functions. Each specific test class could then inherit from this base class and only implement unique test cases or override methods as needed.

Example refactoring:

class BaseAPIPermissionTest(ProjectAPIPermissionTestBase):
    factory_class = None
    url_name = None

    def setUp(self):
        super().setUp()
        self.object = self.factory_class(project=self.project)

    def test_list(self):
        url = reverse(f"seqvars:api-{self.url_name}-list", kwargs={"project": self.project.sodar_uuid})
        self.assert_response(url, self.good_users, 200, method="GET")
        self.assert_response(url, self.bad_users_401, 401, method="GET")
        self.assert_response(url, self.bad_users_403, 403, method="GET")

    # Implement other common test methods (create, retrieve, update, delete)

class TestQueryPresetsSetViewSet(BaseAPIPermissionTest):
    factory_class = SeqvarsQueryPresetsSetFactory
    url_name = "querypresetsset"

    # Implement only unique test methods or override if necessary

This refactoring would significantly reduce code duplication across your test classes and make it easier to maintain and extend your test suite.


Line range hint 1728-1925: Consider adding data validation tests

The TestQuerySettingsViewSet class follows the established pattern for CRUD operations and permission checks. However, the create test method involves complex nested data structures. To ensure robustness, consider adding specific tests for data validation, especially for the nested serializers.

Example:

def test_create_invalid_data(self):
    url = reverse(
        "seqvars:api-querysettings-list",
        kwargs={"session": self.session.sodar_uuid},
    )
    invalid_data = {
        "genotype": {},  # Empty data
        "quality": {"invalid_field": "value"},  # Invalid field
        # ... other invalid data scenarios
    }
    response = self.client.post(url, data=invalid_data, format="json")
    self.assertEqual(response.status_code, 400)
    self.assertIn("genotype", response.data)
    self.assertIn("quality", response.data)
    # ... assert other validation errors

This will help ensure that the API correctly handles and reports validation errors for complex nested data structures.


Line range hint 1926-2194: Address TODO comment in test_create_from method

The TestQueryViewSet class includes a test_create_from method with a TODO comment referencing an open issue (#1920). Once the referenced issue is resolved, make sure to update this test method accordingly. This might involve changing the way the presetsset_factory is created or modifying the test data and assertions.

Consider adding a comment with a brief description of what needs to be changed once the issue is resolved, to make it easier for future developers to update the test.

Example:

def test_create_from(self):
    # TODO: Update this test after resolving https://github.com/varfish-org/varfish-server/issues/1920
    # Changes needed:
    # - Update presetsset_factory creation method
    # - Modify test data to reflect new structure
    # - Update assertions to check for new expected behavior
    ...

This will help ensure that the test is not overlooked when the related issue is resolved and the implementation changes.


Line range hint 2195-2248: Document reason for only testing read operations

The TestQueryExecutionViewSet class only includes tests for list and retrieve operations, omitting tests for create, update, and delete operations. If this is intentional (e.g., if the API doesn't support these operations for QueryExecution), consider adding a comment to explain why only read operations are tested.

Example:

class TestQueryExecutionViewSet(ProjectAPIPermissionTestBase):
    """
    Test case for QueryExecutionViewSet.
    
    Note: This view only supports read operations (list and retrieve),
    so we don't test create, update, or delete operations.
    """
    
    def setUp(self):
        ...

This documentation will help other developers understand the intended behavior of the API and why certain tests are not included.


Line range hint 1-2352: Summary of review findings

The test_permissions_api.py file contains a comprehensive set of test classes for various API endpoints related to sequence variants. The test suite is well-structured and covers CRUD operations and permission checks for different user roles. Here are the main suggestions for improvement:

  1. Refactor the test classes to reduce code duplication by creating a base test class with common methods.
  2. Add data validation tests for complex nested data structures, particularly in the TestQuerySettingsViewSet class.
  3. Address the TODO comment in the TestQueryViewSet.test_create_from method once the related issue is resolved.
  4. Document the reason for only testing read operations in classes like TestQueryExecutionViewSet, TestResultSetViewSet, and TestResultRowViewSet.

Implementing these suggestions will improve the maintainability and clarity of the test suite while ensuring comprehensive coverage of the API functionality.

backend/svs/urls.py (1)

Line range hint 140-144: Simplify re_path() Pattern by Removing Redundant Anchors

In re_path(), the pattern is implicitly anchored at the start and end of the string, so the ^ and $ in the regex are unnecessary. You can simplify the pattern as follows:

-re_path(
-    r"^tracks/(?P<url>.*)$",
+re_path(
+    r"tracks/(?P<url>.*)",
    HttpProxy.as_view(
        base_url=f"{settings.WORKER_REST_BASE_URL}/public/tracks/",
        ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
    ),
),

This improves readability without affecting functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 56b6696 and 78c038c.

⛔ Files ignored due to path filters (1)
  • backend/Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (77)
  • .github/workflows/main.yml (4 hunks)
  • backend/Makefile (1 hunks)
  • backend/Pipfile (4 hunks)
  • backend/beaconsite/tests/test_permissions.py (3 hunks)
  • backend/beaconsite/tests/test_permissions_ajax.py (2 hunks)
  • backend/beaconsite/tests/test_permissions_api.py (3 hunks)
  • backend/beaconsite/tests/test_views_ajax.py (1 hunks)
  • backend/beaconsite/urls.py (1 hunks)
  • backend/cases/tests/test_permissions.py (1 hunks)
  • backend/cases/tests/test_permissions_ajax.py (12 hunks)
  • backend/cases/tests/test_permissions_api.py (11 hunks)
  • backend/cases/tests/test_views.py (1 hunks)
  • backend/cases/tests/test_views_ajax.py (12 hunks)
  • backend/cases/urls.py (1 hunks)
  • backend/cases_analysis/tests/test_permissions_api.py (2 hunks)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_import/tests/test_permissions_api.py (1 hunks)
  • backend/cases_qc/tests/test_permissions_api.py (2 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/cohorts/migrations/0008_alter_cohort_user.py (1 hunks)
  • backend/cohorts/tests/test_permissions_ajax.py (3 hunks)
  • backend/cohorts/tests/test_permissions_api.py (3 hunks)
  • backend/cohorts/tests/test_views_ui.py (1 hunks)
  • backend/cohorts/urls.py (1 hunks)
  • backend/config/settings/base.py (3 hunks)
  • backend/config/urls.py (5 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/genepanels/tests/test_permissions.py (2 hunks)
  • backend/genepanels/urls.py (1 hunks)
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1 hunks)
  • backend/importer/urls.py (1 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/seqmeta/tests/test_permissions.py (2 hunks)
  • backend/seqmeta/urls.py (2 hunks)
  • backend/seqvars/tests/test_permissions_api.py (17 hunks)
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_presets.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_queries.py (6 hunks)
  • backend/svs/urls.py (2 hunks)
  • backend/varannos/tests/helpers.py (3 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_permissions.py (1 hunks)
  • backend/varannos/tests/test_permissions_api.py (1 hunks)
  • backend/varannos/urls.py (2 hunks)
  • backend/varfish/templates/users/login.html (1 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/varfish/users/urls.py (1 hunks)
  • backend/varfish/vueapp/urls.py (1 hunks)
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/models/maintenance.py (1 hunks)
  • backend/variants/tests/helpers.py (3 hunks)
  • backend/variants/tests/test_file_export.py (2 hunks)
  • backend/variants/tests/test_permissions_ajax.py (6 hunks)
  • backend/variants/tests/test_permissions_ajax_annos.py (1 hunks)
  • backend/variants/tests/test_permissions_ajax_presets.py (29 hunks)
  • backend/variants/tests/test_permissions_api.py (7 hunks)
  • backend/variants/tests/test_ui.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
  • backend/variants/urls/init.py (2 hunks)
  • backend/variants/urls/annos.py (1 hunks)
  • backend/variants/urls/presets.py (2 hunks)
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (1 hunks)
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4 hunks)
  • frontend/src/varfish/components/FilterForm/DevPane.vue (2 hunks)
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/EffectPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FlagsPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3 hunks)
  • frontend/src/variants/components/FilterForm/QualityPane.vue (1 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetProperties.vue (1 hunks)
  • utils/docker/Dockerfile (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (64)
  • .github/workflows/main.yml
  • backend/Makefile
  • backend/Pipfile
  • backend/beaconsite/tests/test_permissions.py
  • backend/beaconsite/tests/test_permissions_ajax.py
  • backend/beaconsite/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_views_ajax.py
  • backend/beaconsite/urls.py
  • backend/cases/tests/test_permissions.py
  • backend/cases/tests/test_permissions_ajax.py
  • backend/cases/tests/test_permissions_api.py
  • backend/cases/tests/test_views.py
  • backend/cases/tests/test_views_ajax.py
  • backend/cases_analysis/tests/test_permissions_api.py
  • backend/cases_import/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_views_api.py
  • backend/cohorts/migrations/0008_alter_cohort_user.py
  • backend/cohorts/tests/test_permissions_ajax.py
  • backend/cohorts/tests/test_permissions_api.py
  • backend/cohorts/tests/test_views_ui.py
  • backend/cohorts/urls.py
  • backend/genepanels/forms.py
  • backend/genepanels/tests/test_models.py
  • backend/genepanels/tests/test_permissions.py
  • backend/genepanels/urls.py
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py
  • backend/seqmeta/tests/test_models.py
  • backend/seqmeta/tests/test_permissions.py
  • backend/seqmeta/urls.py
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py
  • backend/svs/tests/test_permissions_ajax_presets.py
  • backend/svs/tests/test_permissions_ajax_queries.py
  • backend/varannos/tests/helpers.py
  • backend/varannos/tests/test_models.py
  • backend/varannos/tests/test_permissions.py
  • backend/varannos/tests/test_permissions_api.py
  • backend/varannos/urls.py
  • backend/varfish/templates/users/login.html
  • backend/varfish/users/management/commands/initdev.py
  • backend/varfish/users/urls.py
  • backend/varfish/vueapp/urls.py
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py
  • backend/variants/migrations/0110_drop_variant_summary.py
  • backend/variants/migrations/0111_create_variant_summary.py
  • backend/variants/tests/helpers.py
  • backend/variants/tests/test_file_export.py
  • backend/variants/tests/test_permissions_ajax.py
  • backend/variants/tests/test_permissions_ajax_annos.py
  • backend/variants/tests/test_permissions_api.py
  • backend/variants/tests/test_ui.py
  • backend/variants/urls/annos.py
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue
  • frontend/src/varfish/components/FilterForm/DevPane.vue
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue
  • frontend/src/variants/components/FilterForm/EffectPane.vue
  • frontend/src/variants/components/FilterForm/FlagsPane.vue
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue
  • frontend/src/variants/components/FilterForm/QualityPane.vue
  • frontend/src/variants/components/QueryPresets/SetEditor.vue
  • frontend/src/variants/components/QueryPresets/SetProperties.vue
  • utils/docker/Dockerfile
🧰 Additional context used
🪛 Ruff
backend/variants/models/maintenance.py

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

🔇 Additional comments (66)
backend/variants/models/maintenance.py (3)

122-134: Well-structured SQL command for materialized view management

The SQL_OUTER command is well-designed and includes all necessary operations for managing the SmallVariantSummary materialized view. It properly handles the dropping of the existing view, creates the new view, and sets up appropriate indexes for performance optimization.

The use of IF EXISTS in the DROP statement and the creation of indexes after the view creation are good practices. The placeholder for the inner query allows for flexibility in defining the view's content.


137-180: Well-designed SQL query for aggregating variant data

The SQL_INNER command is well-structured and effectively aggregates data from the variants_smallvariant table while applying necessary exclusions.

Key strengths of this query:

  1. Uses a CTE to efficiently exclude cases based on project settings.
  2. Employs row_number() for generating a unique ID.
  3. Properly aggregates variant counts using sum() functions.
  4. Applies grouping to create a summary of unique variants.

The query effectively balances performance considerations with the need for accurate data aggregation.


114-188: Overall assessment: Well-implemented materialized view management

The new functions and SQL commands for managing the SmallVariantSummary materialized view are well-designed and effectively implemented. They provide a robust solution for dropping, creating, and populating the view with appropriate data aggregation and exclusion logic.

Key strengths of this implementation:

  1. Clear and concise functions for dropping and creating the materialized view.
  2. Well-structured SQL commands with appropriate use of CTEs, aggregations, and indexing.
  3. Proper use of transactions to ensure atomicity of operations.

The suggested improvements (combining with statements and considering parameterized queries) are minor and do not detract from the overall quality of the implementation. Great job on this feature!

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

backend/config/urls.py (5)

29-70: LGTM: URL patterns updated correctly

The transition from url() to path() for all URL patterns is correct and aligns with modern Django practices. The structure and order of the patterns have been maintained, ensuring consistency with the previous implementation.


94-95: LGTM: Proxy URL patterns updated correctly

The transition from url() to re_path() for all proxy URL patterns is correct. This change maintains the regex functionality while aligning with modern Django practices. The existing regex patterns and configurations have been preserved, ensuring consistent behavior.

Also applies to: 102-103, 110-111, 117-118, 124-125, 132-133, 139-140


182-193: LGTM: Error handling URL patterns updated correctly

The transition from url() to path() for all error handling URL patterns is correct and aligns with modern Django practices. The structure and functionality of these patterns have been maintained, ensuring consistent error handling behavior.


198-198: LGTM: Debug toolbar URL pattern updated correctly

The transition from url() to path() for the debug toolbar URL pattern is correct and aligns with modern Django practices. The functionality of the pattern has been maintained, ensuring consistent behavior for the debug toolbar.


168-169: ⚠️ Potential issue

Use re_path() instead of path() for regex patterns

The pattern "-.*" includes regex wildcard characters. Since path() doesn't accept regex patterns and interprets the route parameter as a fixed string or with path converters, you should use re_path() for regex patterns.

Apply this diff to fix the issue:

-path(
+re_path(

Likely invalid or redundant comment.

backend/variants/urls/__init__.py (5)

1-1: LGTM: Import statement updated correctly

The import statement has been updated to use path instead of url, which is the correct approach for modern Django applications.


12-150: LGTM: UI URL patterns updated correctly

All URL patterns in the ui_urlpatterns list have been successfully updated to use the path() function instead of url(). The conversion from regex patterns to path converters, especially for UUID fields, has been done correctly and consistently.


156-292: LGTM: AJAX URL patterns updated correctly

The ajax_urlpatterns list has been successfully updated to use the path() function. All UUID fields are correctly using the <uuid:...> path converter, and the overall structure and naming conventions have been maintained.


299-450: LGTM: API URL patterns updated correctly

The api_urlpatterns list has been successfully updated to use the path() function. All UUID fields are correctly using the <uuid:...> path converter, and the overall structure and naming conventions have been maintained.


354-358: Verify the <str:category> path converter

The URL pattern for api-category-presets uses a <str:category> path converter, which differs from the UUID pattern used in other routes. This is likely intentional, but please verify that this matches the expected behavior for this endpoint.

To ensure this change is correct, you can run the following command to check if there are any other occurrences of category in URL patterns:

✅ Verification successful

Verification Successful: <str:category> path converter is used correctly.

  • No other URL patterns with category path converter found.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other occurrences of 'category' in URL patterns
rg --type python 'path\([^)]*category' backend/variants/urls/

Length of output: 94


Script:

#!/bin/bash
# Description: Check for other occurrences of 'category' in URL patterns with the correct file type
rg --type py 'path\([^)]*category' backend/variants/urls/

Length of output: 59

backend/cases_import/tests/test_models_executor.py (1)

54-54: LGTM! Verify consistent usage across the codebase.

The change from app_name to plugin_name in the app_settings.set() call looks good. This likely reflects a terminology change in the AppSettingAPI.

To ensure consistency, let's check for any remaining uses of app_name in similar contexts:

✅ Verification successful

Further verification needed: Re-run search for 'app_name' and 'plugin_name' in app_settings.set() calls.


Verified Consistent Usage of 'plugin_name' Across the Codebase.

The search did not find any remaining instances of app_name in app_settings.set() calls, confirming that the change to plugin_name is applied consistently throughout the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for remaining instances of 'app_name' in Python files
rg 'app_settings\.set\(.*app_name' -t py

Length of output: 42


Script:

#!/bin/bash
# Search for instances of 'plugin_name' or 'app_name' in 'app_settings.set()' calls within Python files
rg 'app_settings\.set\([^)]*(plugin_name|app_name)' -t py

Length of output: 59

backend/variants/tests/test_views_ajax_presets.py (2)

122-129: LGTM: Improved test robustness by removing mocks.

The removal of mocking in favor of direct assertions on response data is a positive change. This approach leads to more realistic tests and reduces the risk of false positives due to incorrect mocking.

To ensure the test environment is properly set up for these changes, please run the following command to check for any potential issues:

#!/bin/bash
# Description: Verify the test environment setup

# Run the tests and capture any errors or warnings
python manage.py test backend.variants.tests.test_views_ajax_presets 2>&1 | grep -E "Error|Warning|Exception"

Also applies to: 146-153, 244-251, 268-275, 366-373, 390-397, 488-495, 512-519, 610-617, 634-641, 732-739, 842-848, 862-869


3-3: LGTM: Base class update looks good.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase appears to be part of a standardization effort. This update should improve consistency across the codebase.

To ensure full compatibility, please verify that ProjectAPIPermissionTestBase provides all the necessary methods and attributes used in the derived test classes. Run the following command to check for any undefined attributes or methods:

Also applies to: 26-26

backend/variants/tests/test_permissions_ajax_presets.py (4)

Line range hint 373-420: Changed user role representation in good_users list.

Starting from this class, the good_users list uses self.owner_as.user instead of self.user_owner. This change is consistent with the previous class but differs from earlier classes in the file.

Please verify if this change in user role representation is intentional. If so, consider updating all test classes in this file for consistency. Run the following command to check the usage of both self.user_owner and self.owner_as.user throughout the file:

#!/bin/bash
# Description: Check the usage of user_owner and owner_as.user in the file

# Test: Count occurrences of self.user_owner and self.owner_as.user
echo "Occurrences of self.user_owner:"
rg --count 'self\.user_owner' backend/variants/tests/test_permissions_ajax_presets.py

echo "Occurrences of self.owner_as.user:"
rg --count 'self\.owner_as\.user' backend/variants/tests/test_permissions_ajax_presets.py

Line range hint 1117-1140: Verify the different set of allowed users in TestPresetSetListAllAjaxView.

The TestPresetSetListAllAjaxView class includes self.user_no_roles in the good_users list, which is different from other test classes in this file. This might be intentional due to the nature of the "listall" endpoint, but it's worth verifying.

Please confirm if the inclusion of self.user_no_roles in the good_users list for the "listall" endpoint is intentional. If it is, consider adding a comment explaining why this endpoint allows access to users with no roles. If not, update the good_users list to be consistent with other test classes.

You can use the following command to check the uniqueness of this configuration:

#!/bin/bash
# Description: Check for other occurrences of user_no_roles in good_users lists

# Test: Search for user_no_roles in good_users lists
rg 'good_users.*=.*\[.*self\.user_no_roles' backend/variants/tests/test_permissions_ajax_presets.py

1-2: LGTM! Verify the new base class functionality.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent and appears to be part of a larger refactoring. This change should improve consistency across tests.

To ensure the new base class provides all necessary functionality, run the following command:

Also applies to: 17-17


Line range hint 1-1271: Overall changes look good, suggest thorough testing.

The file has been consistently updated to use ProjectAPIPermissionTestBase as the base class for all test classes, which appears to be part of a larger refactoring effort. The changes should improve consistency and possibly add new functionality.

Key points to note:

  1. There's a change in user role representation from self.user_owner to self.owner_as.user starting from the TestImpactPresetsCloneOtherView class.
  2. The TestPresetSetListAllAjaxView class has a unique set of allowed users, including self.user_no_roles.

To ensure that these changes haven't introduced any regressions, please run the full test suite for this file and verify that all tests pass. You can use the following command:

If any tests fail, please review the failures and make necessary adjustments.

backend/cases_import/models/executors.py (2)

Line range hint 1037-1068: Great addition! Unified approach for create and update operations.

This new method _run_create_or_update effectively encapsulates the logic for both creating and updating cases. It provides several benefits:

  1. Improved code reusability by handling both operations in a single method.
  2. Clear sequence of steps, enhancing readability and maintainability.
  3. Proper error handling and logging.
  4. Modular approach with separate methods for each step.
  5. Appropriate case state management.

The structure and flow of this method look solid and well-thought-out.


Line range hint 1-1068: Overall, excellent improvements to the case import process.

The changes in this file demonstrate a thoughtful approach to improving the codebase:

  1. The update to _build_fs_options aligns with what seems to be updated naming conventions.
  2. The new _run_create_or_update method significantly enhances the case import process by providing a unified, modular approach for both creation and updating of cases.

These changes appear to be part of a larger effort to standardize and improve the codebase. They are well-implemented and follow good coding practices. Great work!

backend/seqvars/tests/test_permissions_api.py (12)

Line range hint 205-355: LGTM!

The TestQueryPresetsVersionSetViewSet class follows the same structure and testing pattern as the previous class. The tests appear to be comprehensive, covering all necessary CRUD operations and permission checks for different user roles.


Line range hint 356-509: LGTM!

The TestQueryPresetsFrequencyViewSet class maintains the consistent structure and testing pattern seen in previous classes. It adequately covers CRUD operations and permission checks for the QueryPresetsFrequency model.


Line range hint 510-661: LGTM!

The TestQueryPresetsQualityViewSet class follows the established pattern, providing comprehensive tests for CRUD operations and permission checks on the QueryPresetsQuality model.


Line range hint 662-815: LGTM!

The TestQueryPresetsConsequenceViewSet class maintains the consistent structure and testing pattern, adequately covering CRUD operations and permission checks for the QueryPresetsConsequence model.


Line range hint 816-965: LGTM!

The TestQueryPresetsLocusViewSet class follows the established pattern, providing comprehensive tests for CRUD operations and permission checks on the QueryPresetsLocus model.


Line range hint 966-1119: LGTM!

The TestQueryPresetsPhenotypePrioViewSet class maintains the consistent structure and testing pattern, adequately covering CRUD operations and permission checks for the QueryPresetsPhenotypePrio model.


Line range hint 1120-1273: LGTM!

The TestQueryPresetsVariantPrioViewSet class follows the established pattern, providing comprehensive tests for CRUD operations and permission checks on the QueryPresetsVariantPrio model.


Line range hint 1274-1425: LGTM!

The TestQueryPresetsColumnsViewSet class maintains the consistent structure and testing pattern, adequately covering CRUD operations and permission checks for the QueryPresetsColumns model.


Line range hint 1426-1577: LGTM!

The TestQueryPresetsClinvarViewSet class follows the established pattern, providing comprehensive tests for CRUD operations and permission checks on the QueryPresetsClinvar model.


Line range hint 1578-1727: LGTM!

The TestPredefinedQueryViewSet class maintains the consistent structure and testing pattern, adequately covering CRUD operations and permission checks for the PredefinedQuery model.


Line range hint 2249-2303: LGTM!

The TestResultSetViewSet class follows the same pattern as TestQueryExecutionViewSet, providing tests for list and retrieve operations and checking permissions for different user roles. The tests appear to be comprehensive for the supported operations.


Line range hint 2304-2352: LGTM!

The TestResultRowViewSet class maintains the consistent structure seen in TestResultSetViewSet and TestQueryExecutionViewSet, providing comprehensive tests for list and retrieve operations and permission checks for different user roles.

backend/importer/urls.py (3)

4-4: Correctly updated import statement to use path.

The import has been updated to use path from django.urls, which is appropriate since url() is deprecated in favor of path() in newer versions of Django.


11-13: URL patterns updated to use path() function.

The URL patterns in ui_urlpatterns have been correctly converted to use path(), with appropriate path converters like <uuid:project> and <uuid:job>.


20-86: API URL patterns correctly converted to path() with appropriate converters.

All the API URL patterns have been updated from url() to path() with suitable path converters for UUIDs. This change aligns with Django's recommended practices for URL routing.

To ensure there are no remaining uses of the deprecated url() function in the codebase, you can run the following script:

✅ Verification successful

API URL patterns have been successfully updated to use path() without any remaining url() usages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining usages of 'url(' in Python files.
# Expected result: No output if all instances are replaced.

rg --type py 'url\('

Length of output: 7364

backend/svs/urls.py (1)

2-2: Import Statement Updated Appropriately

The import statement now correctly includes path and re_path from django.urls, which are needed for the updated URL routing.

backend/cases/urls.py (8)

7-11: Correct migration to path() in ui_urlpatterns

The ui_urlpatterns have been successfully updated to use the path() function with UUID converters, adhering to Django's recommended practices.


15-77: Consistent updates in ajax_urlpatterns

All ajax_urlpatterns have been properly updated to use the path() function with appropriate UUID converters. The routes and views are correctly configured, ensuring consistency throughout this section.


83-102: Proper updates in api_urlpatterns

The initial entries in api_urlpatterns have been correctly updated to use the path() function with UUID converters, referencing the appropriate API views from views_api.


103-107: Previous comment remains applicable


128-132: Previous comment remains applicable


133-137: Previous comment remains applicable


138-142: Previous comment remains applicable


143-147: Previous comment remains applicable

backend/variants/urls/presets.py (18)

3-3: Import updated to use path

The import statement has been correctly updated to import path from django.urls, replacing the deprecated url function.


12-17: Updated URL pattern for FrequencyPresets list-create

The URL pattern has been correctly updated to use path() with <uuid:presetset>. This change aligns with Django's best practices for URL routing.


18-22: Updated URL pattern for FrequencyPresets retrieve-update-destroy

The URL pattern now uses <uuid:frequencypresets>, appropriately reflecting that this parameter is a UUID.


28-32: Updated URL pattern for FrequencyPresets clone-other

The URL pattern has been updated to use <uuid:frequencypresets>, ensuring consistency with the UUID parameter type.


54-59: Updated URL pattern for ImpactPresets list-create

The URL pattern has been correctly updated to use <uuid:presetset>, ensuring proper handling of UUID parameters.


60-64: Updated URL pattern for ImpactPresets retrieve-update-destroy

The use of <uuid:impactpresets> correctly reflects the UUID parameter type for ImpactPresets.


69-73: Updated URL pattern for ImpactPresets clone-other

The URL pattern now uses <uuid:impactpresets>, maintaining consistency in parameter types.


75-80: Updated URL pattern for QualityPresets list-create

The URL pattern has been updated to use <uuid:presetset> appropriately.


81-85: Updated URL pattern for QualityPresets retrieve-update-destroy

The change to <uuid:qualitypresets> correctly handles the UUID parameter.


90-94: Updated URL pattern for QualityPresets clone-other

The URL pattern now correctly uses <uuid:qualitypresets>.


119-124: Updated URL pattern for QuickPresets list-create

The URL pattern has been correctly updated to use <uuid:presetset>.


125-129: Updated URL pattern for QuickPresets retrieve-update-destroy

The use of <uuid:quickpresets> accurately represents the UUID parameter.


130-134: Updated URL pattern for QuickPresets clone-other

The URL pattern now uses <uuid:quickpresets>, ensuring consistency.


137-141: Updated URL pattern for PresetSet list

The URL pattern has been correctly updated to use path() without parameters, which is appropriate for listing all PresetSets.


148-152: Updated URL pattern for PresetSet retrieve-update-destroy

The URL pattern correctly uses <uuid:presetset>, ensuring proper handling of the UUID parameter.


153-157: Updated URL pattern for PresetSet clone-factory-presets

The URL pattern has been appropriately updated, and since it doesn't require a parameter, it correctly uses path() without additional parameters.


158-162: Updated URL pattern for PresetSet clone-other

The use of <uuid:presetset> in the URL pattern ensures consistent handling of UUID parameters.


143-146: Verify consistency of project parameter type

The project parameter now uses <uuid:project>. Ensure that all references to project throughout the codebase consistently use UUIDs, and update any existing calls or links accordingly.

Run the following script to check for inconsistencies:

backend/config/settings/base.py (2)

80-80: Integration of 'social_django' into 'THIRD_PARTY_APPS'

Adding 'social_django' to THIRD_PARTY_APPS enables OpenID Connect (OIDC) authentication, which is necessary for the implemented OIDC features.


438-438: Verify the change of ADMIN_URL to a string

The ADMIN_URL has been updated from a regex pattern to the string "admin/". Ensure that this alteration aligns with Django's URL configuration expectations and does not impact admin site accessibility.

Run the following script to check for usages of ADMIN_URL in your URL configurations and confirm that they handle the string format correctly:

✅ Verification successful

Verified: The ADMIN_URL has been correctly updated to a string in the URL configurations, ensuring that Django's admin site remains accessible.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for occurrences of 'ADMIN_URL' in URL configurations.

rg --type py --glob '**/urls.py' -A 3 'ADMIN_URL'

Length of output: 302

@@ -1,16 +1,15 @@
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls import include
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update import statement for include

For consistency with modern Django practices and to avoid potential deprecation warnings, consider updating the import of include.

Apply this diff to update the import statements:

-from django.conf.urls import include
 from django.conf.urls.static import static
 from django.contrib import admin
 from django.contrib.auth import views as auth_views
 from django.contrib.staticfiles import finders
 from django.http import HttpResponse
 from django.shortcuts import render
-from django.urls import path, re_path
+from django.urls import path, re_path, include

Also applies to: 9-9

Comment on lines +44 to 46
"ajax/flagsetcpresets/clone-factory-presets/<slug:name>/",
view=views_ajax.FlagsEtcPresetsCloneFactoryPresetsAjaxView.as_view(),
name="ajax-flagsetcpresets-clonefactorypresets",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential issue: slug converter allows digits in name parameter

In the URL patterns on lines 44-46, 65-67, 86-88, and 107-109, the name parameter has been changed from a regex pattern (?P<name>[a-zA-Z_-]+) to the <slug:name> path converter. The <slug> converter allows digits ([a-zA-Z0-9_-]+), which may unintentionally broaden the accepted name values.

To maintain the original behavior and exclude digits, consider one of the following options:

Option 1: Define a custom path converter

from django.urls import register_converter

class NoDigitSlugConverter:
    regex = '[a-zA-Z_-]+'

    def to_python(self, value):
        return value

    def to_url(self, value):
        return value

register_converter(NoDigitSlugConverter, 'nodigitslug')

Then update the URL patterns:

- "ajax/flagsetcpresets/clone-factory-presets/<slug:name>/",
+ "ajax/flagsetcpresets/clone-factory-presets/<nodigitslug:name>/",

Apply similar changes to the other affected URL patterns.

Option 2: Use re_path() with the original regex

from django.urls import re_path

re_path(
    r"ajax/flagsetcpresets/clone-factory-presets/(?P<name>[a-zA-Z_-]+)/",
    view=views_ajax.FlagsEtcPresetsCloneFactoryPresetsAjaxView.as_view(),
    name="ajax-flagsetcpresets-clonefactorypresets",
),

Also applies to: 65-67, 86-88, 107-109

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch 6 times, most recently from e546a7c to 7c55f6e Compare October 17, 2024 12:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (24)
backend/varannos/urls.py (1)

37-41: LGTM: Enhanced API URL pattern for VarAnnoSetEntryRetrieveUpdateDestroyApiView

The update from url() to path() simplifies the API URL pattern and improves its readability. The explicit uuid type for the varannosetentry parameter provides better type safety. This change is in line with Django's recommended practices for API URL configuration.

Consider updating the parameter name from varannosetentry to varanno_set_entry for consistency with Python naming conventions. This would make it:

path(
    "api/varannosetentry/retrieve-update-destroy/<uuid:varanno_set_entry>/",
    view=views_api.VarAnnoSetEntryRetrieveUpdateDestroyApiView.as_view(),
    name="api-varannosetentry-retrieveupdatedestroy",
),
backend/variants/models/maintenance.py (1)

137-180: SQL_INNER query is well-structured with a minor optimization opportunity

The SQL_INNER query is well-designed:

  • Good use of CTE for excluding cases based on project settings.
  • Proper aggregation of variant data with correct grouping.
  • Efficient handling of case exclusions.

One minor optimization suggestion:
Consider using COUNT(*) instead of sum(num_*) for counting occurrences, as it might be slightly more efficient. For example:

COUNT(*) FILTER (WHERE num_hom_ref > 0) AS count_hom_ref,
COUNT(*) FILTER (WHERE num_het > 0) AS count_het,
-- ... and so on for other counts

This change is optional and depends on the specific data distribution and database performance characteristics.

utils/docker/Dockerfile (2)

169-169: Approve Bootstrap CSS map addition with a note on production builds.

Adding the Bootstrap CSS map file (bootstrap.min.css.map) is beneficial for debugging in development environments. However, consider whether this file is necessary for production builds, as it may increase the image size without providing benefits in a production environment.

Consider adding a condition to only include this file in development builds, if applicable.


177-177: Approve Bootstrap bundle JavaScript map addition with a note on production builds.

Adding the Bootstrap bundle JavaScript map file (bootstrap.bundle.min.js.map) is beneficial for debugging in development environments. However, similar to the CSS map, consider whether this file is necessary for production builds, as it may increase the image size without providing benefits in a production environment.

Consider adding a condition to only include this file in development builds, if applicable.

frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (2)

Line range hint 69-88: Improved gene panel insertion, but consider Vue reactivity

The insertGenomicsEnglandPanel function has been enhanced to use async/await and now filters genes based on confidence level. This is a good improvement for more precise control over gene selection.

However, directly modifying props.querySettings.gene_allowlist might cause issues with Vue's reactivity system.

Consider using the spread operator to create a new array when updating gene_allowlist:

- props.querySettings.gene_allowlist =
-   props.querySettings.gene_allowlist.concat(symbols)
+ props.querySettings.gene_allowlist = [
+   ...props.querySettings.gene_allowlist,
+   ...symbols
+ ]

This ensures that Vue detects the change and updates any dependent computations or renderings.


Line range hint 134-173: LGTM: Enhanced gene batch validation with panel support

The validateGeneBatch function has been improved to handle gene panel validation and uses the new lookupGenePanelApiEndpoint. The use of Promise.all for concurrent requests is efficient.

However, the error handling could be enhanced:

Consider adding a try-catch block to handle potential network errors:

try {
  const response = await fetch(url, {
    // ... existing options ...
  })
  // ... existing response handling ...
} catch (error) {
  console.error('Error validating gene batch:', error)
  return { [token]: { state: 'error', message: error.message } }
}

This will provide more robust error handling and prevent the function from failing silently in case of network issues.

backend/varfish/users/management/commands/initdev.py (2)

Line range hint 67-89: LGTM! Consider adding help text for --data-release and --data-case.

The new command-line arguments enhance the flexibility of the initdev command, allowing for more specific data handling scenarios. The choices for each argument are well-defined and relevant.

Consider adding more descriptive help text for the --data-release and --data-case arguments to provide users with context about what these choices represent.


Line range hint 118-159: LGTM! Consider adding type hints for the return value.

The changes in the _handle method effectively implement the logic for handling different data creation scenarios based on the new command-line arguments. The error handling and transaction management remain robust.

Consider adding a type hint for the return value of the _handle method to improve code readability:

def _handle(
    self,
    ...,
) -> Optional[int]:
    ...
backend/variants/tests/test_views_ajax_presets.py (5)

122-129: Approve changes and suggest minor improvement

The simplification of the test method by removing mocking is a good improvement. It makes the test more readable and less brittle.

Consider adding an assertion to check if a new FrequencyPresets object was actually created in the database. This would ensure that the API call not only returns the correct response but also performs the expected database operation. For example:

self.assertEqual(FrequencyPresets.objects.count(), 1)  # Add this line before the API call
# ... (existing code)
self.assertEqual(FrequencyPresets.objects.count(), 2)  # Add this line after the assertions

146-153: Approve changes and suggest minor improvement

The simplification of the test method is consistent with the changes made in other classes. This improves readability and maintainability.

As suggested for the previous class, consider adding an assertion to check if a new FrequencyPresets object was created in the database. For example:

self.assertEqual(FrequencyPresets.objects.count(), 1)  # Add this line before the API call
# ... (existing code)
self.assertEqual(FrequencyPresets.objects.count(), 2)  # Add this line after the assertions

244-251: Approve changes and suggest minor improvement for consistency

The simplification of the test method is consistent with the changes made in other classes, improving overall test readability and maintainability.

For consistency with the suggestions made for other similar classes, consider adding an assertion to check if a new ImpactPresets object was created in the database. For example:

self.assertEqual(ImpactPresets.objects.count(), 0)  # Add this line before the API call
# ... (existing code)
self.assertEqual(ImpactPresets.objects.count(), 1)  # Add this line after the assertions

268-275: Approve changes and suggest minor improvement for consistency

The simplification of the test method aligns with the changes made in other classes, contributing to improved test readability and maintainability.

To maintain consistency with the suggestions made for other similar classes, consider adding an assertion to check if a new ImpactPresets object was created in the database. For example:

self.assertEqual(ImpactPresets.objects.count(), 1)  # Add this line before the API call
# ... (existing code)
self.assertEqual(ImpactPresets.objects.count(), 2)  # Add this line after the assertions

Line range hint 1-872: Summary of changes and suggestion for consistency

The refactoring in this file has significantly improved the readability and maintainability of the tests. The removal of mocking and simplification of test methods is a positive change that makes the tests less brittle and easier to understand.

To further improve the consistency and effectiveness of these tests, consider applying the following pattern consistently across all test classes:

  1. Add an assertion to check the object count before the API call.
  2. Perform the API call and check the response status and content.
  3. Add an assertion to check the object count after the API call.

This pattern is exemplified in the TestPresetSetCloneOtherAjaxView class and ensures that each test thoroughly verifies both the API response and the resulting database state. Implementing this consistently will enhance the overall quality and reliability of your test suite.

backend/variants/tests/test_permissions_ajax_presets.py (2)

Line range hint 140-165: LGTM! Comprehensive testing for cloning factory defaults.

The TestFrequencyPresetsCloneFactoryDefaultsView class effectively tests the cloning of factory default frequency presets. It covers all necessary user roles and their permissions.

Consider parameterizing the factory default name ("dominant_strict") to allow for easy testing of multiple factory defaults if needed in the future. This could improve the test's flexibility and reusability.


Line range hint 195-1271: LGTM! Comprehensive and consistent testing across all preset types.

The remaining test classes (from TestImpactPresetsListCreateAjaxView to TestPresetSetCloneOtherView) maintain a consistent structure and thoroughly test all CRUD operations and cloning functionalities for various preset types. This approach ensures that all preset-related API endpoints are properly secured and functioning as expected.

Consider introducing a base test class or using parameterized tests to reduce code duplication across the different preset types. This could make the test suite more maintainable and easier to extend in the future. For example:

class BasePresetTestCase(ProjectAPIPermissionTestBase):
    preset_factory = None
    url_name_prefix = None

    def setUp(self):
        super().setUp()
        self.preset = self.preset_factory(presetset__project=self.project)
        self.presetset = self.preset.presetset

    def test_list(self):
        url = reverse(
            f"variants:ajax-{self.url_name_prefix}-listcreate",
            kwargs={"presetset": self.presetset.sodar_uuid},
        )
        # ... rest of the test implementation

# Usage
class TestFrequencyPresetsListCreateAjaxView(BasePresetTestCase):
    preset_factory = FrequencyPresetsFactory
    url_name_prefix = "frequencypresets"

class TestImpactPresetsListCreateAjaxView(BasePresetTestCase):
    preset_factory = ImpactPresetsFactory
    url_name_prefix = "impactpresets"

# ... and so on for other preset types

This refactoring would significantly reduce code duplication while maintaining the specific test cases for each preset type.

backend/cases_import/models/executors.py (1)

Line range hint 1-1000: LGTM. Consider enhancing error handling and logging.

The addition of the _run_create_or_update method is a good improvement to the code structure. It encapsulates the logic for creating or updating a case, making the code more organized and readable.

Consider adding more detailed error handling and logging for each step of the process. This will make it easier to diagnose issues if something goes wrong during the case import process. For example:

def _run_create_or_update(self):
    try:
        family = self._parse_family()
        with transaction.atomic():
            case = self._create_or_update_case(family)
        if not case:
            return

        self._clear_files(case)
        self._create_external_files(case, family)
        self._run_qc_file_import(case)
        self._run_seqvars_import(case)
        self._run_strucvars_import(case)
        self._update_case_state(case)
    except Exception as e:
        self.caseimportbackgroundjob.add_log_entry(
            f"Error during case import: {str(e)}", LOG_LEVEL_ERROR
        )
        raise

def _parse_family(self):
    try:
        return ParseDict(js_dict=self.caseimportbackgroundjob.caseimportaction.payload, message=Family())
    except ParseError as e:
        self.caseimportbackgroundjob.add_log_entry(
            f"Problem loading phenopackets.Family: {e}", LOG_LEVEL_ERROR
        )
        raise

This structure allows for more granular error handling and logging, which can be helpful for debugging and monitoring the import process.

backend/seqvars/tests/test_permissions_api.py (8)

Line range hint 62-204: Consider using parameterized tests for repeated test patterns

The TestQueryPresetsSetViewSet class (and subsequent similar classes) follow a repetitive pattern for testing different HTTP methods (list, create, retrieve, patch, delete) with various user roles. To reduce code duplication and improve maintainability, consider using a parameterized testing approach.

For example, you could define a base test class with common methods and use a library like parameterized to generate test cases:

from parameterized import parameterized

class BaseAPIPermissionTest(ProjectAPIPermissionTestBase):
    def setUp(self):
        super().setUp()
        self.setup_objects()

    def setup_objects(self):
        # Implement in subclasses to set up necessary objects

    @parameterized.expand([
        ("list", "GET", 200),
        ("create", "POST", 201),
        ("retrieve", "GET", 200),
        ("update", "PATCH", 200),
        ("delete", "DELETE", 204),
    ])
    def test_endpoint(self, name, method, expected_status):
        url = self.get_url(name)
        good_users = self.get_good_users(name)
        bad_users_401 = self.get_bad_users_401(name)
        bad_users_403 = self.get_bad_users_403(name)
        
        data = self.get_data(name) if method in ["POST", "PATCH"] else None
        cleanup = self.get_cleanup(name) if method in ["POST", "DELETE"] else None

        self.assert_response(url, good_users, expected_status, method=method, data=data, cleanup_method=cleanup)
        self.assert_response(url, bad_users_401, 401, method=method, data=data, cleanup_method=cleanup)
        self.assert_response(url, bad_users_403, 403, method=method, data=data, cleanup_method=cleanup)

    # Implement the following methods in subclasses:
    # get_url, get_good_users, get_bad_users_401, get_bad_users_403, get_data, get_cleanup

This approach would significantly reduce the amount of repeated code in your test classes while still maintaining the same level of test coverage.


Line range hint 356-509: Refactor repeated test patterns across multiple classes

The test classes TestQueryPresetsFrequencyViewSet, TestQueryPresetsQualityViewSet, TestQueryPresetsConsequenceViewSet, TestQueryPresetsLocusViewSet, TestQueryPresetsPhenotypePrioViewSet, TestQueryPresetsVariantPrioViewSet, TestQueryPresetsColumnsViewSet, and TestQueryPresetsClinvarViewSet all follow the same pattern of testing CRUD operations with similar permission checks.

To improve code maintainability and reduce duplication, consider implementing a base test class that encapsulates the common test logic. Each specific test class can then inherit from this base class and only implement the necessary setup and any unique test cases.

Example of a base test class:

class BaseQueryPresetsViewSetTest(ProjectAPIPermissionTestBase):
    factory_class = None
    url_name = None

    def setUp(self):
        super().setUp()
        self.querypresetsset = SeqvarsQueryPresetsSetFactory(project=self.project)
        self.querypresetssetversion = SeqvarsQueryPresetsSetVersionFactory(
            presetsset=self.querypresetsset,
            status=SeqvarsQueryPresetsSetVersion.STATUS_DRAFT,
        )
        self.object = self.factory_class(presetssetversion=self.querypresetssetversion)

    def get_url(self, action):
        if action == 'list':
            return reverse(
                f"seqvars:api-{self.url_name}-list",
                kwargs={"querypresetssetversion": self.querypresetssetversion.sodar_uuid},
            )
        else:
            return reverse(
                f"seqvars:api-{self.url_name}-detail",
                kwargs={
                    "querypresetssetversion": self.querypresetssetversion.sodar_uuid,
                    self.url_name: self.object.sodar_uuid,
                },
            )

    # Implement common test methods (test_list, test_create, test_retrieve, test_patch, test_delete)

Then, each specific test class can be simplified:

class TestQueryPresetsFrequencyViewSet(BaseQueryPresetsViewSetTest):
    factory_class = SeqvarsQueryPresetsFrequencyFactory
    url_name = "querypresetsfrequency"

    # Implement only unique test methods or override if necessary

This refactoring will make your test suite more maintainable and easier to extend in the future.

Also applies to: 510-661, 662-815, 816-965, 966-1119, 1120-1273, 1274-1425, 1426-1577


Line range hint 1578-1727: Refactor TestPredefinedQueryViewSet to use base class

The TestPredefinedQueryViewSet class follows the same pattern as the previous test classes. Consider refactoring it to use the base test class suggested earlier. This will help maintain consistency across your test suite and reduce code duplication.

Example:

class TestPredefinedQueryViewSet(BaseQueryPresetsViewSetTest):
    factory_class = SeqvarsPredefinedQueryFactory
    url_name = "predefinedquery"

    # Implement only unique test methods or override if necessary

This approach will make your test suite more maintainable and consistent.


Line range hint 1728-1925: Refactor TestQuerySettingsViewSet for improved maintainability

The TestQuerySettingsViewSet class has a similar structure to previous test classes but with some differences in setup and data handling. Consider creating a separate base class for settings-related tests or extending the existing base class to accommodate these differences.

Additionally, the test_create method contains a large data dictionary. Consider moving this to a separate method or fixture to improve readability:

def get_test_data(self):
    return {
        "genotype": SeqvarsQuerySettingsGenotypeSerializer(
            SeqvarsQuerySettingsGenotypeFactory.build(querysettings=None)
        ).data,
        # ... (rest of the data)
    }

def test_create(self):
    # ... (existing setup code)
    data = self.get_test_data()
    # ... (rest of the test)

This refactoring will improve the maintainability and readability of your test suite.


Line range hint 1926-2194: Refactor TestQueryViewSet for consistency and improved maintainability

The TestQueryViewSet class follows a similar pattern to previous test classes but includes an additional test_create_from method. Consider the following improvements:

  1. Refactor common CRUD tests to use a base class, as suggested for previous test classes.
  2. Move the large data dictionary in test_create to a separate method, similar to the suggestion for TestQuerySettingsViewSet.
  3. For the test_create_from method, consider moving the setup of presetsset and predefinedquery to the setUp method if they are used in multiple tests.

Example refactoring for test_create_from:

class TestQueryViewSet(BaseQueryViewSetTest):
    def setUp(self):
        super().setUp()
        presetsset_factory = create_seqvarspresetsset_short_read_exome_legacy()
        self.presetsset = presetsset_factory.clone_with_latest_version(project=self.project)
        self.version = self.presetsset.versions.all()[0]
        self.predefinedquery = self.version.seqvarspredefinedquery_set.all()[0]

    def test_create_from(self):
        url = reverse(
            "seqvars:api-query-create-from",
            kwargs={
                "session": self.session.sodar_uuid,
            },
        )
        data = {
            "predefinedquery": self.predefinedquery.sodar_uuid,
            "label": "test label",
        }
        
        # ... (rest of the test)

These changes will improve the consistency and maintainability of your test suite.


Line range hint 2195-2248: Refactor TestQueryExecutionViewSet for consistency

The TestQueryExecutionViewSet class is simpler than previous classes, only testing list and retrieve operations. To maintain consistency with other test classes and prepare for potential future additions, consider:

  1. Refactoring it to use a base test class, similar to previous suggestions.
  2. Adding placeholders for create, update, and delete tests, even if they're not currently implemented, to maintain consistency with other viewset tests.

Example:

class TestQueryExecutionViewSet(BaseQueryViewSetTest):
    def setUp(self):
        super().setUp()
        self.case = CaseFactory(project=self.project)
        self.caseanalysis = CaseAnalysisFactory(case=self.case)
        self.session = CaseAnalysisSessionFactory(caseanalysis=self.caseanalysis)
        self.query = SeqvarsQueryFactory(session=self.session)
        self.queryexecution = SeqvarsQueryExecutionFactory(query=self.query)

    # Implement list and retrieve tests

    def test_create(self):
        # Placeholder for create test
        pass

    def test_update(self):
        # Placeholder for update test
        pass

    def test_delete(self):
        # Placeholder for delete test
        pass

This structure will make it easier to add new tests in the future and maintain consistency across your test suite.


Line range hint 2249-2303: Refactor TestResultSetViewSet for consistency

Similar to the TestQueryExecutionViewSet, the TestResultSetViewSet only tests list and retrieve operations. To maintain consistency and prepare for future additions:

  1. Refactor it to use a base test class, as suggested for previous test classes.
  2. Add placeholders for create, update, and delete tests, even if they're not currently implemented.

This approach will make your test suite more consistent and easier to extend in the future.


Line range hint 2304-2351: Refactor TestResultRowViewSet for consistency and completeness

The TestResultRowViewSet class, like the previous two, only tests list and retrieve operations. To improve consistency and prepare for potential future additions:

  1. Refactor it to use a base test class, similar to previous suggestions.
  2. Add placeholders for create, update, and delete tests, even if they're not currently implemented.
  3. Consider adding tests for edge cases, such as attempting to access result rows from a different project or with invalid UUIDs.

Example:

class TestResultRowViewSet(BaseQueryViewSetTest):
    def setUp(self):
        super().setUp()
        # ... (existing setup code)

    def test_list_different_project(self):
        # Test accessing result rows from a different project
        pass

    def test_retrieve_invalid_uuid(self):
        # Test retrieving a result row with an invalid UUID
        pass

    # Implement list and retrieve tests

    def test_create(self):
        # Placeholder for create test
        pass

    def test_update(self):
        # Placeholder for update test
        pass

    def test_delete(self):
        # Placeholder for delete test
        pass

These changes will improve the consistency and completeness of your test suite, making it more robust and easier to maintain.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 78c038c and 7c55f6e.

⛔ Files ignored due to path filters (1)
  • backend/Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (77)
  • .github/workflows/main.yml (4 hunks)
  • backend/Makefile (1 hunks)
  • backend/Pipfile (4 hunks)
  • backend/beaconsite/tests/test_permissions.py (3 hunks)
  • backend/beaconsite/tests/test_permissions_ajax.py (2 hunks)
  • backend/beaconsite/tests/test_permissions_api.py (3 hunks)
  • backend/beaconsite/tests/test_views_ajax.py (1 hunks)
  • backend/beaconsite/urls.py (1 hunks)
  • backend/cases/tests/test_permissions.py (1 hunks)
  • backend/cases/tests/test_permissions_ajax.py (12 hunks)
  • backend/cases/tests/test_permissions_api.py (11 hunks)
  • backend/cases/tests/test_views.py (1 hunks)
  • backend/cases/tests/test_views_ajax.py (12 hunks)
  • backend/cases/urls.py (1 hunks)
  • backend/cases_analysis/tests/test_permissions_api.py (2 hunks)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_import/tests/test_permissions_api.py (1 hunks)
  • backend/cases_qc/tests/test_permissions_api.py (2 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/cohorts/migrations/0008_alter_cohort_user.py (1 hunks)
  • backend/cohorts/tests/test_permissions_ajax.py (3 hunks)
  • backend/cohorts/tests/test_permissions_api.py (3 hunks)
  • backend/cohorts/tests/test_views_ui.py (1 hunks)
  • backend/cohorts/urls.py (1 hunks)
  • backend/config/settings/base.py (3 hunks)
  • backend/config/urls.py (5 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/genepanels/tests/test_permissions.py (2 hunks)
  • backend/genepanels/urls.py (1 hunks)
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1 hunks)
  • backend/importer/urls.py (1 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/seqmeta/tests/test_permissions.py (2 hunks)
  • backend/seqmeta/urls.py (2 hunks)
  • backend/seqvars/tests/test_permissions_api.py (17 hunks)
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_presets.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_queries.py (6 hunks)
  • backend/svs/urls.py (2 hunks)
  • backend/varannos/tests/helpers.py (3 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_permissions.py (1 hunks)
  • backend/varannos/tests/test_permissions_api.py (1 hunks)
  • backend/varannos/urls.py (2 hunks)
  • backend/varfish/templates/users/login.html (1 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/varfish/users/urls.py (1 hunks)
  • backend/varfish/vueapp/urls.py (1 hunks)
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/models/maintenance.py (1 hunks)
  • backend/variants/tests/helpers.py (3 hunks)
  • backend/variants/tests/test_file_export.py (2 hunks)
  • backend/variants/tests/test_permissions_ajax.py (6 hunks)
  • backend/variants/tests/test_permissions_ajax_annos.py (1 hunks)
  • backend/variants/tests/test_permissions_ajax_presets.py (29 hunks)
  • backend/variants/tests/test_permissions_api.py (7 hunks)
  • backend/variants/tests/test_ui.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
  • backend/variants/urls/init.py (2 hunks)
  • backend/variants/urls/annos.py (1 hunks)
  • backend/variants/urls/presets.py (2 hunks)
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (1 hunks)
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4 hunks)
  • frontend/src/varfish/components/FilterForm/DevPane.vue (2 hunks)
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/EffectPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FlagsPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3 hunks)
  • frontend/src/variants/components/FilterForm/QualityPane.vue (1 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetProperties.vue (1 hunks)
  • utils/docker/Dockerfile (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (61)
  • .github/workflows/main.yml
  • backend/Makefile
  • backend/Pipfile
  • backend/beaconsite/tests/test_permissions.py
  • backend/beaconsite/tests/test_permissions_ajax.py
  • backend/beaconsite/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_views_ajax.py
  • backend/beaconsite/urls.py
  • backend/cases/tests/test_permissions.py
  • backend/cases/tests/test_permissions_ajax.py
  • backend/cases/tests/test_permissions_api.py
  • backend/cases/tests/test_views.py
  • backend/cases/tests/test_views_ajax.py
  • backend/cases_analysis/tests/test_permissions_api.py
  • backend/cases_import/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_views_api.py
  • backend/cohorts/migrations/0008_alter_cohort_user.py
  • backend/cohorts/tests/test_permissions_ajax.py
  • backend/cohorts/tests/test_permissions_api.py
  • backend/cohorts/tests/test_views_ui.py
  • backend/cohorts/urls.py
  • backend/genepanels/forms.py
  • backend/genepanels/tests/test_models.py
  • backend/genepanels/tests/test_permissions.py
  • backend/genepanels/urls.py
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py
  • backend/seqmeta/tests/test_models.py
  • backend/seqmeta/tests/test_permissions.py
  • backend/seqmeta/urls.py
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py
  • backend/svs/tests/test_permissions_ajax_presets.py
  • backend/svs/tests/test_permissions_ajax_queries.py
  • backend/varannos/tests/helpers.py
  • backend/varannos/tests/test_models.py
  • backend/varannos/tests/test_permissions.py
  • backend/varannos/tests/test_permissions_api.py
  • backend/varfish/templates/users/login.html
  • backend/varfish/users/urls.py
  • backend/varfish/vueapp/urls.py
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py
  • backend/variants/migrations/0110_drop_variant_summary.py
  • backend/variants/migrations/0111_create_variant_summary.py
  • backend/variants/tests/helpers.py
  • backend/variants/tests/test_file_export.py
  • backend/variants/tests/test_permissions_ajax.py
  • backend/variants/tests/test_permissions_ajax_annos.py
  • backend/variants/tests/test_permissions_api.py
  • backend/variants/tests/test_ui.py
  • backend/variants/urls/annos.py
  • backend/variants/urls/presets.py
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue
  • frontend/src/varfish/components/FilterForm/DevPane.vue
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue
  • frontend/src/variants/components/FilterForm/EffectPane.vue
  • frontend/src/variants/components/FilterForm/FlagsPane.vue
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue
  • frontend/src/variants/components/FilterForm/QualityPane.vue
  • frontend/src/variants/components/QueryPresets/SetEditor.vue
  • frontend/src/variants/components/QueryPresets/SetProperties.vue
🧰 Additional context used
🪛 Ruff
backend/variants/models/maintenance.py

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

🔇 Additional comments (48)
backend/varannos/urls.py (6)

7-11: LGTM: Improved URL pattern for VarAnnoSetListView

The update from url() to path() simplifies the URL pattern and improves readability. The explicit uuid type for the project parameter adds type safety. This change aligns with Django's recommended practices for URL routing.


12-16: LGTM: Enhanced URL pattern for VarAnnoSetDetailView

The transition from url() to path() simplifies the URL pattern and enhances readability. The explicit uuid type for the varannoset parameter provides improved type safety. This update is in line with Django's best practices for URL configuration.


22-26: LGTM: Optimized API URL pattern for VarAnnoSetListCreateApiView

The shift from url() to path() simplifies the API URL pattern and improves its readability. The explicit uuid type for the project parameter enhances type safety. This modification aligns with Django's best practices for API URL configuration.


27-31: LGTM: Refined API URL pattern for VarAnnoSetRetrieveUpdateDestroyApiView

The update from url() to path() simplifies the API URL pattern and enhances its readability. The explicit uuid type for the varannoset parameter provides improved type safety. This change adheres to Django's recommended practices for API URL configuration.


32-36: LGTM: Improved API URL pattern for VarAnnoSetEntryListCreateApiView

The transition from url() to path() simplifies the API URL pattern and enhances its readability. The explicit uuid type for the varannoset parameter adds type safety. This update aligns with Django's best practices for API URL configuration.


Line range hint 1-46: Overall improvements in URL configurations

The changes in this file consistently update all URL patterns from url() to path(), which aligns with Django's modern best practices. This improves readability and maintainability of the URL configurations. The consistent use of uuid type for parameters adds type safety throughout the file.

To ensure these changes don't introduce any regressions, please verify:

  1. That all related views correctly handle the uuid parameters.
  2. That any existing tests for these URLs have been updated to use the new path format.
  3. That any reverse URL lookups in the codebase use the correct parameter types.

You can use the following script to check for potential issues:

✅ Verification successful

URL Configuration Updates Verified

All URL patterns have been successfully updated from url() to path(), and there are no remaining instances of the deprecated url() function in the codebase. Reverse lookups in tests are correctly referencing the updated URL patterns, ensuring consistency and compatibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential issues related to URL pattern changes

# Test: Search for reverse lookups of these URLs
echo "Checking reverse lookups:"
rg "reverse\(.*?varannos:(varannoset|api-varannoset|api-varannosetentry)"

# Test: Search for any remaining uses of url() function
echo "Checking for remaining url() usage:"
rg "from django\.conf\.urls import url" --type python

# Test: Check if view functions are expecting UUID parameters
echo "Checking view functions:"
rg "def .*(project|varannoset|varannosetentry):" --type python

Length of output: 731


Script:

#!/bin/bash
# Description: Check for potential issues related to URL pattern changes

# Test: Search for reverse lookups of these URLs
echo "Checking reverse lookups:"
rg "reverse\(.*?varannos:(varannoset|api-varannoset|api-varannosetentry)"

# Test: Search for any remaining uses of url() function
echo "Checking for remaining url() usage:"
rg "from django\.conf\.urls import url" --type py

# Test: Check if view functions are expecting UUID parameters
echo "Checking view functions:"
rg "def .*(project|varannoset|varannosetentry):" --type py

Length of output: 978

backend/cases/urls.py (4)

1-5: LGTM: Imports and app configuration are correct

The imports have been updated to use path from django.urls, which is consistent with the changes made in the URL patterns. The app configuration is correctly set.


6-12: LGTM: UI URL pattern updated correctly

The UI URL pattern has been successfully updated to use the path() function with a UUID converter for the project parameter. This change aligns with Django's best practices for URL routing.


14-80: LGTM: AJAX URL patterns updated consistently

All AJAX URL patterns have been successfully updated to use the path() function with appropriate UUID converters. The view references consistently use views_ajax, maintaining a clear separation between AJAX and API views.


Line range hint 1-156: Overall improvement with minor inconsistencies

The update from url() to path() for all URL patterns is a significant improvement, aligning with Django's best practices. The consistent use of UUID converters for various parameters ensures type safety and consistency across all patterns.

The main areas of improvement are:

  1. Consistent use of API views in the api_urlpatterns section.
  2. Correct route prefixing for all API patterns.

Once these issues are addressed, the URL routing in this file will be both modern and consistent.

After making the suggested changes, please run the following script to ensure all URL patterns are correctly formatted:

#!/bin/bash
# Description: Verify URL pattern consistency

# Test: Check if all URL patterns use path() and have correct prefixes
rg --type python '^[^#]*path\(' backend/cases/urls.py

# Test: Ensure all view references match their respective URL pattern type (ui, ajax, api)
rg --type python 'view=views(_ajax|_api)?' backend/cases/urls.py
backend/variants/models/maintenance.py (2)

122-134: SQL_OUTER command looks good

The SQL_OUTER command is well-structured and follows best practices:

  • It safely drops the existing view if it exists.
  • Creates the materialized view with a placeholder for the inner query.
  • Adds appropriate indexes for performance optimization.

Good job on separating the outer and inner SQL commands for better maintainability.


114-188: Overall, well-implemented functionality for managing SmallVariantSummary

The new functions and SQL commands for managing the SmallVariantSummary materialized view are well-implemented. They provide a robust solution for creating, dropping, and populating the view with appropriate data aggregation and exclusion logic.

Key strengths:

  1. Clear and purposeful function implementations.
  2. Well-structured SQL commands with good use of CTEs and aggregations.
  3. Proper use of transactions for data consistency.

Minor suggestions for improvement have been provided in previous comments, mainly focusing on code readability by combining nested with statements.

Great job on implementing this feature!

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

utils/docker/Dockerfile (5)

Line range hint 187-224: Approve overall changes to the Dockerfile.

The remaining parts of the Dockerfile have been kept consistent with the previous version, which is good for maintaining stability in the build process. The updates made to base images, dependency versions, and added files are well-integrated into the existing structure.


42-42: Approve Python base image update with a note on dependency compatibility.

The update to Python 3.11 is a good move for potential performance improvements and access to new features. However, it's crucial to ensure all dependencies are compatible with this version.

Please run the following script to check for any potential compatibility issues:

#!/bin/bash
# Description: Check for Python version compatibility issues in dependencies

# Test: Look for any version constraints in Pipfile that might conflict with Python 3.11
grep -n "python_version" backend/Pipfile

# Test: Check if any dependencies explicitly specify Python version < 3.11
grep -nR "python_version < '3.11'" backend/

185-186: Approve jsrender JavaScript additions with a request for usage verification.

The addition of jsrender JavaScript files (jsrender.min.js and jsrender.min.js.map) can provide powerful templating capabilities for the frontend. However, it's important to verify that jsrender is actually being used in the project and that its addition is intentional.

Please run the following script to check for jsrender usage in the project:

#!/bin/bash
# Description: Check for jsrender usage in the project

# Test: Look for jsrender imports or usage in JavaScript files
grep -nR "jsrender" frontend/src/

# Test: Check for jsrender-specific syntax in HTML templates
grep -nR "{{:" frontend/src/

59-66: Approve PostgreSQL client update with a note on server compatibility.

Updating the PostgreSQL client to version 14 is a good practice for maintaining compatibility with newer PostgreSQL servers. However, it's important to ensure this version is compatible with the PostgreSQL server being used in the project.

Please run the following script to check the PostgreSQL server version used in the project:

#!/bin/bash
# Description: Check PostgreSQL server version compatibility

# Test: Look for PostgreSQL version specification in project configuration
grep -nR "POSTGRES_VERSION" .

# Test: Check for any hardcoded PostgreSQL version numbers in configuration files
grep -nR "postgresql-[0-9]*" .

Line range hint 7-7: Approve Node.js base image addition with a note on dependency compatibility.

The addition of the node:20-slim base image is a good choice for reducing image size and potential security vulnerabilities. However, it's crucial to ensure all Node.js dependencies are compatible with version 20.

Please run the following script to check for any potential compatibility issues with Node.js 20:

✅ Verification successful

Node.js dependency compatibility confirmed.

All dependencies are compatible with Node.js 20, ensuring the node:20-slim base image is appropriate.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for Node.js version compatibility issues in dependencies

# Test: Look for any engine constraints in package.json that might conflict with Node.js 20
grep -n '"engines"' frontend/package.json -A 5

# Test: Check if any dependencies explicitly specify Node.js version < 20
grep -nR '"node":' frontend/package.json frontend/package-lock.json | grep -v '"node": "20'

Length of output: 685


Script:

#!/bin/bash
# Description: Check for Node.js version compatibility issues in dependencies

# Test 1: Look for any engine constraints in package.json that might conflict with Node.js 20
grep -n '"engines"' frontend/package.json -A 5

# Test 2: Check if any dependencies explicitly specify a Node.js version less than 20
grep -nR '"node":' frontend/package.json frontend/package-lock.json | grep -v '"node": "20"'

Length of output: 65693


Script:

#!/bin/bash
# Description: Identify dependencies that explicitly restrict Node.js versions below 20

# Test 1: Look for any engine constraints in package.json that exclude Node.js 20
grep -n '"engines"' frontend/package.json -A 10 | grep -E '"node"\s*:\s*".*<\s*20'

# Test 2: Check if any dependencies in package-lock.json explicitly specify Node.js versions less than 20
grep -nR '"node"' frontend/package-lock.json | grep -E '"node"\s*:\s*".*<\s*20'

Length of output: 166

frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (4)

Line range hint 14-22: LGTM: New API endpoint properties added

The addition of lookupGeneApiEndpoint and lookupGenePanelApiEndpoint properties with default values is a good practice. It allows for easier configuration and maintenance of API endpoints, enhancing the component's flexibility.


Line range hint 49-66: LGTM: Improved panel loading with pagination support

The loadPanelPage function has been enhanced to use async/await syntax and now supports recursive loading of additional pages. This improvement ensures all panels are fetched, making the data retrieval more robust and complete.


310-314: LGTM: Template improvements for accessibility and functionality

The addition of an ID to the confidence select element (genomicsEnglandConfidence) improves accessibility and testability. The update to the @select event handler for the Multiselect component ensures correct functionality.


Line range hint 1-399: Overall assessment: Significant improvements with minor suggestions

This review has covered the major changes to the GenesRegionsPane.vue component. The modifications enhance the component's functionality, particularly in handling gene panels and API interactions. The code structure and use of async/await have improved readability and error handling in several functions.

Key improvements include:

  1. Addition of configurable API endpoints
  2. Enhanced panel loading with pagination support
  3. Improved gene batch validation with panel support
  4. Template improvements for accessibility and functionality

While the changes are generally positive, a few minor suggestions have been made to further improve reactivity handling and error management. These small adjustments will contribute to making the component more robust and maintainable.

backend/varfish/users/management/commands/initdev.py (2)

Line range hint 91-116: LGTM! Proper handling of new data_create argument.

The changes in the handle method effectively integrate the new functionality for creating and running import jobs based on the data_create argument. The use of transaction.atomic() ensures data consistency, and the error handling and success messages are well-implemented.


285-285: LGTM! Improved naming consistency.

The renaming of app_name to plugin_name in the app_settings.set() call improves naming consistency without changing the functionality.

backend/variants/tests/test_views_ajax_presets.py (3)

842-851: Approve changes and commend good practice

The simplification of the test method is consistent with the changes made in other classes, improving overall test readability and maintainability.

It's great to see that you've included an assertion to check the PresetSet object count after the API call. This ensures that the API not only returns the correct response but also performs the expected database operation. This is a good practice that enhances the test's effectiveness.


861-872: Approve changes and commend comprehensive implementation

The changes in this test class are excellent. The simplification of the test method improves readability, and the addition of PresetSet count assertions both before and after the API call ensures a thorough test of the API's behavior.

This implementation serves as a great example for the other test classes. It not only checks the API response but also verifies the database state before and after the operation. Consider applying this pattern consistently across all similar test classes in this file for maximum effectiveness and consistency.


3-3: Verify the impact of the base class change

The base class has been changed from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is likely related to the upgrade to sodar core v1 mentioned in the PR objectives.

To ensure this change doesn't introduce any unintended side effects, please run the following command to check for any other occurrences of TestProjectAPIPermissionBase in the codebase:

If there are no other occurrences, this change is likely correct. However, if there are other occurrences, they may need to be updated as well for consistency.

Also applies to: 26-26

✅ Verification successful

Base class change verified successfully

No remaining occurrences of TestProjectAPIPermissionBase were found in the codebase. The switch to ProjectAPIPermissionTestBase is consistent and does not introduce any unintended side effects.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining occurrences of TestProjectAPIPermissionBase
rg "TestProjectAPIPermissionBase" --type python

Length of output: 78


Script:

#!/bin/bash
# Search for any remaining occurrences of TestProjectAPIPermissionBase with the correct file type
rg "TestProjectAPIPermissionBase" --type py

Length of output: 43

backend/variants/tests/test_permissions_ajax_presets.py (4)

Line range hint 17-62: LGTM! Comprehensive permission checks for frequency presets.

The TestFrequencyPresetsListCreateAjaxView class provides thorough testing for listing and creating frequency presets. It covers various user roles and their expected permissions, ensuring that the API endpoints behave correctly for different types of users.


Line range hint 64-138: LGTM! Thorough testing of CRUD operations for frequency presets.

The TestFrequencyPresetsRetrieveUpdateDestroyAjaxView class provides comprehensive testing for retrieving, updating, and deleting frequency presets. It covers all CRUD operations and ensures proper permission checks for various user roles. The approach of creating a new preset for each user in the destroy test is a good practice for test isolation.


Line range hint 167-193: LGTM! Thorough testing for cloning other frequency presets.

The TestFrequencyPresetsCloneOtherView class effectively tests the cloning of other frequency presets. It covers all necessary user roles and their permissions, ensuring that the cloning functionality works as expected and is properly secured.


Line range hint 1-1271: Overall, excellent test coverage and consistency for preset-related functionalities.

This test file provides comprehensive coverage for all preset-related API endpoints, including various preset types (frequency, impact, quality, chromosome, flags, quick presets, and preset sets) and operations (list, create, retrieve, update, destroy, and clone). The consistent structure across all test classes ensures that each endpoint is thoroughly tested for proper functionality and security.

Key strengths:

  1. Comprehensive permission checks for different user roles
  2. Consistent test structure across all preset types
  3. Thorough testing of CRUD operations and cloning functionalities
  4. Good test isolation, especially in destroy tests

While the current implementation is solid, consider the earlier suggestion about reducing code duplication through a base test class or parameterized tests. This would enhance maintainability and make it easier to add new preset types or test cases in the future.

Overall, this test file significantly contributes to the robustness and security of the preset-related features in the application.

backend/cases_import/models/executors.py (1)

Line range hint 1-1000: Overall, the changes improve code organization and consistency.

The modifications in this file, particularly the update to _build_fs_options and the addition of _run_create_or_update, enhance the code structure and maintainability. The change from "app_name" to "plugin_name" aligns with what seems to be a broader refactoring effort. The new _run_create_or_update method encapsulates complex logic in a clear and organized manner.

While these changes are positive, there's room for further improvement in error handling and logging, as suggested earlier. Additionally, it's crucial to ensure that the "app_name" to "plugin_name" change is consistent across the entire codebase to prevent any potential issues.

backend/seqvars/tests/test_permissions_api.py (2)

1-2: LGTM: Imports look good

The imports seem appropriate for the test file. The use of ProjectAPIPermissionTestBase from projectroles.tests.test_permissions_api is correct for testing API permissions.


Line range hint 205-355: Consider creating a base test class for common CRUD operations

The TestQueryPresetsVersionSetViewSet class has a very similar structure to TestQueryPresetsSetViewSet and other test classes in this file. To reduce code duplication and improve maintainability, consider creating a base test class that implements the common CRUD test methods. Each specific test class could then inherit from this base class and only implement unique test cases or override methods as needed.

This approach would significantly reduce code duplication across your test classes and make it easier to maintain and extend your test suite.

backend/importer/urls.py (3)

4-4: Import statement updated correctly to use path()

The import statement has been updated from django.conf.urls.url to django.urls.path, aligning with Django's recommendations since url() is deprecated in favor of path().


11-13: UI URL patterns converted to path() with UUID converters

The UI URL patterns have been correctly updated to use path() with <uuid:...> converters. This enhances readability and ensures that only valid UUIDs are accepted as parameters.


20-86: API URL patterns modernized using path() and UUID converters

All API URL patterns have been successfully migrated from url() to path(), utilizing <uuid:...> converters for route parameters. This not only modernizes the URL configurations but also enforces parameter validation by ensuring that only valid UUIDs are matched.

backend/svs/urls.py (3)

2-2: Import statements updated appropriately

The import now includes path and re_path from django.urls, which is correct for the migration from url().


11-81: URL patterns migrated successfully to path()

The URL patterns have been properly updated to use path() with appropriate path converters like <uuid:project> and <uuid:job>, enhancing readability and maintainability.


133-140: Correct use of re_path() for regex patterns

The re_path() function is appropriately used for patterns that require regular expressions, such as the worker and tracks URLs. This maintains the necessary flexibility for these patterns.

backend/config/urls.py (5)

29-29: Home URL pattern updated correctly

Using path() for the home URL simplifies the routing and adheres to modern Django practices.


36-70: URL patterns successfully updated to use path()

The switch from url() to path() for these application URL patterns is appropriate. Since these patterns are straightforward and do not require regex matching, path() is the suitable choice.


94-95: Correct usage of re_path() for regex URL patterns

Updating the proxy URL patterns to re_path() ensures that the regex expressions are properly handled, maintaining the expected routing behavior for these endpoints.

Also applies to: 102-103, 110-111, 117-118, 124-125, 132-133, 139-140


182-193: Error handling routes updated appropriately

Switching to path() for the error handling routes simplifies the URL patterns and is suitable for these static paths.


198-198: Debug toolbar URL pattern updated correctly

Using path() for the debug toolbar URL aligns with standard practices and ensures proper functionality of the debugging tools.

backend/variants/urls/__init__.py (2)

355-358: Ensure category parameter validation matches previous constraints

The previous comment regarding the category parameter validation is still applicable. The use of <str:category> in the path() function allows more permissive inputs than the original regex pattern. To maintain the original input validation, consider using re_path() with the original regex.


12-450: Successful migration to path() with appropriate path converters

The URL patterns have been successfully updated from url() with regex patterns to path() with path converters. This enhances readability and aligns with Django's recommended practices. All parameters are correctly typed using <uuid:...>, ensuring proper URL matching and data integrity.

backend/config/settings/base.py (2)

80-80: Addition of 'social_django' to THIRD_PARTY_APPS

Including 'social_django' in THIRD_PARTY_APPS is appropriate for enabling OpenID Connect (OIDC) authentication.


438-438: Simplification of ADMIN_URL format

Updating ADMIN_URL to "admin/" simplifies the URL configuration and aligns with Django's recommended practices.

Comment on lines 82 to 152
api_urlpatterns = [
url(
regex=r"^api/case/count/(?P<project>[0-9a-f-]+)/?$",
path(
route="api/case/count/<uuid:project>/",
view=views_api.CaseCountApiView.as_view(),
name="api-case-count",
),
url(
regex=r"^api/case/list/(?P<project>[0-9a-f-]+)/?$",
path(
route="api/case/list/<uuid:project>/",
view=views_api.CaseListApiView.as_view(),
name="api-case-list",
),
url(
regex=r"^api/case/retrieve-update-destroy/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case/retrieve-update-destroy/<uuid:case>/",
view=views_api.CaseRetrieveUpdateDestroyApiView.as_view(),
name="api-case-retrieveupdatedestroy",
),
url(
regex=r"^api/case-comment/list-create/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-comment/list-create/<uuid:case>/",
view=views_api.CaseCommentListCreateApiView.as_view(),
name="api-casecomment-listcreate",
),
url(
regex=r"^ajax/case-comment/retrieve-update-destroy/(?P<casecomment>[0-9a-f-]+)/?$",
path(
route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
view=views_api.CaseCommentRetrieveUpdateDestroyApiView.as_view(),
name="api-casecomment-retrieveupdatedestroy",
),
url(
regex=r"^api/case-phenotype-terms/list-create/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-phenotype-terms/list-create/<uuid:case>/",
view=views_api.CasePhenotypeTermsListCreateApiView.as_view(),
name="api-casephenotypeterms-listcreate",
),
url(
regex=r"^api/case-phenotype-terms/retrieve-update-destroy/(?P<casephenotypeterms>[0-9a-f-]+)/?$",
path(
route="api/case-phenotype-terms/retrieve-update-destroy/<uuid:casephenotypeterms>/",
view=views_api.CasePhenotypeTermsRetrieveUpdateDestroyApiView.as_view(),
name="api-casephenotypeterms-retrieveupdatedestroy",
),
url(
regex=r"^api/annotation-release-info/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/annotation-release-info/list/<uuid:case>/",
view=views_api.AnnotationReleaseInfoApiView.as_view(),
name="api-annotationreleaseinfo-list",
),
url(
regex=r"^api/sv-annotation-release-info/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/sv-annotation-release-info/list/<uuid:case>/",
view=views_api.SvAnnotationReleaseInfoApiView.as_view(),
name="api-svannotationreleaseinfo-list",
),
url(
regex=r"^api/case-gene-annotation/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-gene-annotation/list/<uuid:case>/",
view=views_ajax.CaseGeneAnnotationListAjaxView.as_view(),
name="api-casegeneannotation-list",
),
url(
regex=r"^api/case-alignment-stats/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-alignment-stats/list/<uuid:case>/",
view=views_ajax.CaseAlignmentStatsListAjaxView.as_view(),
name="api-casealignmentstats-list",
),
url(
regex=r"^api/case-variant-stats/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-variant-stats/list/<uuid:case>/",
view=views_ajax.SampleVariantStatisticsListAjaxView.as_view(),
name="api-casevariantstats-list",
),
url(
regex=r"^api/case-relatedness/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-relatedness/list/<uuid:case>/",
view=views_ajax.PedigreeRelatednessListAjaxView.as_view(),
name="api-caserelatedness-list",
),
url(
regex=r"^api/user-and-global-settings/?$",
path(
route="api/user-and-global-settings/",
view=views_api.UserAndGlobalSettingsView.as_view(),
name="api-userandglobalsettings",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Resolve remaining inconsistencies in API URL patterns

Several API URL patterns still reference views_ajax and use the ajax/ prefix instead of views_api and api/. Please address the following inconsistencies to ensure uniformity across all API endpoints:

  1. Update view references from views_ajax to views_api:

    -        view=views_ajax.CaseListAjaxView.as_view(),
    +        view=views_api.CaseListApiView.as_view(),
    
    -        view=views_ajax.CaseRetrieveUpdateDestroyAjaxView.as_view(),
    +        view=views_api.CaseRetrieveUpdateDestroyApiView.as_view(),
    
    -        view=views_ajax.CaseCommentListCreateAjaxView.as_view(),
    +        view=views_api.CaseCommentListCreateApiView.as_view(),
    
    -        view=views_ajax.CaseCommentRetrieveUpdateDestroyAjaxView.as_view(),
    +        view=views_api.CaseCommentRetrieveUpdateDestroyApiView.as_view(),
    
    -        view=views_ajax.CasePhenotypeTermsListCreateAjaxView.as_view(),
    +        view=views_api.CasePhenotypeTermsListCreateApiView.as_view(),
    
    -        view=views_ajax.CasePhenotypeTermsRetrieveUpdateDestroyAjaxView.as_view(),
    +        view=views_api.CasePhenotypeTermsRetrieveUpdateDestroyApiView.as_view(),
    
    -        view=views_ajax.AnnotationReleaseInfoAjaxView.as_view(),
    +        view=views_api.AnnotationReleaseInfoApiView.as_view(),
    
    -        view=views_ajax.SvAnnotationReleaseInfoAjaxView.as_view(),
    +        view=views_api.SvAnnotationReleaseInfoApiView.as_view(),
    
    -        view=views_ajax.CaseGeneAnnotationListAjaxView.as_view(),
    +        view=views_api.CaseGeneAnnotationListApiView.as_view(),
    
    -        view=views_ajax.ProjectUserPermissionsAjaxView.as_view(),
    +        view=views_api.ProjectUserPermissionsApiView.as_view(),
    
    -        view=views_ajax.CaseAlignmentStatsListAjaxView.as_view(),
    +        view=views_api.CaseAlignmentStatsListApiView.as_view(),
    
    -        view=views_ajax.SampleVariantStatisticsListAjaxView.as_view(),
    +        view=views_api.SampleVariantStatisticsListApiView.as_view(),
    
    -        view=views_ajax.PedigreeRelatednessListAjaxView.as_view(),
    +        view=views_api.PedigreeRelatednessListApiView.as_view(),
  2. Fix route prefixes from ajax/ to api/:

    -        route="ajax/case/list/<uuid:project>/",
    +        route="api/case/list/<uuid:project>/",
    
    -        route="ajax/case/retrieve-update-destroy/<uuid:case>/",
    +        route="api/case/retrieve-update-destroy/<uuid:case>/",
    
    -        route="ajax/case-comment/list-create/<uuid:case>/",
    +        route="api/case-comment/list-create/<uuid:case>/",
    
    -        route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
    +        route="api/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
    
    -        route="ajax/case-phenotype-terms/list-create/<uuid:case>/",
    +        route="api/case-phenotype-terms/list-create/<uuid:case>/",
    
    -        route="ajax/case-phenotype-terms/retrieve-update-destroy/<uuid:casephenotypeterms>/",
    +        route="api/case-phenotype-terms/retrieve-update-destroy/<uuid:casephenotypeterms>/",
    
    -        route="ajax/annotation-release-info/list/<uuid:case>/",
    +        route="api/annotation-release-info/list/<uuid:case>/",
    
    -        route="ajax/sv-annotation-release-info/list/<uuid:case>/",
    +        route="api/sv-annotation-release-info/list/<uuid:case>/",
    
    -        route="ajax/case-gene-annotation/list/<uuid:case>/",
    +        route="api/case-gene-annotation/list/<uuid:case>/",
    
    -        route="ajax/user-permissions/<uuid:project>/",
    +        route="api/user-permissions/<uuid:project>/",
    
    -        route="ajax/case-alignment-stats/list/<uuid:case>/",
    +        route="api/case-alignment-stats/list/<uuid:case>/",
    
    -        route="ajax/case-variant-stats/list/<uuid:case>/",
    +        route="api/case-variant-stats/list/<uuid:case>/",
    
    -        route="ajax/case-relatedness/list/<uuid:case>/",
    +        route="api/case-relatedness/list/<uuid:case>/",
    
    -        route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
    +        route="api/case-comment/retrieve-update-destroy/<uuid:casecomment>/",

Ensure that all instances of views_ajax are replaced with views_api and that all route prefixes use api/ instead of ajax/. This will maintain consistency and adhere to the API routing standards established in the project.

🔗 Analysis chain

Fix inconsistencies in API URL patterns

While the update to path() functions is correct, there are several inconsistencies in the API URL patterns:

  1. Some patterns are using AJAX views instead of API views.
  2. One route is incorrectly prefixed with "ajax" instead of "api".

Please apply the following changes:

  1. Update view references:

    • Line 129: Change to view=views_api.CaseGeneAnnotationListApiView.as_view()
    • Line 134: Change to view=views_api.CaseAlignmentStatsListApiView.as_view()
    • Line 139: Change to view=views_api.SampleVariantStatisticsListApiView.as_view()
    • Line 144: Change to view=views_api.PedigreeRelatednessListApiView.as_view()
  2. Fix route prefix:

    • Line 104: Change route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/" to route="api/case-comment/retrieve-update-destroy/<uuid:casecomment>/"

Apply these changes to ensure consistency across all API URL patterns:

-        view=views_ajax.CaseGeneAnnotationListAjaxView.as_view(),
+        view=views_api.CaseGeneAnnotationListApiView.as_view(),
-        view=views_ajax.CaseAlignmentStatsListAjaxView.as_view(),
+        view=views_api.CaseAlignmentStatsListApiView.as_view(),
-        view=views_ajax.SampleVariantStatisticsListAjaxView.as_view(),
+        view=views_api.SampleVariantStatisticsListApiView.as_view(),
-        view=views_ajax.PedigreeRelatednessListAjaxView.as_view(),
+        view=views_api.PedigreeRelatednessListApiView.as_view(),
-        route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
+        route="api/case-comment/retrieve-update-destroy/<uuid:casecomment>/",

After making these changes, please run the following script to verify that all API views exist and are correctly referenced:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify API views exist and are correctly referenced

# Test: Check if all API views exist
rg --type python -g 'views_api.py' '(class\s+\w+ApiView|def\s+\w+_api_view)'

# Test: Ensure all API URL patterns use views_api
rg --type python 'path\(' backend/cases/urls.py | rg 'api/' | rg 'view=views_api'

Length of output: 184


Script:

#!/bin/bash
# Description: Verify API views exist and are correctly referenced

# Test: Check if all API views exist in views_api.py
rg --type py -g 'views_api.py' '(class\s+\w+ApiView|def\s+\w+_api_view)'

# Test: Ensure all API URL patterns use views_api in backend/cases/urls.py
rg 'path\(' backend/cases/urls.py | rg 'api/' | rg 'view=views_api'

Length of output: 3463


Script:

#!/bin/bash
# Description: Check for any remaining 'views_ajax' references and 'ajax/' route prefixes in backend/cases/urls.py

# Test: Search for 'views_ajax' in backend/cases/urls.py
rg 'views_ajax' backend/cases/urls.py

# Test: Search for 'ajax/' in route definitions within backend/cases/urls.py
rg 'route="ajax/' backend/cases/urls.py

Length of output: 2197

Comment on lines +183 to +188
def create_variants_smallvariantsummary():
"""Create the ``SmallVariantSummary`` materialized view."""

with transaction.atomic():
with connection.cursor() as cursor:
cursor.execute(SQL_OUTER % SQL_INNER)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify nested with statements and address SQL injection concern

  1. Combine the nested with statements for improved readability:
 def create_variants_smallvariantsummary():
     """Create the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute(SQL_OUTER % SQL_INNER)
  1. Regarding the SQL injection concern mentioned in a previous review:
    The current implementation is safe as both SQL_OUTER and SQL_INNER are hardcoded within the file. There's no risk of SQL injection in this case. However, if in the future any part of these queries becomes dynamic or user-influenced, consider using parameterized queries for better security practices.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def create_variants_smallvariantsummary():
"""Create the ``SmallVariantSummary`` materialized view."""
with transaction.atomic():
with connection.cursor() as cursor:
cursor.execute(SQL_OUTER % SQL_INNER)
def create_variants_smallvariantsummary():
"""Create the ``SmallVariantSummary`` materialized view."""
with transaction.atomic(), connection.cursor() as cursor:
cursor.execute(SQL_OUTER % SQL_INNER)
🧰 Tools
🪛 Ruff

186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

Comment on lines +114 to +119
def drop_variants_smallvariantsummary():
"""Drop the ``SmallVariantSummary`` materialized view."""

with transaction.atomic():
with connection.cursor() as cursor:
cursor.execute("DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary")
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify nested with statements

As suggested in a previous review, we can improve readability by combining the nested with statements:

 def drop_variants_smallvariantsummary():
     """Drop the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute("DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary")

This change maintains the same functionality while simplifying the code structure.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def drop_variants_smallvariantsummary():
"""Drop the ``SmallVariantSummary`` materialized view."""
with transaction.atomic():
with connection.cursor() as cursor:
cursor.execute("DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary")
def drop_variants_smallvariantsummary():
"""Drop the ``SmallVariantSummary`` materialized view."""
with transaction.atomic(), connection.cursor() as cursor:
cursor.execute("DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary")
🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

@@ -51,7 +51,7 @@ def _setUpExecutor(self, action, fac_kwargs=None):

app_settings = AppSettingAPI()
app_settings.set(
app_name="cases_import",
plugin_name="cases_import",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Change app_name to plugin_name Requires Comprehensive Refactor

The term app_name is extensively used throughout the codebase. Renaming it to plugin_name in a single location without updating all its occurrences can lead to inconsistencies and potential bugs. A thorough refactor is necessary to ensure that all instances of app_name are consistently updated to plugin_name.

🔗 Analysis chain

LGTM! Verify consistent usage across the codebase.

The change from app_name to plugin_name in the app_settings.set() call looks good. This likely reflects a terminology change in the AppSettingAPI.

To ensure consistency, let's check for any remaining uses of app_name in similar contexts:


Further Verification Needed: Assess app_name Usage Throughout the Codebase

The app_name identifier is used extensively across multiple files. To ensure that changing it to plugin_name won't introduce inconsistencies or issues, we need to verify all its usages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for remaining instances of 'app_name' in Python files
rg 'app_settings\.set\(.*app_name' -t py

# Search for all instances of 'app_name' in Python files
fd --type f --extension py | xargs rg 'app_name'

Length of output: 2710


Script:

#!/bin/bash
# Search for function definitions with 'app_name' as a parameter
ast-grep --lang python --pattern $'def $_($_, app_name, $_): $$$'

# Search for function calls passing 'app_name' as an argument
rg 'app_name\s*=' -t py

# Search for variable assignments to 'app_name'
rg 'app_name\s*=' -t py

Length of output: 4636

@@ -136,7 +136,7 @@ def __init__(self, project: Project):
def _build_fs_options(self, project: Project) -> FileSystemOptions:
"""Build `FileSystemOptions` from project settings."""
app_settings = AppSettingAPI()
kwargs = {"app_name": "cases_import", "project": project}
kwargs = {"plugin_name": "cases_import", "project": project}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent Usage of "app_name" and "plugin_name".

The change from "app_name" to "plugin_name" in executors.py appears to be isolated. However, numerous instances of "app_name" still exist across the codebase, which may lead to inconsistencies or runtime issues.

Affected Files:

  • backend/variants/variant_stats.py
  • backend/variants/migrations/0110_drop_variant_summary.py
  • backend/varannos/urls.py
  • backend/varfish/vueapp/urls.py
  • backend/variants/templatetags/variants_tags.py
  • (and others as listed in the shell script output)

It is recommended to ensure that the renaming is consistently applied throughout the codebase to maintain coherence and prevent potential bugs.

🔗 Analysis chain

LGTM. Verify usage of "plugin_name" across the codebase.

The change from "app_name" to "plugin_name" looks good and likely aligns with updated naming conventions. However, it's important to ensure this change is consistent throughout the codebase.

To verify the impact and consistency of this change, please run the following command:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of "app_name" in Python files
echo "Occurrences of 'app_name':"
rg 'app_name' --glob '*.py'

# Search for any remaining instances of "plugin_name" in Python files
echo "Occurrences of 'plugin_name':"
rg 'plugin_name' --glob '*.py'

Length of output: 3208

@@ -1,4 +1,4 @@
from django.conf.urls import url
from django.urls import path
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Import re_path for regex URL patterns

To maintain strict parameter validation for URL patterns that require regex matching, consider importing re_path from django.urls. This allows you to use regular expressions in URL patterns where necessary.

Apply this diff to include re_path in the imports:

-from django.urls import path
+from django.urls import path, re_path
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from django.urls import path
from django.urls import path, re_path

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch from 7c55f6e to a938b03 Compare October 17, 2024 12:51
@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch 5 times, most recently from 609d0b3 to 42f8b4e Compare October 22, 2024 09:12
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 12

🧹 Outside diff range and nitpick comments (26)
backend/varfish/vueapp/urls.py (1)

7-11: LGTM: Improved URL pattern definition

The URL pattern has been successfully updated to use path() instead of url(), which improves readability and follows Django's recommended practices. The str path converter is appropriately used for the setting_name parameter.

Consider adding a trailing comma after the last argument for consistency with multi-line function calls:

 path(
     "ajax/user-setting/<str:setting_name>/",
     view=views_ajax.UserSettingView.as_view(),
-    name="user-setting",
+    name="user-setting",
 ),
backend/variants/urls/annos.py (2)

10-14: LGTM: URL pattern updated correctly with a minor suggestion.

The change from url() to path() is correct and improves readability. The use of the uuid path converter for the case parameter is appropriate.

For consistency with Django's style guide, consider removing the trailing slash from the URL pattern:

-        "ajax/smallvariant/user-annotated-case/<uuid:case>/",
+        "ajax/smallvariant/user-annotated-case/<uuid:case>",

This change aligns with Django's recommendation to avoid trailing slashes in URL patterns when using path().


Line range hint 1-21: Summary: URL routing updated to use path() function.

The changes in this file are part of a project-wide update to modernize URL routing. The transition from url() to path() improves code readability and leverages Django's path converters. These changes maintain backwards compatibility while aligning with current Django best practices.

Consider applying similar updates to any remaining files in the project that still use the url() function for consistency across the codebase.

backend/seqmeta/tests/test_permissions.py (1)

Incomplete Refactoring of Permission Test Base Classes

Several files are still using TestProjectPermissionBase instead of the updated ProjectPermissionTestBase. Please update all instances to ensure consistency across the project.

  • backend/variants/tests/helpers.py
  • backend/varannos/tests/test_permissions.py
  • backend/genepanels/tests/test_permissions.py
  • backend/cases/tests/test_permissions.py
  • backend/cases/tests/test_views.py
  • backend/beaconsite/tests/test_permissions.py
🔗 Analysis chain

Line range hint 1-43: Overall, these changes look good. Verify project-wide impact.

The modifications to this file are part of a larger refactoring effort to standardize the permission testing framework across the project. The changes are minimal and don't affect the actual test implementations, which is a good indication of backwards compatibility.

To ensure these changes haven't introduced any unintended side effects, run the following script:

If all tests pass, it confirms that the refactoring has been successfully implemented without breaking existing functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify overall project test suite

# Test: Run the entire test suite and check for any failures
pytest

Length of output: 1972

frontend/src/varfish/components/FilterForm/DevPane.vue (1)

87-87: Remove unnecessary change to input id

The id attribute of the input element has been changed from "customSwitch1" to "customSwitch1", which is effectively a non-change. To maintain clarity in the diff and avoid confusion, it's recommended to revert this line to its original state.

Apply this change:

-            id="customSwitch1"
+            id="customSwitch1"
frontend/src/variants/components/FilterForm/FlagsPane.vue (1)

18-18: Approved: Improved null check for querySettings

The addition of the null and undefined check for querySettings enhances the component's robustness by preventing rendering when querySettings is not a valid object. This change aligns well with similar updates in other components and helps prevent potential errors.

Consider using the shorter v-if="querySettings != null" syntax, which checks for both null and undefined:

-    v-if="querySettings !== null && querySettings !== undefined"
+    v-if="querySettings != null"

This achieves the same result with a more concise expression.

frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (2)

Line range hint 78-91: LGTM: Improved template structure

The reordering of v-if and class attributes in the v-list-subheader elements enhances readability by placing the conditional first. This is a good practice.

Consider applying this pattern consistently across the entire codebase for better maintainability.


117-118: LGTM: Reordered props in SvFilterApp component

The reordering of props in the SvFilterApp component improves the template structure by grouping similar props together. This change enhances readability without affecting functionality.

If not already present, consider adding documentation or a style guide entry regarding the preferred order of props in component templates to maintain consistency across the project.

backend/varannos/tests/test_permissions_api.py (1)

Line range hint 58-64: Potential issue: Inconsistent user role reference.

In the test_create method, the bad_users_403 list includes self.owner_as.user. This seems inconsistent with other test methods where self.user_owner is used instead. This could lead to incorrect test results if self.owner_as is not defined or doesn't have the expected user attribute.

Consider updating the line to use self.user_owner for consistency:

bad_users_403 = [
    self.user_no_roles,
-   self.owner_as.user,
+   self.user_owner,
    self.user_delegate,
    self.user_contributor,
    self.user_guest,
]
backend/svs/urls.py (2)

133-139: Consider simplifying the re_path() pattern.

The change to re_path() is appropriate for this complex pattern. However, you can simplify the regex by removing the redundant ^ and $ anchors, as re_path() implicitly anchors the pattern:

re_path(
    r"worker/(?P<url>.*)",
    HttpProxy.as_view(
        base_url=f"{settings.WORKER_REST_BASE_URL}/public/svs/",
        ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
    ),
),

This simplification improves readability without affecting functionality.


Line range hint 140-146: Consider simplifying the re_path() pattern for consistency.

Similar to the worker proxy pattern, you can simplify this regex by removing the redundant ^ and $ anchors:

re_path(
    r"tracks/(?P<url>.*)",
    HttpProxy.as_view(
        base_url=f"{settings.WORKER_REST_BASE_URL}/public/tracks/",
        ignored_request_headers=HttpProxy.ignored_upstream_headers + ["cookie"],
    ),
),

This maintains consistency with the previous pattern and improves readability.

backend/variants/models/maintenance.py (4)

114-119: Simplify nested with statements

The function looks good overall. As suggested in the previous review, we can improve readability by combining the nested with statements:

 def drop_variants_smallvariantsummary():
     """Drop the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute("DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary")

This change maintains the same functionality while simplifying the code structure.

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


122-134: SQL_OUTER query looks good, consider adding a comment

The SQL_OUTER query is well-structured and includes necessary steps to drop the existing view, create a new one, and set up appropriate indexes.

To improve maintainability, consider adding a brief comment explaining the purpose of the %s placeholder and its relationship with SQL_INNER. For example:

SQL_OUTER = r"""
# The %s placeholder will be replaced with the SQL_INNER query to define the view's content
DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;

...
"""

This addition would make the relationship between SQL_OUTER and SQL_INNER more explicit for future maintainers.


137-180: SQL_INNER query is well-structured, consider adding comments

The SQL_INNER query is well-organized and efficiently structured. It effectively excludes certain cases based on project settings and aggregates data from the variants_smallvariant table.

To further improve readability and maintainability, consider adding brief comments to explain the purpose of each main section of the query. For example:

SQL_INNER = r"""
-- Exclude cases based on project settings
WITH excluded_case_ids AS (
    ...
)
-- Main query to aggregate variant data
SELECT
    ...
FROM (
    -- Subquery to select distinct variants per case
    SELECT DISTINCT
        ...
    FROM variants_smallvariant AS variants
    WHERE NOT EXISTS (SELECT 1 from excluded_case_ids AS e WHERE e.case_id = variants.case_id)
) AS variants_per_case
GROUP BY (release, chromosome, start, "end", bin, reference, alternative)
"""

These comments would help future maintainers quickly understand the structure and purpose of each part of the query.


183-188: Simplify nested with statements

The function looks good overall. As suggested in the previous review, we can improve readability by combining the nested with statements:

 def create_variants_smallvariantsummary():
     """Create the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute(SQL_OUTER % SQL_INNER)

This change maintains the same functionality while simplifying the code structure.

Regarding the SQL injection concern mentioned in a previous review: The current implementation is safe as both SQL_OUTER and SQL_INNER are hardcoded within the file. There's no risk of SQL injection in this case.

🧰 Tools
🪛 Ruff

186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

backend/variants/urls/presets.py (1)

Line range hint 1-166: Summary of URL pattern updates and required actions

The URL patterns in this file have been successfully updated to use the path() function, improving readability and maintainability. However, there are a few key points that need to be addressed:

  1. Implement a custom path converter (NoDigitSlugConverter) to maintain the original behavior for name parameters in clone-factory-presets URLs.
  2. Apply the custom path converter to all relevant URL patterns (FrequencyPresets, FlagsEtcPresets, ImpactPresets, QualityPresets, and ChromosomePresets).
  3. Verify the impact of changing the project parameter to UUID, ensuring all usages in the codebase are compatible with this change.

Please make these adjustments to ensure the URL routing behaves as expected and maintains backwards compatibility where necessary.

backend/variants/tests/test_permissions_ajax.py (1)

183-183: LGTM! Base class updated consistently. Consider addressing commented-out tests.

The base class has been correctly updated to ProjectAPIPermissionTestBase, maintaining consistency with the other test classes in this file.

Additionally, there are commented-out lines throughout the file related to testing unauthenticated users (401 status code). Consider addressing these commented-out tests to ensure comprehensive test coverage.

Would you like assistance in implementing or removing these commented-out tests?

frontend/src/variants/components/FilterForm/ClinvarPane.vue (1)

16-22: Approve template changes with a minor suggestion.

The template changes significantly improve the component's structure and readability. The dynamic generation of checkbox inputs based on the interpretations array is a good practice that reduces code duplication.

However, the v-if condition can be simplified for better readability:

Consider simplifying the v-if condition:

-  <div
-    v-if="querySettings !== null && querySettings !== undefined"
-    class="row p-2"
-  >
+  <div v-if="querySettings != null" class="row p-2">

This change uses the loose inequality operator (!=) which checks for both null and undefined, making the condition more concise.

frontend/src/variants/components/FilterForm/EffectPane.vue (4)

Line range hint 19-89: LGTM: Improved state management for effects and groups

The addition of buildEffectWrapper, buildGroupWrapper, and buildGroupIndeterminate functions significantly improves the component's reactivity and state management. These computed properties ensure efficient updates when the underlying data changes.

The logic for handling indeterminate states in groups is a good UX consideration.

Consider memoizing the results of these functions to optimize performance, especially if the component re-renders frequently:

import { computed, reactive } from 'vue'

const effectWrappers = reactive({})
const groupWrappers = reactive({})
const groupIndeterminates = reactive({})

// Use these in your setup function
onMounted(() => {
  for (const group of detailedEffectGroups) {
    for (const field of group.fields) {
      effectWrappers[field.id] = computed(() => buildEffectWrapper(field.id))
    }
  }

  for (const name of Object.keys(effectGroups)) {
    groupWrappers[name] = computed(() => buildGroupWrapper(name))
    groupIndeterminates[name] = computed(() => buildGroupIndeterminate(name))
  }
})

This approach would compute the wrappers only once and cache the results, potentially improving performance for large datasets.


Line range hint 91-134: LGTM: Robust form validation implementation

The addition of Vuelidate for form validation is a significant improvement:

  • The formState object with a computed property for maxExonDist ensures reactivity with querySettings.
  • Vuelidate rules are well-defined for maxExonDist.
  • Touching the form on mount ensures immediate validation.

These changes enhance data integrity and user experience.

Consider adding error handling for cases where props.querySettings is unexpectedly null or undefined:

const formState = {
  maxExonDist: computed({
    get() {
      return props.querySettings?.max_exon_dist ?? null
    },
    set(newValue) {
      if (newValue === '') {
        newValue = null
      }
      if (props.querySettings) {
        props.querySettings.max_exon_dist = newValue
      } else {
        console.warn('querySettings is null or undefined')
      }
    },
  }),
}

This change would make the component more robust against potential runtime errors.


141-143: LGTM: Improved template with conditional rendering and form validation

The template changes enhance the component's robustness and user experience:

  • Conditional rendering based on querySettings prevents potential errors.
  • Integration of Vuelidate in the maxExonDist input field improves form validation.
  • Clear error display for maxExonDist validation provides good user feedback.

Consider adding an aria-describedby attribute to the maxExonDist input for improved accessibility:

<input
  id="max-exon-dist"
  v-model.number.lazy="v$.maxExonDist.$model"
  type="number"
  class="form-control"
  placeholder="max. distance to next exon"
  :class="{
    'is-invalid': v$.maxExonDist.$error,
  }"
  :aria-describedby="v$.maxExonDist.$error ? 'max-exon-dist-error' : undefined"
/>
<div
  v-for="error of v$.maxExonDist.$errors"
  :key="error.$uid"
  class="invalid-feedback"
  :id="'max-exon-dist-error'"
>
  {{ error.$message }}
</div>

This change would improve the accessibility of the form by explicitly associating the error message with the input field.

Also applies to: 301-315


Line range hint 1-445: Overall: Significant improvements to component functionality and maintainability

The changes to this component represent a substantial improvement in several areas:

  1. Enhanced reactivity through computed properties for effects and groups.
  2. Robust form validation using Vuelidate.
  3. Improved error handling and user feedback.
  4. Better conditional rendering to prevent potential runtime errors.

These changes align well with Vue 3 best practices and modern front-end development standards.

For future enhancements, consider implementing a custom composable for managing the effects and groups logic. This could improve reusability across similar components and make the main component file more concise. For example:

// useEffectsAndGroups.js
import { reactive, computed } from 'vue'

export function useEffectsAndGroups(querySettings) {
  const effectWrappers = reactive({})
  const groupWrappers = reactive({})
  const groupIndeterminates = reactive({})

  // Implement the logic for buildEffectWrapper, buildGroupWrapper, and buildGroupIndeterminate here

  return {
    effectWrappers,
    groupWrappers,
    groupIndeterminates,
  }
}

// In your component
import { useEffectsAndGroups } from './useEffectsAndGroups'

// ...

const { effectWrappers, groupWrappers, groupIndeterminates } = useEffectsAndGroups(props.querySettings)

This approach would further improve the component's maintainability and potentially reduce duplication if similar logic is needed elsewhere in the application.

backend/cases/tests/test_views_ajax.py (1)

Line range hint 1-706: LGTM: Consistent refactoring across all test classes.

The changes in this file demonstrate a systematic refactoring effort, updating all test classes to use ProjectAPIPermissionTestBase as their base class. This consistent change across the entire file should improve the maintainability and coherence of the test suite. No functional changes were observed in the test methods, indicating that this is purely a structural improvement.

Consider adding a comment at the top of the file explaining the reason for this refactoring, which could be helpful for future developers working on this codebase.

backend/seqvars/tests/test_permissions_api.py (3)

62-62: Base class updated correctly for TestQueryPresetsSetViewSet.

The TestQueryPresetsSetViewSet class now inherits from ProjectAPIPermissionTestBase, which is consistent with the refactoring. The overall structure of the test class remains sound and follows best practices for API permission testing.

Consider implementing a parameterized test approach for user roles to reduce code duplication across test methods. This could improve maintainability and make it easier to add or modify user roles in the future.


Line range hint 356-2344: Base class updated consistently across all remaining test classes.

All test classes from TestQueryPresetsFrequencyViewSet to TestResultRowViewSet have been correctly updated to inherit from ProjectAPIPermissionTestBase. This consistent change maintains the uniformity of the test structure throughout the file.

Given the high degree of similarity between these test classes, consider creating a base test class that encapsulates common setup and test methods. This could significantly reduce code duplication and make it easier to maintain and update these tests in the future. For example:

class BaseAPIPermissionTest(ProjectAPIPermissionTestBase):
    def setUp(self):
        super().setUp()
        self.setup_common_objects()

    def setup_common_objects(self):
        # Implement in subclasses

    def test_list(self):
        # Common list test implementation

    def test_create(self):
        # Common create test implementation

    def test_retrieve(self):
        # Common retrieve test implementation

    def test_patch(self):
        # Common patch test implementation

    def test_delete(self):
        # Common delete test implementation

# Then, in each specific test class:
class TestSpecificViewSet(BaseAPIPermissionTest):
    def setup_common_objects(self):
        # Set up objects specific to this test class

    # Override any methods that need specific implementation

This approach would make the test file more DRY (Don't Repeat Yourself) and easier to maintain.


Line range hint 1-2344: Summary of changes and impact

The refactoring of this test file to use ProjectAPIPermissionTestBase as the base class for all test classes is a positive change that enhances consistency across the codebase. This update likely aligns with similar changes in other test files, indicating a broader effort to unify the permission testing framework.

Key points:

  1. Consistent base class usage improves maintainability and readability.
  2. The uniform structure across test classes facilitates easier understanding and future modifications.
  3. There's an opportunity to further optimize the code by introducing a common base test class to reduce duplication.

These changes contribute to a more robust and maintainable test suite, which is crucial for ensuring the reliability of the API's permission system.

Consider documenting the rationale behind this refactoring in the project's documentation or in a comment at the top of this file. This would help future developers understand the context and importance of these changes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7c55f6e and 42f8b4e.

⛔ Files ignored due to path filters (1)
  • backend/Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (77)
  • .github/workflows/main.yml (4 hunks)
  • backend/Makefile (1 hunks)
  • backend/Pipfile (4 hunks)
  • backend/beaconsite/tests/test_permissions.py (3 hunks)
  • backend/beaconsite/tests/test_permissions_ajax.py (2 hunks)
  • backend/beaconsite/tests/test_permissions_api.py (3 hunks)
  • backend/beaconsite/tests/test_views_ajax.py (1 hunks)
  • backend/beaconsite/urls.py (1 hunks)
  • backend/cases/tests/test_permissions.py (1 hunks)
  • backend/cases/tests/test_permissions_ajax.py (12 hunks)
  • backend/cases/tests/test_permissions_api.py (11 hunks)
  • backend/cases/tests/test_views.py (1 hunks)
  • backend/cases/tests/test_views_ajax.py (12 hunks)
  • backend/cases/urls.py (1 hunks)
  • backend/cases_analysis/tests/test_permissions_api.py (2 hunks)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_import/tests/test_permissions_api.py (1 hunks)
  • backend/cases_qc/tests/test_permissions_api.py (2 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/cohorts/migrations/0008_alter_cohort_user.py (1 hunks)
  • backend/cohorts/tests/test_permissions_ajax.py (3 hunks)
  • backend/cohorts/tests/test_permissions_api.py (3 hunks)
  • backend/cohorts/tests/test_views_ui.py (1 hunks)
  • backend/cohorts/urls.py (1 hunks)
  • backend/config/settings/base.py (5 hunks)
  • backend/config/urls.py (5 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/genepanels/tests/test_permissions.py (2 hunks)
  • backend/genepanels/urls.py (1 hunks)
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1 hunks)
  • backend/importer/urls.py (1 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/seqmeta/tests/test_permissions.py (2 hunks)
  • backend/seqmeta/urls.py (2 hunks)
  • backend/seqvars/tests/test_permissions_api.py (17 hunks)
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_presets.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_queries.py (6 hunks)
  • backend/svs/urls.py (2 hunks)
  • backend/varannos/tests/helpers.py (3 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_permissions.py (1 hunks)
  • backend/varannos/tests/test_permissions_api.py (1 hunks)
  • backend/varannos/urls.py (2 hunks)
  • backend/varfish/templates/users/login.html (1 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/varfish/users/urls.py (1 hunks)
  • backend/varfish/vueapp/urls.py (1 hunks)
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/models/maintenance.py (1 hunks)
  • backend/variants/tests/helpers.py (3 hunks)
  • backend/variants/tests/test_file_export.py (2 hunks)
  • backend/variants/tests/test_permissions_ajax.py (6 hunks)
  • backend/variants/tests/test_permissions_ajax_annos.py (1 hunks)
  • backend/variants/tests/test_permissions_ajax_presets.py (29 hunks)
  • backend/variants/tests/test_permissions_api.py (7 hunks)
  • backend/variants/tests/test_ui.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
  • backend/variants/urls/init.py (2 hunks)
  • backend/variants/urls/annos.py (1 hunks)
  • backend/variants/urls/presets.py (2 hunks)
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (1 hunks)
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4 hunks)
  • frontend/src/varfish/components/FilterForm/DevPane.vue (2 hunks)
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/EffectPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FlagsPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3 hunks)
  • frontend/src/variants/components/FilterForm/QualityPane.vue (1 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetProperties.vue (1 hunks)
  • utils/docker/Dockerfile (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • backend/varfish/templates/users/login.html
🚧 Files skipped from review as they are similar to previous changes (27)
  • backend/Makefile
  • backend/Pipfile
  • backend/beaconsite/tests/test_permissions.py
  • backend/beaconsite/tests/test_permissions_ajax.py
  • backend/beaconsite/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_views_ajax.py
  • backend/beaconsite/urls.py
  • backend/cases/tests/test_permissions.py
  • backend/cases/tests/test_permissions_ajax.py
  • backend/cases/tests/test_permissions_api.py
  • backend/cases_analysis/tests/test_permissions_api.py
  • backend/cases_import/models/executors.py
  • backend/cases_import/tests/test_models_executor.py
  • backend/cases_import/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_views_api.py
  • backend/cohorts/migrations/0008_alter_cohort_user.py
  • backend/cohorts/tests/test_permissions_ajax.py
  • backend/cohorts/tests/test_permissions_api.py
  • backend/cohorts/tests/test_views_ui.py
  • backend/cohorts/urls.py
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue
  • frontend/src/variants/components/FilterForm/QualityPane.vue
  • frontend/src/variants/components/QueryPresets/SetEditor.vue
  • frontend/src/variants/components/QueryPresets/SetProperties.vue
  • utils/docker/Dockerfile
🧰 Additional context used
🪛 Ruff
backend/variants/models/maintenance.py

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

🔇 Additional comments (205)
backend/varfish/vueapp/urls.py (2)

1-1: LGTM: Updated import statement

The import statement has been correctly updated to use path from django.urls, which is in line with Django's best practices for URL routing.


Line range hint 1-14: Overall assessment: Successful modernization of URL configuration

The changes in this file successfully modernize the URL configuration by transitioning from url() to path(). This update improves code readability and aligns with Django's current best practices. The modifications maintain the existing functionality while making the code more maintainable.

Key improvements:

  1. Updated import statement to use path from django.urls.
  2. Replaced regex pattern with a more readable path converter.
  3. Maintained consistent structure and naming conventions.

These changes are approved and contribute positively to the codebase.

backend/varfish/users/urls.py (6)

1-1: LGTM: Correct import for Django's path function.

The import statement has been updated to use path from django.urls, which is the correct approach for modern Django applications.


6-6: LGTM: Correct transition to path() for root URL.

The URL pattern for the root path has been correctly updated to use path() with an empty string as the route.


7-7: LGTM: Correct transition to path() for redirect URL.

The URL pattern for the redirect view has been properly updated to use path(). The route "~redirect/" is correct and maintains the trailing slash.


8-8: LGTM: Correct transition to path() with path converter for user detail URL.

The URL pattern for the user detail view has been correctly updated to use path() with the <str:username> path converter. This change simplifies the URL pattern while maintaining the same functionality.


9-9: LGTM: Correct transition to path() for update URL.

The URL pattern for the update view has been properly updated to use path(). The route "~update/" is correct and maintains the trailing slash.


1-9: Excellent transition to modern Django URL routing.

The changes in this file successfully update all URL patterns to use the path() function from django.urls. This transition:

  1. Aligns with modern Django best practices.
  2. Improves code readability by simplifying URL patterns.
  3. Maintains existing functionality while enhancing maintainability.

Great job on consistently applying these changes across all URL patterns in the file.

backend/variants/urls/annos.py (1)

3-3: LGTM: Import statement updated correctly.

The change from django.conf.urls to django.urls for importing path is correct and aligns with Django's best practices.

backend/cases/tests/test_views.py (2)

2-2: LGTM: Updated base class for permission testing.

The change from TestProjectPermissionBase to ProjectPermissionTestBase aligns with similar updates across other test files in the project. This consistency suggests an intentional improvement in the permission testing framework.

Also applies to: 5-5


Line range hint 8-14: Verify compatibility with new base class.

The test_entrypoint method remains unchanged. While this maintains existing test coverage, it's important to ensure that the method is still compatible with the new ProjectPermissionTestBase class and doesn't require any adjustments.

To verify the compatibility, please run the following script:

This script will help identify any new methods or patterns introduced by ProjectPermissionTestBase that might be beneficial to incorporate into the test_entrypoint method.

✅ Verification successful

Compatibility Verified. The test_entrypoint method remains compatible with ProjectPermissionTestBase and does not require any adjustments.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if ProjectPermissionTestBase introduces any new methods or attributes that should be used in test_entrypoint

# Test: Search for the base class definition and its methods
ast-grep --pattern $'class ProjectPermissionTestBase($_):
  $$$
  def $_(self, $_):
    $$$
'

# Test: Compare with the current test method implementation
rg -A 10 'def test_entrypoint' backend/cases/tests/test_views.py

Length of output: 482

backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (3)

1-5: LGTM: Migration file structure and imports are correct.

The migration file is properly structured with the correct Django version and necessary imports.


9-12: LGTM: Dependencies are correctly specified.

The migration dependencies are properly defined, ensuring that this migration runs after the necessary changes in the "bgjobs" and "importer" apps.


14-24: Verify the impact of the ForeignKey modification.

The bg_job field in the ImportCaseBgJob model is being modified with new attributes. This change looks good, but it's important to ensure that it doesn't break existing functionality or data integrity.

Key points to note:

  1. The on_delete behavior is set to CASCADE, which means related ImportCaseBgJob instances will be deleted when the referenced BackgroundJob is deleted.
  2. The related_name is set dynamically, which allows for reverse lookups from the BackgroundJob model.
  3. A help_text is added to provide context for the field's purpose.

To ensure this change doesn't negatively impact existing data or functionality, please run the following verification script:

After running these checks, please ensure that:

  1. Existing data is not unexpectedly affected.
  2. The migration can be applied and reversed without issues.
  3. Any related views or forms are updated if necessary to accommodate the field change.
backend/seqmeta/tests/test_models.py (1)

15-15: LGTM! Verify consistency across the application.

The addition of a trailing slash to the expected URL is a good practice and aligns with Django's default URL handling. This change likely reflects an update in the URL configuration or the get_absolute_url method of the EnrichmentKit model.

To ensure consistency, please run the following script to check if similar changes have been applied across the application:

This script will help identify any inconsistencies in URL patterns across the application. Please review the output and ensure that trailing slashes are used consistently where appropriate.

✅ Verification successful

URL patterns are consistent across the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in URL patterns across the application

# Test: Search for get_absolute_url methods and their return values
echo "Checking get_absolute_url methods:"
rg -n "def get_absolute_url" -A 3

# Test: Search for URL patterns in urls.py files
echo "Checking URL patterns in urls.py files:"
fd urls.py | xargs rg -n "path\(.*"

# Test: Search for reverse function calls
echo "Checking reverse function calls:"
rg -n "reverse\(.*"

Length of output: 82988

backend/variants/tests/test_permissions_ajax_annos.py (3)

7-7: LGTM! Verify consistency of base class usage.

The update of the base class to ProjectAPIPermissionTestBase is consistent with the import change and aligns with the broader refactoring effort. The unchanged implementation suggests compatibility with the new base class.

To ensure this change has been applied consistently, run the following script:

#!/bin/bash
# Description: Verify the usage of ProjectAPIPermissionTestBase as a base class across test files

# Test: Search for class definitions using ProjectAPIPermissionTestBase
rg -t py 'class \w+\(ProjectAPIPermissionTestBase\):' backend/**/tests/

Line range hint 8-24: Consider potential enhancements from the new base class.

The test implementation remains unchanged, which is good for maintaining existing functionality. However, it's worth checking if the new ProjectAPIPermissionTestBase introduces any new methods or features that could enhance or simplify this test class.

To explore potential enhancements, run the following script:

#!/bin/bash
# Description: Examine the ProjectAPIPermissionTestBase class for new methods

# Test: Retrieve the content of the file containing ProjectAPIPermissionTestBase
cat $(rg -l 'class ProjectAPIPermissionTestBase' backend)

# Note: Manually review the output to identify any new methods or features
# that could be beneficial for the TestCaseUserAnnotatedVariantsAjaxView class.

2-2: LGTM! Verify consistency across test files.

The update to import ProjectAPIPermissionTestBase aligns with the broader refactoring of the permission testing framework. This change enhances consistency and maintainability across the test suite.

To ensure this change has been applied consistently, run the following script:

backend/svs/tests/test_permissions_ajax_presets.py (3)

4-4: LGTM: Import statement updated for new base class.

The import statement has been correctly updated to import ProjectAPIPermissionTestBase from the projectroles.tests.test_permissions_api module. This change aligns with the broader refactoring effort to standardize the base classes used for permission testing across the codebase.


4-9: Overall impact: Positive step towards standardized permission testing.

The changes in this file, while minimal, represent a significant step towards standardizing the permission testing framework across the project. This refactoring effort should improve code consistency and maintainability.

To ensure that these changes haven't introduced any unintended side effects, it's recommended to run the entire test suite. Please execute the following command:

#!/bin/bash
# Description: Run the entire test suite to verify overall test integrity

# Test: Execute all tests and generate a coverage report
python -m pytest --cov=backend --cov-report=term-missing

This will help verify that the refactoring hasn't inadvertently affected other tests or reduced overall test coverage.


9-9: LGTM: Base class updated for consistency.

The base class has been correctly updated to ProjectAPIPermissionTestBase, which is consistent with the import change. This modification aligns with the broader refactoring effort to standardize permission testing across the codebase.

To ensure that this change hasn't inadvertently affected the test coverage, please run the following command:

This will help verify that the test coverage for the related views hasn't been impacted by the base class change.

backend/varannos/tests/helpers.py (3)

3-3: LGTM: Import statement updated for consistency

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase aligns with the broader refactoring effort to standardize permission testing base classes. This new naming convention is more consistent and clearer.


31-31: LGTM: Base class updated for API view tests

The change in the base class for ApiViewTestBase from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the earlier import change and aligns with the broader refactoring effort.

To ensure this change doesn't introduce any unexpected behavior, please review the affected API test cases. You can use the following script to find files that might need attention:

#!/bin/bash
# Description: Find test files that might be affected by the ApiViewTestBase change
rg "class.*\(.*ApiViewTestBase" --type py

14-14: LGTM: Class renamed for clarity

The renaming of TestViewsBase to ViewTestBase improves clarity and consistency in the naming convention. This change aligns with the overall refactoring effort mentioned in the PR summary.

To ensure this change doesn't break any existing code, please run the following script to check for any remaining references to the old class name:

✅ Verification successful

Verification Complete: No Remaining References Found

The renaming of TestViewsBase to ViewTestBase has been successfully verified with no remaining references to TestViewsBase found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to TestViewsBase
rg "TestViewsBase" --type py

Length of output: 7860

backend/varannos/tests/test_models.py (1)

20-20: LGTM! Verify corresponding model change.

The addition of the trailing slash in the expected URL is correct and aligns with Django's best practices. This change is consistent with similar updates in other test files, indicating a standardization of URL formatting across the project.

To ensure full consistency, please verify that the get_absolute_url method in the VarAnnoSet model has been updated to include the trailing slash. You can use the following script to check:

✅ Verification successful

Verified: get_absolute_url correctly includes a trailing slash consistent with URL patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the get_absolute_url method in the VarAnnoSet model

# Test: Search for the get_absolute_url method in the VarAnnoSet model
rg -A 5 'def get_absolute_url' backend/varannos/models.py

Length of output: 287


Script:

#!/bin/bash
# Description: Verify that the 'varannoset-detail' URL pattern includes a trailing slash

# Search for the 'varannoset-detail' path in urls.py
rg "path\s*\(.*'varannoset-detail'[^)]*\)" backend/varannos/urls.py

Length of output: 75


Script:

#!/bin/bash
# Description: Search for the 'varannoset-detail' URL pattern across all urls.py files

rg "name\s*=\s*['\"]varannoset-detail['\"]" $(fd -t f -e py 'urls.py') --context 2

Length of output: 741

backend/varannos/urls.py (8)

1-1: LGTM: Import statement updated correctly.

The import statement has been correctly updated to use django.urls instead of django.conf.urls, which is consistent with the transition to path() function usage.


7-11: LGTM: URL pattern updated correctly with improved type safety.

The URL pattern for VarAnnoSetListView has been successfully updated to use the path() function. The change also introduces the UUID path converter <uuid:project>, which enhances type safety and readability compared to the previous regex pattern. The trailing slash is correctly maintained, adhering to Django's URL pattern best practices.


12-16: LGTM: URL pattern updated correctly with improved type safety.

The URL pattern for VarAnnoSetDetailView has been successfully updated to use the path() function. The change introduces the UUID path converter <uuid:varannoset>, which enhances type safety and readability compared to the previous regex pattern. The trailing slash is correctly maintained, adhering to Django's URL pattern best practices.


22-26: LGTM: API URL pattern updated correctly with improved type safety.

The API URL pattern for VarAnnoSetListCreateApiView has been successfully updated to use the path() function. The change introduces the UUID path converter <uuid:project>, which enhances type safety and readability compared to the previous regex pattern. The trailing slash is correctly maintained, adhering to Django's URL pattern best practices.


27-31: LGTM: API URL pattern updated correctly with improved type safety.

The API URL pattern for VarAnnoSetRetrieveUpdateDestroyApiView has been successfully updated to use the path() function. The change introduces the UUID path converter <uuid:varannoset>, which enhances type safety and readability compared to the previous regex pattern. The trailing slash is correctly maintained, adhering to Django's URL pattern best practices.


32-36: LGTM: API URL pattern updated correctly with improved type safety.

The API URL pattern for VarAnnoSetEntryListCreateApiView has been successfully updated to use the path() function. The change introduces the UUID path converter <uuid:varannoset>, which enhances type safety and readability compared to the previous regex pattern. The trailing slash is correctly maintained, adhering to Django's URL pattern best practices.


37-41: LGTM: API URL pattern updated correctly with improved type safety.

The API URL pattern for VarAnnoSetEntryRetrieveUpdateDestroyApiView has been successfully updated to use the path() function. The change introduces the UUID path converter <uuid:varannosetentry>, which enhances type safety and readability compared to the previous regex pattern. The trailing slash is correctly maintained, adhering to Django's URL pattern best practices.


Line range hint 1-46: Excellent update: Modernized URL routing with improved type safety and consistency.

The changes in this file represent a comprehensive update of URL patterns from the deprecated url() function to the modern path() function. This transition brings several benefits:

  1. Improved readability: The path() function syntax is more intuitive and easier to understand.
  2. Enhanced type safety: The use of UUID path converters (<uuid:...>) ensures that only valid UUIDs are matched, reducing the risk of incorrect URL matching.
  3. Consistency: All patterns have been updated uniformly, maintaining a consistent approach throughout the file.
  4. Future-proofing: These changes align the code with current Django best practices, making future maintenance easier.

These updates contribute to a more robust and maintainable codebase. Great job on implementing these improvements consistently across all URL patterns!

backend/seqmeta/tests/test_permissions.py (2)

2-2: LGTM! Verify consistent usage across the project.

The import statement has been updated to use ProjectPermissionTestBase, which aligns with the broader refactoring of the permission testing framework mentioned in the PR summary. This change looks good and should improve consistency across test files.

To ensure this change is consistently applied across the project, run the following script:

#!/bin/bash
# Description: Verify the usage of ProjectPermissionTestBase across test files

# Test: Search for both old and new base classes
echo "Files still using TestProjectPermissionBase:"
rg "TestProjectPermissionBase" --type py

echo "Files using ProjectPermissionTestBase:"
rg "ProjectPermissionTestBase" --type py

26-26: LGTM! Verify test coverage remains intact.

The base class for TestSeqmetaView has been updated to use ProjectPermissionTestBase, which is consistent with the import change. This modification appears to be part of a broader refactoring effort to standardize permission testing across the project.

To ensure that this change hasn't inadvertently affected test coverage, run the following script:

backend/seqmeta/urls.py (9)

1-1: LGTM: Import statement updated correctly.

The import statement has been updated to use path from django.urls, which is correct for the new URL routing syntax.


8-12: LGTM: Index view URL pattern updated correctly.

The URL pattern for the index view has been successfully updated to use path() with an empty string as the route. This change simplifies the pattern while maintaining the same functionality.


13-17: LGTM: Enrichment kit list view URL pattern updated correctly.

The URL pattern for the enrichment kit list view has been successfully updated to use path() with "enrichmentkit/" as the route. This change simplifies the pattern while maintaining the same functionality and includes the trailing slash as per Django conventions.


18-22: LGTM: Enrichment kit detail view URL pattern updated correctly.

The URL pattern for the enrichment kit detail view has been successfully updated to use path() with "uuid:enrichmentkit/" as the route. This change improves type safety by using the built-in UUID converter and maintains consistency with Django conventions.


28-32: LGTM: Enrichment kit list-create API view URL pattern updated correctly.

The URL pattern for the enrichment kit list-create API view has been successfully updated to use path() with "api/enrichmentkit/list-create/" as the route. This change simplifies the pattern while maintaining the same functionality and includes the trailing slash as per Django conventions.


33-37: LGTM: Enrichment kit retrieve-update-destroy API view URL pattern updated correctly.

The URL pattern for the enrichment kit retrieve-update-destroy API view has been successfully updated to use path() with "uuid:enrichmentkit/" as part of the route. This change improves type safety by using the built-in UUID converter and maintains consistency with Django conventions.


38-42: LGTM: Target bed file list-create API view URL pattern updated correctly.

The URL pattern for the target bed file list-create API view has been successfully updated to use path() with "uuid:enrichmentkit/" as part of the route. This change improves type safety by using the built-in UUID converter and maintains consistency with Django conventions.


43-47: LGTM: Target bed file retrieve-update-destroy API view URL pattern updated correctly.

The URL pattern for the target bed file retrieve-update-destroy API view has been successfully updated to use path() with "uuid:targetbedfile/" as part of the route. This change improves type safety by using the built-in UUID converter and maintains consistency with Django conventions.


Line range hint 1-50: Overall: Excellent update to modern Django URL routing.

The changes in this file successfully transition all URL patterns from url() to path(), which aligns with modern Django practices. This update:

  1. Improves code readability by using simpler, more intuitive path definitions.
  2. Enhances type safety by utilizing built-in path converters (e.g., uuid).
  3. Maintains consistency with Django conventions, including the use of trailing slashes.

These changes will contribute to better maintainability and reduced potential for routing-related bugs in the future.

backend/varannos/tests/test_permissions.py (3)

2-2: LGTM: Import statement updated correctly.

The import statement has been updated to reflect the new base class ProjectPermissionTestBase. This change is consistent with the class inheritance modification.


Line range hint 9-42: Verify compatibility with the new base class.

The test methods and setup remain unchanged, which suggests compatibility with the new ProjectPermissionTestBase. However, to ensure full compliance:

  1. Check if ProjectPermissionTestBase requires any additional setup or teardown methods.
  2. Verify that all assertions and helper methods used in this test class are still available in the new base class.

Run the following script to check for any setUp or tearDown methods in the new base class that might need to be called:

If any methods are found, ensure they are properly called in this test class.


7-7: LGTM: Class inheritance updated correctly.

The TestVarAnnoSetViews class now inherits from ProjectPermissionTestBase, which is consistent with the import statement change and aligns with the broader refactoring of permission testing structures.

To ensure full compatibility with the new base class, please verify that all methods in ProjectPermissionTestBase that are used in this test class are still available and have the same signatures. You can run the following script to compare the method signatures:

If there are any discrepancies, please update the test class accordingly.

backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (5)

17-26: Well-structured ForeignKey relationship for buildbackgroundsvsetjob.bg_job

The changes to the bg_job field in the buildbackgroundsvsetjob model are well-implemented:

  1. The CASCADE deletion policy ensures data integrity by removing related objects when a backgroundjob is deleted.
  2. The dynamic related_name using %(app_label)s_%(class)s_related follows Django best practices, preventing naming conflicts in reverse relations.
  3. The help text provides clear information about the field's purpose.

These changes align with Django best practices and improve the overall structure of the model relationships.


27-36: Consistent implementation for cleanupbackgroundsvsetjob.bg_job

The changes to the bg_job field in the cleanupbackgroundsvsetjob model mirror those made to buildbackgroundsvsetjob. This consistency is commendable:

  1. It maintains a uniform approach to handling background jobs across different models.
  2. The CASCADE deletion policy and dynamic related_name are applied consistently.
  3. The help text remains clear and informative.

This consistent implementation enhances code maintainability and reduces the likelihood of errors due to inconsistent model relationships.


37-46: Systematic refactoring of background job relationships

The changes to the bg_job field in the importstructuralvariantbgjob model complete a systematic refactoring of background job relationships:

  1. All three models (buildbackgroundsvsetjob, cleanupbackgroundsvsetjob, and importstructuralvariantbgjob) now have consistent bg_job field definitions.
  2. This systematic approach ensures uniformity in how background jobs are handled across different parts of the application.
  3. The consistent use of CASCADE deletion and dynamic related_name across all three models simplifies the mental model for developers working with these relationships.

This refactoring demonstrates a thoughtful, holistic approach to improving the database schema.


47-58: Well-designed user relationship for svquery

The changes to the user field in the svquery model are well-considered:

  1. The SET_NULL deletion policy allows for maintaining historical query data even if a user is deleted, which is often desirable for audit purposes.
  2. Allowing null values (null=True, blank=True) is consistent with the SET_NULL policy and provides flexibility in query creation.
  3. The dynamic related_name maintains consistency with the other model changes in this migration.
  4. The help text clearly describes the field's purpose.

These changes strike a good balance between data integrity and flexibility, allowing for user-associated queries while not enforcing a strict requirement that might limit system functionality.


1-59: Excellent migration file with consistent and well-structured changes

This migration file demonstrates a high-quality, systematic approach to refactoring model relationships:

  1. Consistent implementation across similar models (buildbackgroundsvsetjob, cleanupbackgroundsvsetjob, importstructuralvariantbgjob) improves maintainability.
  2. Appropriate use of deletion policies (CASCADE for background jobs, SET_NULL for user relationships) balances data integrity with flexibility.
  3. Dynamic related_name usage follows Django best practices and prevents potential naming conflicts.
  4. Clear and informative help text for all modified fields enhances code documentation.

The changes in this migration file will likely improve the overall structure and integrity of the database schema. Great work on maintaining consistency and following best practices throughout the refactoring process.

backend/genepanels/urls.py (17)

4-4: LGTM: Correct import for path()

The change from django.conf.urls to django.urls is correct and aligns with Django's recommendation to use path() instead of url().


11-15: LGTM: Correct transition to path() for index view

The change from url() to path() for the index view is implemented correctly. The empty string pattern is maintained, and the view and name remain the same.


16-20: LGTM: Correct transition to path() for category list view

The change from url() to path() for the category list view is implemented correctly. The pattern "category/" is maintained, and the view and name remain the same.


21-25: LGTM: Correct transition to path() for category create view

The change from url() to path() for the category create view is implemented correctly. The pattern "category/create/" is maintained, and the view and name remain the same.


26-30: LGTM: Improved readability with path() for category update view

The change from url() to path() for the category update view is implemented correctly. The use of "uuid:category" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


31-35: LGTM: Improved readability with path() for category detail view

The change from url() to path() for the category detail view is implemented correctly. The use of "uuid:category" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


36-40: LGTM: Improved readability with path() for category delete view

The change from url() to path() for the category delete view is implemented correctly. The use of "uuid:category" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


41-45: LGTM: Correct transition to path() for gene panel create view

The change from url() to path() for the gene panel create view is implemented correctly. The pattern "panel/create/" is maintained, and the view and name remain the same.


46-50: LGTM: Improved readability with path() for gene panel update view

The change from url() to path() for the gene panel update view is implemented correctly. The use of "uuid:panel" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


51-55: LGTM: Improved readability with path() for gene panel detail view

The change from url() to path() for the gene panel detail view is implemented correctly. The use of "uuid:panel" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


56-60: LGTM: Improved readability with path() for gene panel delete view

The change from url() to path() for the gene panel delete view is implemented correctly. The use of "uuid:panel" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


61-65: LGTM: Improved readability with path() for gene panel copy as draft view

The change from url() to path() for the gene panel copy as draft view is implemented correctly. The use of "uuid:panel" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


66-70: LGTM: Improved readability with path() for gene panel release view

The change from url() to path() for the gene panel release view is implemented correctly. The use of "uuid:panel" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


71-75: LGTM: Improved readability with path() for gene panel retire view

The change from url() to path() for the gene panel retire view is implemented correctly. The use of "uuid:panel" instead of a regex pattern improves readability while maintaining the same functionality. The view and name remain the same.


79-83: LGTM: Correct transition to path() for gene panel category list API view

The change from url() to path() for the gene panel category list API view is implemented correctly. The pattern "api/genepanel-category/list/" is maintained, and the view and name remain the same.


84-88: LGTM: Correct transition to path() for lookup gene panel API view

The change from url() to path() for the lookup gene panel API view is implemented correctly. The pattern "api/lookup-genepanel/" is maintained, and the view and name remain the same.


Line range hint 1-90: Summary: Successful migration to path() improves code quality

The changes in this file successfully migrate all URL patterns from url() to path(). This transition:

  1. Improves code readability, especially for patterns with UUID parameters.
  2. Aligns with Django's best practices for URL configuration.
  3. Maintains all existing functionality without alterations.

These changes contribute to better maintainability of the codebase and demonstrate a commitment to keeping the project up-to-date with modern Django practices.

frontend/src/varfish/components/FilterForm/DevPane.vue (1)

70-72: LGTM: Improved textarea attributes and readability

The changes to the textarea element enhance both functionality and readability:

  1. Moving the class attribute to a new line improves code organization.
  2. Adding the :readonly binding ensures the textarea is only editable when in edit mode, which aligns with the toggleEditMode function in the script.

These changes effectively implement the edit mode functionality for the settings.

backend/genepanels/tests/test_models.py (2)

27-29: LGTM: Consistent URL formatting with trailing slash

The addition of a trailing slash to the URL in category.get_absolute_url() is correct and aligns with Django's URL handling conventions. This change enhances consistency across the codebase.


51-51: LGTM: Consistent URL formatting with trailing slash

The addition of a trailing slash to the URL in panel.get_absolute_url() is correct and maintains consistency with the previous change. This modification aligns with Django's URL handling conventions and improves overall codebase consistency.

backend/importer/urls.py (18)

4-4: LGTM: Updated import statement for modern Django URL routing.

The change from url to path is correct and aligns with Django's current best practices for URL configuration.


11-15: LGTM: Improved URL pattern for "import-info".

The change to path() is correct and improves readability by removing the regex pattern. The functionality remains the same with the view and name unchanged.


12-16: LGTM: Enhanced type safety in "import-case-job-detail" URL pattern.

The change to path() with <uuid:project> and <uuid:job> improves type safety and readability compared to the previous regex patterns. The functionality is preserved with the same view and name.


20-24: LGTM: Consistent update for "api-case-import-info-list-create" URL pattern.

The change to path() with <uuid:project> maintains consistency with previous updates, improving type safety and readability. The functionality is preserved with the same view and name.


25-29: LGTM: Consistent update for "api-case-import-info-retrieve-update-destroy" URL pattern.

The change to path() with <uuid:project> and <uuid:caseimportinfo> maintains the consistent pattern of improved type safety and readability across URL configurations. Functionality is preserved with the same view and name.


30-34: LGTM: Consistent update for "api-variant-set-import-info-list-create" URL pattern.

The change to path() with <uuid:caseimportinfo> continues the pattern of improved type safety and readability. Functionality is maintained with the same view and name.


35-39: LGTM: Consistent update for "api-variant-set-import-info-retrieve-update-destroy" URL pattern.

The change to path() with <uuid:caseimportinfo> and <uuid:variantsetimportinfo> maintains the consistent pattern of improved type safety and readability. Functionality is preserved with the same view and name.


40-44: LGTM: Consistent update for "api-bam-qc-file-list-create" URL pattern.

The change to path() with <uuid:caseimportinfo> continues the pattern of improved type safety and readability. Functionality is maintained with the same view and name.


45-49: LGTM: Consistent update for "api-bam-qc-file-retrieve-destroy" URL pattern.

The change to path() with <uuid:caseimportinfo> and <uuid:bamqcfile> maintains the consistent pattern of improved type safety and readability. Functionality is preserved with the same view and name.


50-54: LGTM: Consistent update for "api-case-gene-annotation-file-list-create" URL pattern.

The change to path() with <uuid:caseimportinfo> continues the pattern of improved type safety and readability. Functionality is maintained with the same view and name.


55-59: LGTM: Consistent update for "api-case-gene-annotation-file-retrieve-destroy" URL pattern.

The change to path() with <uuid:caseimportinfo> and <uuid:casegeneannotationfile> maintains the consistent pattern of improved type safety and readability. Functionality is preserved with the same view and name.


60-64: LGTM: Consistent update for "api-genotype-file-list-create" URL pattern.

The change to path() with <uuid:variantsetimportinfo> continues the pattern of improved type safety and readability. Functionality is maintained with the same view and name.


65-69: LGTM: Consistent update for "api-genotype-file-retrieve-destroy" URL pattern.

The change to path() with <uuid:variantsetimportinfo> and <uuid:genotypefile> maintains the consistent pattern of improved type safety and readability. Functionality is preserved with the same view and name.


70-74: LGTM: Consistent update for "api-effects-file-list-create" URL pattern.

The change to path() with <uuid:variantsetimportinfo> continues the pattern of improved type safety and readability. Functionality is maintained with the same view and name.


75-79: LGTM: Consistent update for "api-effects-file-retrieve-destroy" URL pattern.

The change to path() with <uuid:variantsetimportinfo> and <uuid:effectsfile> maintains the consistent pattern of improved type safety and readability. Functionality is preserved with the same view and name.


80-84: LGTM: Consistent update for "api-db-info-file-list-create" URL pattern.

The change to path() with <uuid:variantsetimportinfo> continues the pattern of improved type safety and readability. Functionality is maintained with the same view and name.


85-89: LGTM: Consistent update for "api-db-info-file-retrieve-destroy" URL pattern.

The change to path() with <uuid:variantsetimportinfo> and <uuid:databaseinfofile> maintains the consistent pattern of improved type safety and readability. Functionality is preserved with the same view and name.


Line range hint 1-91: Excellent modernization of URL routing in the importer app.

The changes in this file consistently update all URL patterns from url() to path(), improving type safety and readability throughout. The use of <uuid:...> for path parameters enhances type checking and reduces the risk of errors. These changes align with Django's best practices and should make the codebase more maintainable.

Great job on maintaining functionality while modernizing the URL configuration!

frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (2)

64-64: LGTM: Updated v-model syntax for TheAppBar component

The change to v-model:show-left-panel="navbarShown" is correct and aligns with Vue 3's component v-model syntax. This two-way binding ensures that the navbarShown state is properly synchronized with the TheAppBar component's internal state.


Line range hint 1-122: Overall assessment: Improved component structure and readability

The changes in this file enhance the component's structure and readability without altering its core functionality. The updates align with modern Vue.js practices, particularly in terms of v-model usage and template organization. These modifications contribute to better maintainability and are consistent with the broader changes mentioned in the pull request summary.

backend/genepanels/tests/test_permissions.py (3)

Line range hint 1-101: Overall impact seems minimal. Verify related files.

The changes in this file are limited to the import statement and the base class of TestGenepanelsView. The rest of the file, including all test methods and the UsersMixin class, remains unchanged. This suggests that the new ProjectPermissionTestBase class is likely compatible with the previous implementation.

To ensure consistency across the project, please verify that similar changes have been applied to other test files using the old TestProjectPermissionBase. Run the following command:

#!/bin/bash
# Description: Check for other files still using TestProjectPermissionBase

# Test: Search for files still using TestProjectPermissionBase
rg 'class \w+\(.*TestProjectPermissionBase\)' backend

If any files are found still using TestProjectPermissionBase, they should be updated to use ProjectPermissionTestBase for consistency.


29-29: LGTM! Run tests to ensure no regression.

The class signature has been updated to use ProjectPermissionTestBase as the base class, which is consistent with the import statement change. The UsersMixin is still being used, maintaining the previous functionality.

To ensure this change doesn't introduce any regression, please run the full test suite for this module. You can use the following command:

#!/bin/bash
# Description: Run tests for the genepanels module

# Test: Run pytest for the genepanels module
python -m pytest backend/genepanels/tests

2-2: LGTM! Verify the new base class interface.

The import statement has been updated to use ProjectPermissionTestBase instead of what was likely TestProjectPermissionBase. This change appears to be part of a broader refactoring effort to improve the permission testing framework.

To ensure this change doesn't introduce any breaking changes, please verify that the ProjectPermissionTestBase class provides the same interface as the previous TestProjectPermissionBase. You can run the following script to check the class definition:

✅ Verification successful

Verified: ProjectPermissionTestBase exists and is correctly imported.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the interface of ProjectPermissionTestBase

# Test: Search for the class definition of ProjectPermissionTestBase
rg -A 10 'class ProjectPermissionTestBase'

Length of output: 173


Script:

#!/bin/bash
# Description: Search for the definition of ProjectPermissionTestBase or similar classes.

# Search for classes that end with 'PermissionTestBase' in the backend directory
rg 'class \w+PermissionTestBase' backend/

Length of output: 43


Script:

#!/bin/bash
# Description: Search for any test classes related to permissions in the backend directory.

# Search for classes that contain both 'Permission' and 'Test' in their names
rg 'class \w*(Permission|Test)\w*' backend/

Length of output: 57260

backend/varannos/tests/test_permissions_api.py (1)

2-2: LGTM! Verify consistent usage across the codebase.

The import statement has been updated to reflect the new location of the ProjectAPIPermissionTestBase class. This change aligns with the base class modification in the test class.

To ensure consistency, let's verify the usage of this import across the codebase:

#!/bin/bash
# Description: Check for consistent usage of ProjectAPIPermissionTestBase import
# Test: Search for ProjectAPIPermissionTestBase usage. Expect: Consistent import statements.
rg -n "from projectroles.tests.test_permissions_api import ProjectAPIPermissionTestBase"
backend/svs/urls.py (13)

2-2: LGTM: Updated import statement for modern Django URL routing.

The change from url to path and re_path is appropriate and aligns with current Django best practices for URL routing.


11-15: LGTM: Updated to path() with appropriate path converters.

The change to path() with <uuid:project> and <uuid:job> converters is a good modernization. However, ensure that your application's APPEND_SLASH setting and CommonMiddleware configuration align with the intended trailing slash behavior, as this pattern now enforces a trailing slash.


16-20: LGTM: Consistent use of path() and UUID converter.

This change aligns with the previous pattern update. The same consideration about trailing slash behavior mentioned in the previous comment applies here.


21-25: LGTM: Consistent pattern update.

This change follows the same pattern as the previous two, maintaining consistency across the file.


29-33: LGTM: Consistent use of path() and UUID converter.

This change maintains the pattern established in previous updates, using the appropriate path converter for the case UUID.


44-48: LGTM: Consistent use of path() and UUID converter.

This change aligns with the established pattern of using path() with UUID converters, maintaining consistency across the file.


50-54: LGTM: Consistent pattern update with UUID converter.

This change follows the established pattern of using path() with UUID converters, maintaining consistency throughout the file.


56-65: LGTM: Consistent updates for SV query views.

Both changes maintain the established pattern of using path() with appropriate UUID converters. This consistency improves readability and maintainability of the URL patterns.


66-75: LGTM: Consistent updates for SV query result set views.

These changes follow the established pattern of using path() with appropriate UUID converters for the SV query result set views. The consistency is maintained, improving the overall structure of the URL patterns.


76-85: LGTM: Consistent updates for SV query result row views.

These changes maintain the established pattern of using path() with appropriate UUID converters for the SV query result row views. The consistency across all related views enhances the readability and maintainability of the URL patterns.


87-101: LGTM: Consistent updates for structural variant flags views.

These three changes maintain the established pattern of using path() with appropriate UUID converters for the structural variant flags views. The consistency across these related views contributes to a clean and maintainable URL structure.


102-130: LGTM: Consistent updates for user annotation views.

All these changes for structural variant comment and ACMG rating views maintain the established pattern of using path() with appropriate UUID converters. This consistency across the user annotation views contributes to a uniform and maintainable URL structure throughout the file.


Line range hint 1-146: Overall, excellent modernization of URL patterns.

The transition from url() to path() and re_path() significantly improves the readability and maintainability of the URL configurations. The consistent use of UUID converters is commendable. A few minor adjustments have been suggested:

  1. Ensure trailing slash behavior is consistent, especially for the 'quick-presets' view.
  2. Consider using re_path() or a custom converter for the 'category-presets' view to maintain original constraints.
  3. Simplify the re_path() patterns for proxy views by removing redundant anchors.

These changes align well with modern Django practices and should make the codebase more robust and easier to maintain.

backend/cases/urls.py (4)

1-5: LGTM: Imports and app_name are correctly updated

The imports have been properly updated to use path instead of url, and all necessary view modules are imported. The app_name is correctly set to "cases".


6-12: LGTM: UI URL pattern correctly updated

The UI URL pattern has been properly updated to use the path() function with a UUID converter for the project parameter. This change aligns with Django's best practices for URL routing.


14-79: LGTM: AJAX URL patterns correctly updated

All AJAX URL patterns have been properly updated to use the path() function with appropriate UUID converters. The views referenced consistently use views_ajax, maintaining separation between AJAX and API views.


Line range hint 1-156: Overall improvement with minor inconsistencies

The update from url() to path() for all URL patterns is a significant improvement, aligning with Django's best practices. The consistent use of UUID converters for various parameters ensures type safety and consistency across all patterns.

However, there are still some inconsistencies in the API URL patterns section, particularly with view references and one route prefix. Addressing these issues will complete the transition and maintain a clear separation between AJAX and API functionalities.

Once the suggested changes are implemented, this file will be in excellent shape, providing a clear and consistent routing structure for the application.

To ensure all API views exist and are correctly referenced after making the suggested changes, please run the following script:

This script will help verify that all necessary API views exist and are correctly referenced in the URL patterns.

backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (3)

1-141: LGTM: Well-structured migration for standardizing ForeignKey relationships

This migration effectively standardizes the ForeignKey relationships across multiple models, which is a good practice for maintaining consistency and improving the database schema. The changes align with best practices and seem to be part of a larger refactoring effort.


97-108: LGTM: Appropriate user field alterations

The alterations to the user field in ProjectCasesSmallVariantQuery and SmallVariantQuery models are well-defined. The use of SET_NULL for on_delete is a good practice, allowing for user deletion without losing associated data. The blank=True and null=True fields appropriately handle optional user associations.

Also applies to: 119-130


1-141: Ensure comprehensive testing and verification

Given that this migration is part of a larger upgrade process (as indicated by the PR title "feat: upgrade to sodar core v1"), it's crucial to ensure that these changes are compatible with the rest of the system. Please confirm that:

  1. Comprehensive tests have been updated or added to cover these model changes.
  2. The migration has been tested on a copy of the production database to ensure smooth execution.
  3. Any code that relies on the altered fields (especially the bg_job and user fields) has been updated and tested accordingly.

To help verify the impact of these changes, you can run the following script:

This script will help identify any potential areas that might need attention due to the field alterations.

backend/variants/tests/helpers.py (3)

5-6: LGTM: Import statements updated correctly.

The import statements have been updated to reflect the new base classes for permission testing. This change is consistent with the overall refactoring effort mentioned in the PR summary.


34-34: LGTM: ApiViewTestBase updated to use new permission base class.

The ApiViewTestBase class has been correctly updated to inherit from ProjectAPIPermissionTestBase, which is consistent with the import changes and the overall refactoring effort.


47-47: LGTM: ViewTestBase updated to use new permission base class.

The ViewTestBase class has been correctly updated to inherit from ProjectPermissionTestBase, which is consistent with the import changes and the overall refactoring effort.

Regarding the past review comment about class redefinition:
The issue of ViewTestBase redefinition seems to have been resolved in this update. The class is now defined only once, inheriting from ViewTestBaseMixin and ProjectPermissionTestBase. This change addresses the previous concern about unintentional redefinition.

backend/variants/models/maintenance.py (1)

114-188: Overall, excellent implementation of SmallVariantSummary management

The new functions and SQL queries for managing the SmallVariantSummary materialized view are well-implemented. They demonstrate good coding practices, efficient SQL structure, and clear documentation. The minor suggestions provided (simplifying nested with statements and adding comments to SQL queries) will further enhance the code's readability and maintainability.

Great job on this implementation!

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

backend/variants/urls/presets.py (7)

3-3: LGTM: Import statement updated correctly

The import statement has been updated to use django.urls, which is consistent with the transition to the path() function for URL routing.


119-132: LGTM: QuickPresets URL patterns updated correctly

The URL patterns for QuickPresets have been updated consistently to use path() with appropriate UUID converters. These changes improve readability and maintainability without introducing any new issues.


33-52: ⚠️ Potential issue

Apply custom path converter for name parameter

The URL patterns for FlagsEtcPresets have been updated consistently. However, the same issue with the slug converter applies here.

Please apply the custom path converter solution suggested in the previous comment to the following URL pattern:

- "ajax/flagsetcpresets/clone-factory-presets/<slug:name>/",
+ "ajax/flagsetcpresets/clone-factory-presets/<nodigitslug:name>/",

54-73: ⚠️ Potential issue

Apply custom path converter for name parameter

The URL patterns for ImpactPresets have been updated consistently. However, the same issue with the slug converter applies here.

Please apply the custom path converter solution suggested in the previous comments to the following URL pattern:

- "ajax/impactpresets/clone-factory-presets/<slug:name>/",
+ "ajax/impactpresets/clone-factory-presets/<nodigitslug:name>/",

75-94: ⚠️ Potential issue

Apply custom path converter for name parameter

The URL patterns for QualityPresets have been updated consistently. However, the same issue with the slug converter applies here.

Please apply the custom path converter solution suggested in the previous comments to the following URL pattern:

- "ajax/qualitypresets/clone-factory-presets/<slug:name>/",
+ "ajax/qualitypresets/clone-factory-presets/<nodigitslug:name>/",

96-115: ⚠️ Potential issue

Apply custom path converter for name parameter

The URL patterns for ChromosomePresets have been updated consistently. However, the same issue with the slug converter applies here.

Please apply the custom path converter solution suggested in the previous comments to the following URL pattern:

- "ajax/chromosomepresets/clone-factory-presets/<slug:name>/",
+ "ajax/chromosomepresets/clone-factory-presets/<nodigitslug:name>/",

137-166: Verify the impact of changing project parameter to UUID

The URL patterns for PresetSet have been updated to use path() with UUID converters. However, the project parameter has been changed from accepting slugs to strictly accepting UUIDs. This change could potentially break existing functionality if project was previously used with non-UUID identifiers.

Please verify the following:

  1. Ensure that all project identifiers in the codebase are UUIDs.
  2. Check if this change affects any existing API clients or frontend code that might be using non-UUID project identifiers.

To help verify this change, you can run the following script to search for any non-UUID usage of the project parameter:

If this script returns any results, it may indicate areas where the project parameter is being used with non-UUID values, which could be affected by this change.

✅ Verification successful

Corrected script to verify project parameter usage

The previous script encountered a syntax error. Please use the updated script below to search for any non-UUID usage of the project parameter:


Retry the script with PCRE2 support to verify project parameter usage

The previous script encountered a regex parse error due to unsupported look-around assertions. Please use the updated script below with the --pcre2 flag to search for any non-UUID usage of the project parameter:


Verification completed: No impact on API functionality

The only non-UUID usage of the project parameter was found in docs/conf.py, which is related to documentation and does not affect the API endpoints. No issues detected in the runtime codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential non-UUID usage of 'project' parameter
rg -i 'project\s*=\s*["\'](?![0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})[^"\']+["\']' --type py

Length of output: 250


Script:

#!/bin/bash
# Search for potential non-UUID usage of 'project' parameter
rg -i "project\s*=\s*[\"'](?![0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})[^\"']+[\"']" --type py

Length of output: 435


Script:

#!/bin/bash
# Search for potential non-UUID usage of 'project' parameter with PCRE2 support
rg -i --pcre2 "project\s*=\s*[\"'](?![0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})[^\"']+[\"']" --type py

Length of output: 169

backend/variants/tests/test_ui.py (1)

164-164: LGTM! Verify base class existence.

The renaming of TestUIBase to UITestBase is consistent with the standardization efforts across the test suite. This change improves clarity and aligns with similar modifications in other test files.

To ensure the base class exists, please run the following script:

If the script doesn't return any results, please update the import statement or create the UITestBase class in the appropriate location within the projectroles package.

backend/config/urls.py (7)

29-29: LGTM: URL patterns updated to use path()

The changes from url() to path() for these URL patterns are correct and align with modern Django practices. This update improves readability and maintainability of the URL configuration.

Also applies to: 36-41, 43-43, 46-48, 50-56, 58-70


94-95: LGTM: Proxy URL patterns updated to use re_path()

The transition from url() to re_path() for these proxy URL patterns is correct. re_path() is the appropriate choice for patterns containing regex, maintaining the existing functionality while aligning with modern Django practices.

Also applies to: 102-103, 110-111, 117-118, 124-125, 132-133, 139-140


182-184: LGTM: Error handling URL patterns updated to use path()

The changes from url() to path() for the error handling URL patterns are correct and consistent with the rest of the file. This update maintains the existing functionality while aligning with modern Django practices.

Also applies to: 188-189, 193-193


198-198: LGTM: Debug toolbar URL pattern updated to use path()

The change from url() to path() for including the debug toolbar URLs is correct and consistent with the rest of the file. This update maintains the existing functionality while aligning with modern Django practices.


Line range hint 1-198: Summary of URL configuration updates

The changes in this file successfully transition most URL patterns from url() to path() and re_path(), aligning with modern Django practices. This improves readability and maintainability of the URL configuration.

Two minor issues were identified:

  1. The import statement for include should be updated for consistency.
  2. One instance of path() should be changed to re_path() for a regex pattern.

After addressing these issues, the URL configuration will be fully modernized and consistent.


2-2: 🛠️ Refactor suggestion

Update import statements for consistency

The import of include from django.conf.urls is outdated. For consistency with modern Django practices and to avoid potential deprecation warnings, update the import statements as follows:

-from django.conf.urls import include
 from django.conf.urls.static import static
 from django.contrib import admin
 from django.contrib.auth import views as auth_views
 from django.contrib.staticfiles import finders
 from django.http import HttpResponse
 from django.shortcuts import render
-from django.urls import path, re_path
+from django.urls import path, re_path, include

This change aligns with the transition to using path() and re_path() throughout the file.

Also applies to: 9-9


168-169: ⚠️ Potential issue

Use re_path() instead of path() for regex patterns

The pattern "-.*" includes regex wildcard characters. Since path() doesn't accept regex patterns and interprets the route parameter as a fixed string or with path converters, you should use re_path() for regex patterns.

Apply this diff to fix the issue:

-path(
+re_path(

This change ensures that the regex pattern is correctly interpreted and the route functions as intended.

.github/workflows/main.yml (4)

174-174: LGTM: Python version update for linting.

The Python version for the linting job has been updated to 3.11, which is consistent with the change in the testing job. This ensures that linting and testing are performed using the same Python version, maintaining consistency across the CI pipeline.


Line range hint 1-285: Summary of changes in the GitHub Actions workflow

  1. PostgreSQL image updated to version 16.
  2. Python version updated to 3.11 for both testing and linting jobs.
  3. A duplicate Python setup step was identified in the Python-Lint job.

These changes modernize the CI pipeline but require careful verification of compatibility with the updated versions. Ensure that all necessary adjustments have been made in the application code, dependencies, and configuration files to support these updates.


122-122: Verify compatibility with Python 3.11 for testing.

The Python version for testing has been updated from 3.10.13 to 3.11. This minor version upgrade may introduce new features or improvements. Please ensure that:

  1. All project dependencies are compatible with Python 3.11.
  2. Any Python 3.11-specific features or syntax are not used unless the minimum supported version has been officially changed.
  3. The Pipfile and Pipfile.lock have been updated accordingly.

To check for potential compatibility issues, run the following script:

#!/bin/bash
# Check if Pipfile specifies Python 3.11
grep -q 'python_version = "3.11"' backend/Pipfile || echo "Pipfile may need to be updated for Python 3.11"

# Check for any Python 3.11-specific syntax or features
rg -i 'match.*case' --type py

17-17: Verify compatibility with PostgreSQL 16.

The PostgreSQL image has been updated from version 14 to 16. This is a major version upgrade that may introduce breaking changes or new features. Please ensure that:

  1. The application is compatible with PostgreSQL 16.
  2. Any database migrations or schema changes are properly handled.
  3. Performance impact, if any, is assessed.

To check for potential compatibility issues, run the following script:

✅ Verification successful

PostgreSQL 16 compatibility verified.

No code dependencies on the previous PostgreSQL version detected. Please ensure all tests pass with the upgraded database.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for PostgreSQL-specific code or configuration that might be affected by the version change
rg -i 'postgres|psql|pg_' --type py --type yaml --type json

Length of output: 83


Script:

#!/bin/bash
# Enhanced search for PostgreSQL-specific code or configuration that might be affected by the version change
rg -i 'postgresql|psql|pg_[a-zA-Z_]+|PostgreSQL' --type py --type yaml --type json --type sql

Length of output: 963

backend/svs/tests/test_permissions_ajax_queries.py (8)

11-11: LGTM. Base class updated correctly.

The base class for TestSvQueryListCreateAjaxView has been successfully updated to ProjectAPIPermissionTestBase. This change is consistent with the import statement update and maintains the existing test structure.


48-48: LGTM. Base class updated consistently.

The base class for TestSvQueryRetrieveUpdateDestroyAjaxView has been correctly updated to ProjectAPIPermissionTestBase. This change is consistent with the previous updates and maintains the existing test structure.


111-111: LGTM. Base class updated consistently.

The base class for TestSvQueryResultSetListAjaxView has been correctly updated to ProjectAPIPermissionTestBase. This change is consistent with the previous updates and maintains the existing test structure.


134-134: LGTM. Base class updated consistently.

The base class for TestSvQueryResultSetRetrieveAjaxView has been correctly updated to ProjectAPIPermissionTestBase. This change is consistent with the previous updates and maintains the existing test structure.


160-160: LGTM. Base class updated consistently.

The base class for TestSvQueryResultRowListAjaxView has been correctly updated to ProjectAPIPermissionTestBase. This change is consistent with the previous updates and maintains the existing test structure.


186-186: LGTM. Base class updated consistently. Verify entire file.

The base class for TestSvQueryResultRowRetrieveView has been correctly updated to ProjectAPIPermissionTestBase. This change is consistent with all previous updates in the file and maintains the existing test structure.

To ensure all changes have been applied consistently, run the following script to verify that no instances of TestProjectAPIPermissionBase remain in this file:

#!/bin/bash
# Description: Verify that TestProjectAPIPermissionBase is not present in the file
! grep -q "TestProjectAPIPermissionBase" backend/svs/tests/test_permissions_ajax_queries.py && echo "All instances updated successfully" || echo "Some instances of TestProjectAPIPermissionBase remain"

Line range hint 1-208: Summary: Consistent update of base class for permission tests

The changes in this file are part of a larger refactoring effort to use ProjectAPIPermissionTestBase as the new base class for permission testing. The updates have been applied consistently across all test classes, and the import statement has been correctly modified. These changes maintain the existing test structure while potentially introducing new functionality or improvements from the updated base class.

To ensure the refactoring is complete:

  1. Verify that similar changes have been applied to other test files in the project.
  2. Run the test suite to confirm that all tests pass with the new base class.
  3. Update any documentation that may reference the old base class name.

Run the following script to check for any remaining uses of TestProjectAPIPermissionBase in the project:

#!/bin/bash
# Description: Check for any remaining uses of TestProjectAPIPermissionBase in the project
rg "TestProjectAPIPermissionBase" --type py

If any results are found, consider updating those occurrences as well.


4-4: LGTM. Verify consistency across the project.

The import statement has been correctly updated to reflect the new location or name of the ProjectAPIPermissionTestBase class. This change is consistent with the updates in the test classes.

To ensure project-wide consistency, run the following script to check for any remaining imports of TestProjectAPIPermissionBase:

If any results are found, consider updating those imports as well.

✅ Verification successful

All instances of TestProjectAPIPermissionBase have been successfully updated across the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining imports of TestProjectAPIPermissionBase
rg "from .+ import TestProjectAPIPermissionBase" --type py

Length of output: 168

backend/variants/tests/test_permissions_ajax.py (5)

62-62: LGTM! Base class updated consistently.

The base class has been correctly updated to ProjectAPIPermissionTestBase, maintaining consistency with the other test classes in this file.


127-127: LGTM! Base class updated consistently.

The base class has been correctly updated to ProjectAPIPermissionTestBase, maintaining consistency with the other test classes in this file.


155-155: LGTM! Base class updated consistently.

The base class has been correctly updated to ProjectAPIPermissionTestBase, maintaining consistency with the other test classes in this file.


20-20: LGTM! Verify the new base class methods.

The base class has been correctly updated to ProjectAPIPermissionTestBase. This change is consistent across all test classes in this file.

To ensure that the new base class provides all necessary methods, please run:

#!/bin/bash
# List methods of ProjectAPIPermissionTestBase
rg -p "def \w+\(self" $(rg -l "class ProjectAPIPermissionTestBase" projectroles/)
# List methods of TestProjectAPIPermissionBase (old base class)
rg -p "def \w+\(self" $(rg -l "class TestProjectAPIPermissionBase" projectroles/)
# Compare the output to ensure all necessary methods are present in the new base class

6-6: LGTM! Verify the new base class import.

The import statement has been correctly updated to use ProjectAPIPermissionTestBase. This change is consistent with the updates in the test classes.

Please run the following command to verify the existence and location of the new base class:

frontend/src/variants/components/FilterForm/ClinvarPane.vue (4)

Line range hint 1-14: LGTM: Script section is well-structured and uses Vue 3 composition API.

The script section is concise and well-organized. It correctly defines the necessary props and the interpretations array, which will be used in the template. The use of the setup syntax indicates proper adoption of the Vue 3 composition API.


Line range hint 23-110: LGTM: Checkbox implementations and bindings are well-structured.

The checkbox implementations and their bindings to the querySettings object are well-structured and maintain the component's logic. The conditional disabling of checkboxes (e.g., "paranoid mode" and interpretation checkboxes) based on the "require ClinVar membership" state ensures a consistent user interface. The dynamic generation of interpretation checkboxes based on the interpretations array is a good practice for maintainability.


Line range hint 111-220: Approve removal of commented-out code.

The removal of the large block of commented-out code at the end of the template is a good practice. It improves code cleanliness and readability, removing potentially confusing or outdated implementations. This change, combined with the new dynamic checkbox generation, results in a more maintainable and cleaner component.


Line range hint 1-224: Overall assessment: Significant improvements to component structure and maintainability.

This review has covered the entire ClinvarPane.vue component, including both the script and template sections. The changes made to this component represent significant improvements:

  1. Adoption of Vue 3 composition API in the script section.
  2. Improved prop definitions and use of a dynamic interpretations array.
  3. Reorganized and simplified template structure with better conditional rendering.
  4. Dynamic generation of checkbox inputs, reducing code duplication.
  5. Removal of outdated commented-out code, improving overall cleanliness.

These changes collectively enhance the component's readability, maintainability, and adherence to Vue.js best practices. The only suggested improvement is a minor simplification of the v-if condition for the main div.

backend/variants/tests/test_permissions_api.py (7)

18-18: LGTM. Base class updated correctly.

The base class for TestSmallVariantQueryListCreateApiView has been correctly updated to ProjectAPIPermissionTestBase. This change is consistent with the import statement update and maintains compatibility with the existing test methods.


60-60: LGTM. Base class updated consistently.

The base class for TestSmallVariantQueryRetrieveUpdateDestroyApiView has been correctly updated to ProjectAPIPermissionTestBase. This change maintains consistency with the previous updates and preserves compatibility with the existing test methods.


125-125: LGTM. Base class updated consistently.

The base class for TestSmallVariantQueryResultSetListApiView has been correctly updated to ProjectAPIPermissionTestBase. This change maintains consistency with the previous updates and preserves compatibility with the existing test methods.


153-153: LGTM. Base class updated consistently.

The base class for TestSmallVariantQueryResultSetRetrieveApiView has been correctly updated to ProjectAPIPermissionTestBase. This change maintains consistency with the previous updates and preserves compatibility with the existing test methods.


181-181: LGTM. Base class updated consistently.

The base class for TestSmallVariantQueryResultRowListApiView has been correctly updated to ProjectAPIPermissionTestBase. This change maintains consistency with the previous updates and preserves compatibility with the existing test methods.


Line range hint 1-234: Summary: Consistent base class update across all test classes

The changes in this file demonstrate a systematic refactoring of the API permission test classes. All test classes have been updated to inherit from ProjectAPIPermissionTestBase instead of TestProjectAPIPermissionBase. This change is consistent throughout the file and aligns with the updated import statement.

Key points:

  1. The refactoring appears to be part of a larger effort to standardize API permission testing.
  2. No changes were made to the test methods or their implementations, suggesting that the new base class is compatible with the existing tests.
  3. The consistency of the changes indicates a well-planned and executed refactoring process.

To ensure the refactoring hasn't introduced any unintended side effects:

  1. Verify that all tests in this file pass successfully.
  2. Check if similar changes have been applied consistently across other test files in the project.
  3. Review the ProjectAPIPermissionTestBase class to understand any new functionality or changes in behavior that might affect these tests.

To check for similar changes across the project, run:

#!/bin/bash
# Description: Check for similar base class changes in other test files

# Test: Search for files that still use TestProjectAPIPermissionBase
rg "class \w+\(TestProjectAPIPermissionBase\)" backend/

This will help ensure the refactoring has been applied consistently across the project.


209-209: LGTM. Base class updated consistently. Verify all test cases.

The base class for TestSmallVariantQueryResultRowRetrieveApiView has been correctly updated to ProjectAPIPermissionTestBase. This change maintains consistency with the previous updates and preserves compatibility with the existing test methods.

As this is the last class update in the file, please ensure all test cases still pass with the new base class.

Run the following command to verify that all tests in this file still pass:

#!/bin/bash
# Description: Run tests for the updated file

# Test: Run pytest for the specific test file
python -m pytest backend/variants/tests/test_permissions_api.py -v
frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (2)

310-310: LGTM: Improved attribute ordering in Multiselect component

The reordering of attributes in the Multiselect component and moving the @select event handler to a new line improves code readability and follows Vue.js style guidelines. These changes are cosmetic and do not affect functionality.


314-314: LGTM: Improved attribute placement in select element

Moving the id attribute to a new line in the select element for genomicsEnglandConfidence improves code readability and maintains consistency with the component's overall style. This change is cosmetic and does not affect functionality.

frontend/src/variants/components/FilterForm/EffectPane.vue (1)

Line range hint 1-17: LGTM: Improved imports and introduction of form validation

The changes to the import statements are appropriate:

  • The addition of Vuelidate imports indicates the implementation of form validation, which is a good practice for ensuring data integrity.
  • Explicit imports from 'vue' align with Vue 3 best practices.

These changes enhance the component's functionality and maintainability.

backend/cases/tests/test_views_ajax.py (11)

41-41: LGTM: Base class updated consistently.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the refactoring mentioned in the summary. This standardization should improve the maintainability of the test suite.


150-150: LGTM: Consistent base class update.

The base class change to ProjectAPIPermissionTestBase is consistent with the previous class and the overall refactoring effort.


228-228: LGTM: Base class updated consistently.

The change to ProjectAPIPermissionTestBase maintains consistency with the ongoing refactoring effort.


293-293: LGTM: Consistent base class update.

The base class change to ProjectAPIPermissionTestBase aligns with the refactoring pattern observed in other classes.


363-363: LGTM: Base class updated consistently.

The change to ProjectAPIPermissionTestBase maintains the refactoring pattern seen in other test classes.


417-417: LGTM: Consistent base class update.

The base class change to ProjectAPIPermissionTestBase follows the established refactoring pattern.


488-488: LGTM: Base class updated consistently.

The change to ProjectAPIPermissionTestBase continues the consistent refactoring pattern observed throughout the file.


516-516: LGTM: Consistent base class update.

The base class change to ProjectAPIPermissionTestBase maintains the refactoring pattern seen throughout the file.


599-599: LGTM: Base class updated consistently.

The change to ProjectAPIPermissionTestBase follows the established refactoring pattern seen in other test classes.


627-627: LGTM: Consistent base class update.

The base class change to ProjectAPIPermissionTestBase maintains the refactoring pattern observed throughout the file.


667-667: LGTM: Base class updated consistently.

The change to ProjectAPIPermissionTestBase completes the consistent refactoring pattern observed throughout the entire file.

backend/variants/tests/test_views_ajax_presets.py (7)

3-3: Update to import statement looks good.

The change from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase is consistent with the class name change. This update likely reflects a refactoring in the projectroles app to standardize naming conventions.


26-26: Base class update is correct.

The ApiViewTestBase class now inherits from ProjectAPIPermissionTestBase, which is consistent with the import change. This update ensures that all test classes in this file will use the new base class for permission testing.


122-129: Improved test implementation for factory preset cloning.

The removal of mocking in favor of directly testing the API endpoint is a positive change. This approach:

  1. Tests the actual implementation rather than mocked behavior.
  2. Simplifies the test code and makes it easier to understand.
  3. Provides more confidence in the API's functionality.

The use of kwargs={"name": "any"} in the URL reversal is appropriate, as it allows testing with any valid preset name.


146-153: Consistent improvement in test implementation for cloning other presets.

The changes in this test class mirror those in the factory preset cloning test, maintaining consistency across related functionalities. The direct API testing approach is well-implemented here, providing a clear and effective test case.


244-251: Consistent improvement in test implementations across preset types.

The changes in TestImpactPresetsCloneFactoryPresetsAjaxView, TestImpactPresetsCloneOtherAjaxView, TestQualityPresetsCloneFactoryPresetsAjaxView, TestQualityPresetsCloneOtherAjaxView, and TestChromosomePresetsCloneFactoryPresetsAjaxView classes all follow the same pattern of improvement:

  1. Removal of mocking in favor of direct API testing.
  2. Consistent use of self.login(self.superuser) to authenticate requests.
  3. Direct assertion of response status and content.

This consistency across different preset types enhances the maintainability and reliability of the test suite. The uniform approach makes it easier to understand and modify tests for different preset types in the future.

Also applies to: 268-275, 366-373, 390-397, 488-495


610-617: Consistent improvements with additional validations for PresetSet cloning.

The changes in TestFlagsEtcPresetsCloneFactoryPresetsAjaxView, TestFlagsEtcPresetsCloneOtherAjaxView, TestQuickPresetsCloneOtherAjaxView, TestPresetSetCloneFactoryPresetsAjaxView, and TestPresetSetCloneOtherAjaxView classes maintain the consistent improvement pattern seen throughout the file.

Notable points:

  1. All classes now use direct API testing instead of mocking.
  2. The TestPresetSetCloneFactoryPresetsAjaxView and TestPresetSetCloneOtherAjaxView classes include additional assertions to verify the object count before and after the cloning process. This extra validation enhances the robustness of these tests.

Example from TestPresetSetCloneOtherAjaxView:

self.assertEqual(PresetSet.objects.count(), 1)
# ... (API call)
self.assertEqual(PresetSet.objects.count(), 2)

These additional checks ensure that the cloning process is creating new objects as expected, which is a valuable addition to the test suite.

Also applies to: 634-641, 732-739, 842-851, 861-872


Line range hint 1-872: Excellent refactoring of test suite with improved testing methodology.

The changes made to this file represent a significant enhancement to the test suite:

  1. Consistent update to use ProjectAPIPermissionTestBase as the base class for permission testing.
  2. Transition from mocked tests to direct API testing across all preset types.
  3. Uniform implementation of the new testing approach, improving maintainability.
  4. Addition of object count assertions in some tests, providing extra validation.

These improvements result in a more robust and reliable test suite that more accurately reflects real-world API usage. The consistency across different preset types will make future maintenance and updates easier.

Suggestions for future improvements:

  1. Consider adding more edge case tests, such as testing with invalid data or unauthorized users.
  2. Explore the possibility of parameterized tests to reduce code duplication across similar preset types.

Overall, this refactoring significantly enhances the quality and effectiveness of the test suite.

backend/variants/tests/test_file_export.py (3)

Line range hint 18-978: Refactoring: ProjectEvent to TimelineEvent

The changes in this file are part of a larger refactoring effort to update the event model from ProjectEvent to TimelineEvent. This update affects both the import statement and the assertion in the ExportCaseTest class. While the changes in this file are minimal and straightforward, it's important to ensure that this refactoring is consistent across the entire codebase.

To ensure the refactoring is complete and consistent, consider running the following checks:

  1. Search for any remaining uses of ProjectEvent in the entire codebase:
#!/bin/bash
# Search for any remaining uses of ProjectEvent in the entire codebase
rg "ProjectEvent" --type py
  1. Check for any files that import from timeline.models to ensure they're using the correct model:
#!/bin/bash
# Search for imports from timeline.models
rg "from timeline.models import" --type py
  1. Verify that all tests related to timeline events are updated and passing:
#!/bin/bash
# Run tests related to timeline functionality
python manage.py test timeline

These checks will help ensure that the refactoring is complete and hasn't introduced any inconsistencies or broken functionality.


978-978: Update assertion to use TimelineEvent

The assertion has been updated to check the count of TimelineEvent objects instead of ProjectEvent objects. This change is consistent with the import statement update.

Let's verify if there are any other occurrences of ProjectEvent in this file that might need to be updated:

#!/bin/bash
# Search for any remaining uses of ProjectEvent in this file
rg "ProjectEvent" backend/variants/tests/test_file_export.py

18-18: Update import statement to use TimelineEvent

The import statement has been changed from ProjectEvent to TimelineEvent. This change suggests a refactoring or renaming of the event model used in the timeline functionality.

To ensure this change is consistent across the codebase, let's check for any remaining uses of ProjectEvent:

✅ Verification successful

No remaining uses of ProjectEvent found

The import statement update to TimelineEvent is consistent across the codebase with no residual ProjectEvent references.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining uses of ProjectEvent
rg "ProjectEvent" --type py

Length of output: 60


Script:

#!/bin/bash
# Search for any remaining uses of ProjectEvent across the entire codebase
rg "ProjectEvent" --type py

Length of output: 27

backend/variants/tests/test_permissions_ajax_presets.py (5)

2-2: LGTM: Consistent base class import update.

The import statement has been updated to use ProjectAPIPermissionTestBase, which is consistent with the changes throughout the file. This change likely reflects a broader refactoring effort in the project.


17-17: LGTM: Base class updated, existing tests preserved.

The TestFrequencyPresetsListCreateAjaxView class now correctly inherits from ProjectAPIPermissionTestBase. The existing test methods and their logic remain unchanged, ensuring that the test coverage is maintained.


64-64: LGTM: Consistent base class update.

The TestFrequencyPresetsRetrieveUpdateDestroyAjaxView class has been updated to inherit from ProjectAPIPermissionTestBase, maintaining consistency with other classes in the file. The existing test methods remain intact, preserving the test coverage.


Line range hint 140-1244: LGTM: Consistent base class refactoring across all test classes.

All test classes in this file have been updated to inherit from ProjectAPIPermissionTestBase. This change is consistent throughout the file and likely part of a larger refactoring effort to standardize API permission tests. The existing test methods, their logic, and coverage remain unchanged, which is crucial for maintaining the integrity of the test suite.

Classes affected:

  • TestFrequencyPresetsCloneFactoryDefaultsView
  • TestFrequencyPresetsCloneOtherView
  • TestImpactPresetsListCreateAjaxView
  • TestImpactPresetsRetrieveUpdateDestroyAjaxView
  • TestImpactPresetsCloneFactoryDefaultsView
  • TestImpactPresetsCloneOtherView
  • TestQualityPresetsListCreateAjaxView
  • TestQualityPresetsRetrieveUpdateDestroyAjaxView
  • TestQualityPresetsCloneFactoryDefaultsView
  • TestQualityPresetsCloneOtherView
  • TestChromosomePresetsListCreateAjaxView
  • TestChromosomePresetsRetrieveUpdateDestroyAjaxView
  • TestChromosomePresetsCloneFactoryDefaultsView
  • TestChromosomePresetsCloneOtherView
  • TestFlagsEtcPresetsListCreateAjaxView
  • TestFlagsEtcPresetsRetrieveUpdateDestroyAjaxView
  • TestFlagsEtcPresetsCloneFactoryDefaultsView
  • TestFlagsEtcPresetsCloneOtherView
  • TestQuickPresetsListCreateAjaxView
  • TestQuickPresetsRetrieveUpdateDestroyAjaxView
  • TestQuickPresetsCloneOtherView
  • TestPresetSetListCreateAjaxView
  • TestPresetSetListAllAjaxView
  • TestPresetSetRetrieveUpdateDestroyAjaxView
  • TestPresetSetCloneFactoryDefaultsView
  • TestPresetSetCloneOtherView

This refactoring improves code consistency and maintainability without altering the test behavior.


Line range hint 1-1244: Summary: Successful refactoring of test base class.

This file has undergone a systematic refactoring to update the base class for all test classes from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. The changes are consistent throughout the file and align with the updated import statement.

Key points:

  1. All test classes now inherit from ProjectAPIPermissionTestBase.
  2. The existing test methods, their logic, and coverage remain unchanged.
  3. This refactoring likely improves code consistency across the project's test suite.

The changes appear to be part of a larger effort to standardize API permission tests. The refactoring has been executed cleanly, maintaining the integrity of the test suite while potentially improving its maintainability.

No issues or potential problems were identified during this review. The changes are approved and ready for merging.

backend/seqvars/tests/test_permissions_api.py (2)

2-2: Base class import updated correctly.

The import statement has been updated to use the new base class name ProjectAPIPermissionTestBase. This change is consistent with the modifications made throughout the file.


205-205: Base class updated correctly for TestQueryPresetsVersionSetViewSet.

The TestQueryPresetsVersionSetViewSet class now inherits from ProjectAPIPermissionTestBase, maintaining consistency with the refactoring. The structure of this test class mirrors that of TestQueryPresetsSetViewSet, which is good for maintaining a uniform testing approach across different API endpoints.

The suggestion for implementing a parameterized test approach for user roles, as mentioned in the previous comment, applies here as well.

backend/variants/migrations/0111_create_variant_summary.py (2)

32-32: Duplicate Comment: Ensure deterministic id generation

The previous comment regarding non-deterministic id assignments is still valid and applicable.


80-87: Migration dependencies and operations are correctly defined

The migration class is properly structured with accurate dependencies and operations.

backend/variants/urls/__init__.py (4)

1-1: LGTM: Updated import statement

The import statement has been correctly updated to include path from django.urls, aligning with Django's current best practices.


12-149: LGTM: Modernized UI URL patterns

The UI URL patterns have been successfully refactored to use path() with appropriate <uuid:...> converters. This enhances readability and maintains the intended URL structure.


156-295: LGTM: Updated AJAX API URL patterns

The AJAX API URL patterns have been updated to use path() along with the correct UUID converters. The changes are accurate and ensure consistent routing behavior.


299-450: LGTM: Refactored API URL patterns

The API URL patterns have been modernized using path() with appropriate path converters. The refactor aligns with Django's recommendations and maintains existing functionality.

backend/config/settings/base.py (5)

80-80: Integration of social_django into THIRD_PARTY_APPS

The addition of 'social_django' to THIRD_PARTY_APPS enables OIDC authentication, which aligns with the updated authentication settings.

Also applies to: 83-83


438-438: Verify the change in ADMIN_URL

The modification of ADMIN_URL from r"^admin/" to "admin/" removes the caret (^) and the raw string indicator (r). This might affect URL patterns that rely on regular expressions. Ensure that the URL configurations and any references to ADMIN_URL are updated accordingly to maintain the accessibility of the admin site.


688-697: Addition of custom_preprocessing_hook

The custom_preprocessing_hook function effectively filters out endpoints starting with "/project/" and "/timeline/" from the API documentation, which aligns with the intended functionality.


709-709: Inclusion of custom_preprocessing_hook in SPECTACULAR_SETTINGS

Adding "config.settings.base.custom_preprocessing_hook" to PREPROCESSING_HOOKS ensures that the custom preprocessing is applied during schema generation, correctly excluding specified endpoints.


877-906: Confirm resolution of previous OIDC configuration concerns

Please verify that prior review comments regarding the OIDC configuration have been addressed, specifically:

  • Default credentials: Ensure that SOCIAL_AUTH_OIDC_KEY and SOCIAL_AUTH_OIDC_SECRET do not have insecure default values to prevent potential security risks.
  • Authentication backends: Check that AUTHENTICATION_BACKENDS is properly managed to include all necessary backends without overwriting previous entries.


from varannos.models import VarAnnoSet
from varannos.tests.factories import VarAnnoSetFactory


class TestVarAnnoSetApiView(TestProjectAPIPermissionBase):
class TestVarAnnoSetApiView(ProjectAPIPermissionTestBase):
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Potential Issues Found.

The old base class TestProjectAPIPermissionBase does not appear to exist in the codebase anymore. Please verify that ProjectAPIPermissionTestBase maintains the same functionality to avoid unintended behavioral changes.

🔗 Analysis chain

LGTM! Verify potential behavioral changes.

The base class has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase, which is consistent with the import statement change. This modification likely reflects a standardization effort in the permission testing framework.

To ensure that this change doesn't introduce unexpected behavior, let's verify the differences between the old and new base classes:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare the old and new base classes
# Test: Search for both class definitions. Expect: To see differences in method signatures or implementations.
rg -n "class TestProjectAPIPermissionBase\(" 
rg -n "class ProjectAPIPermissionTestBase\("

Length of output: 2950

Comment on lines +34 to 38
path(
"ajax/query-case/quick-presets",
view=views.SvQuickPresetsAjaxView.as_view(),
name="ajax-quick-presets",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider trailing slash behavior for consistency.

The new pattern "ajax/query-case/quick-presets" doesn't include a trailing slash, unlike the original regex pattern which allowed an optional trailing slash. To maintain consistent behavior:

  1. Add a trailing slash: "ajax/query-case/quick-presets/"
  2. Use re_path() with an optional trailing slash: re_path(r"^ajax/query-case/quick-presets/?$", ...)
  3. Ensure APPEND_SLASH setting and CommonMiddleware are configured to handle this change as intended.

Choose the option that best fits your project's URL scheme consistency.

Comment on lines +39 to 43
path(
"ajax/query-case/category-presets/<str:category>/",
view=views.SvCategoryPresetsApiView.as_view(),
name="ajax-category-presets",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure category parameter constraints are maintained.

The change from a regex pattern to <str:category> may introduce unintended behavior. The original regex (?P<category>[a-zA-Z0-9\._-]+) was more restrictive than <str:category>, which allows any non-empty string excluding slashes.

Consider one of these options to maintain the original constraints:

  1. Use re_path() with the original regex:

    re_path(
        r"ajax/query-case/category-presets/(?P<category>[a-zA-Z0-9\._-]+)/",
        view=views.SvCategoryPresetsApiView.as_view(),
        name="ajax-category-presets",
    ),
  2. Create a custom path converter that enforces the required character set.

This ensures that the category parameter remains constrained to alphanumeric characters, periods, underscores, and hyphens.

Comment on lines 81 to 152

api_urlpatterns = [
url(
regex=r"^api/case/count/(?P<project>[0-9a-f-]+)/?$",
path(
route="api/case/count/<uuid:project>/",
view=views_api.CaseCountApiView.as_view(),
name="api-case-count",
),
url(
regex=r"^api/case/list/(?P<project>[0-9a-f-]+)/?$",
path(
route="api/case/list/<uuid:project>/",
view=views_api.CaseListApiView.as_view(),
name="api-case-list",
),
url(
regex=r"^api/case/retrieve-update-destroy/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case/retrieve-update-destroy/<uuid:case>/",
view=views_api.CaseRetrieveUpdateDestroyApiView.as_view(),
name="api-case-retrieveupdatedestroy",
),
url(
regex=r"^api/case-comment/list-create/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-comment/list-create/<uuid:case>/",
view=views_api.CaseCommentListCreateApiView.as_view(),
name="api-casecomment-listcreate",
),
url(
regex=r"^ajax/case-comment/retrieve-update-destroy/(?P<casecomment>[0-9a-f-]+)/?$",
path(
route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/",
view=views_api.CaseCommentRetrieveUpdateDestroyApiView.as_view(),
name="api-casecomment-retrieveupdatedestroy",
),
url(
regex=r"^api/case-phenotype-terms/list-create/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-phenotype-terms/list-create/<uuid:case>/",
view=views_api.CasePhenotypeTermsListCreateApiView.as_view(),
name="api-casephenotypeterms-listcreate",
),
url(
regex=r"^api/case-phenotype-terms/retrieve-update-destroy/(?P<casephenotypeterms>[0-9a-f-]+)/?$",
path(
route="api/case-phenotype-terms/retrieve-update-destroy/<uuid:casephenotypeterms>/",
view=views_api.CasePhenotypeTermsRetrieveUpdateDestroyApiView.as_view(),
name="api-casephenotypeterms-retrieveupdatedestroy",
),
url(
regex=r"^api/annotation-release-info/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/annotation-release-info/list/<uuid:case>/",
view=views_api.AnnotationReleaseInfoApiView.as_view(),
name="api-annotationreleaseinfo-list",
),
url(
regex=r"^api/sv-annotation-release-info/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/sv-annotation-release-info/list/<uuid:case>/",
view=views_api.SvAnnotationReleaseInfoApiView.as_view(),
name="api-svannotationreleaseinfo-list",
),
url(
regex=r"^api/case-gene-annotation/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-gene-annotation/list/<uuid:case>/",
view=views_ajax.CaseGeneAnnotationListAjaxView.as_view(),
name="api-casegeneannotation-list",
),
url(
regex=r"^api/case-alignment-stats/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-alignment-stats/list/<uuid:case>/",
view=views_ajax.CaseAlignmentStatsListAjaxView.as_view(),
name="api-casealignmentstats-list",
),
url(
regex=r"^api/case-variant-stats/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-variant-stats/list/<uuid:case>/",
view=views_ajax.SampleVariantStatisticsListAjaxView.as_view(),
name="api-casevariantstats-list",
),
url(
regex=r"^api/case-relatedness/list/(?P<case>[0-9a-f-]+)/?$",
path(
route="api/case-relatedness/list/<uuid:case>/",
view=views_ajax.PedigreeRelatednessListAjaxView.as_view(),
name="api-caserelatedness-list",
),
url(
regex=r"^api/user-and-global-settings/?$",
path(
route="api/user-and-global-settings/",
view=views_api.UserAndGlobalSettingsView.as_view(),
name="api-userandglobalsettings",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix remaining inconsistencies in API URL patterns

While the update to path() functions is correct, there are still some inconsistencies in the API URL patterns that need to be addressed:

  1. Some patterns are using AJAX views instead of API views:

    • Line 129: Change to view=views_api.CaseGeneAnnotationListApiView.as_view()
    • Line 134: Change to view=views_api.CaseAlignmentStatsListApiView.as_view()
    • Line 139: Change to view=views_api.SampleVariantStatisticsListApiView.as_view()
    • Line 144: Change to view=views_api.PedigreeRelatednessListApiView.as_view()
  2. One route is incorrectly prefixed with "ajax" instead of "api":

    • Line 104: Change route="ajax/case-comment/retrieve-update-destroy/<uuid:casecomment>/" to route="api/case-comment/retrieve-update-destroy/<uuid:casecomment>/"

Please make these changes to ensure consistency across all API URL patterns.

Comment on lines +17 to +26
migrations.AlterField(
model_name="clearexpiredexportedfilesbgjob",
name="bg_job",
field=models.ForeignKey(
help_text="Background job for state etc.",
on_delete=django.db.models.deletion.CASCADE,
related_name="%(app_label)s_%(class)s_related",
to="bgjobs.backgroundjob",
),
),
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using a custom migration operation to reduce repetition

The migration alters the bg_job field in multiple models using identical field definitions. To improve maintainability and reduce the risk of inconsistencies, consider creating a custom migration operation that encapsulates this common field alteration.

Example:

from django.db import migrations

def alter_bg_job_field(apps, schema_editor):
    models_to_alter = [
        "ClearExpiredExportedFilesBgJob",
        "ClearInactiveVariantSetsBgJob",
        # ... add all other models
    ]
    for model_name in models_to_alter:
        Model = apps.get_model("variants", model_name)
        bg_job_field = Model._meta.get_field("bg_job")
        bg_job_field.remote_field.on_delete = models.CASCADE
        bg_job_field.remote_field.related_name = "%(app_label)s_%(class)s_related"
        bg_job_field.remote_field.model = "bgjobs.BackgroundJob"
        bg_job_field.help_text = "Background job for state etc."

class Migration(migrations.Migration):
    # ...
    operations = [
        migrations.RunPython(alter_bg_job_field),
    ]

This approach would make the migration more concise and easier to maintain.

Also applies to: 27-36, 37-46, 47-56, 57-66, 67-76, 77-86, 87-96, 109-118, 131-140

@@ -3,7 +3,7 @@
import json

from django.urls import reverse
from projectroles.tests.test_permissions_api import TestProjectAPIPermissionBase
from projectroles.tests.test_permissions_api import ProjectAPIPermissionTestBase
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

ProjectAPIPermissionTestBase class not found.

The import statement references ProjectAPIPermissionTestBase, but the class definition couldn't be located in the codebase. Please ensure that the class is defined and correctly imported.

🔗 Analysis chain

LGTM. Verify the new base class functionality.

The import statement has been correctly updated to use ProjectAPIPermissionTestBase. This change is consistent with the updates made to the test classes throughout the file.

To ensure the new base class provides all necessary functionality, please run the following command:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the contents of the new ProjectAPIPermissionTestBase class

# Test: Check the contents of the ProjectAPIPermissionTestBase class
rg -A 20 "class ProjectAPIPermissionTestBase" projectroles/tests/test_permissions_api.py

Length of output: 236


Script:

#!/bin/bash
# Description: Verify the contents of the new ProjectAPIPermissionTestBase class

# Test: Check the contents of the ProjectAPIPermissionTestBase class
rg "class ProjectAPIPermissionTestBase" projectroles/tests/test_permissions_api.py -A 20

Length of output: 173


Script:

#!/bin/bash
# Description: Verify the contents of the ProjectAPIPermissionTestBase class

# Test: Check the contents of the ProjectAPIPermissionTestBase class
rg "class ProjectAPIPermissionTestBase" backend/variants/tests/test_permissions_api.py -A 20

Length of output: 94


Script:

#!/bin/bash
# Description: Check if the file backend/variants/tests/test_permissions_api.py exists

# Test: Verify the existence of the file
if [ -f backend/variants/tests/test_permissions_api.py ]; then
    echo "File exists."
else
    echo "File does not exist."
fi

Length of output: 94


Script:

#!/bin/bash
# Description: Search the entire codebase for the ProjectAPIPermissionTestBase class definition

# Test: Locate the ProjectAPIPermissionTestBase class
rg "class ProjectAPIPermissionTestBase" --type py -A 20

Length of output: 57

@@ -282,7 +282,7 @@ def _create_project(
for setting_name, value in setting_value.items():
if project_settings.get(setting_name) != value:
app_settings.set(
app_name="cases_import",
plugin_name="cases_import",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Incomplete Terminology Update from app_name to plugin_name

Several instances of app_name remain in the codebase and should be updated to plugin_name for consistency:

  • backend/variants/variant_stats.py
  • backend/variants/templatetags/variants_tags.py
  • backend/variants/sync_upstream.py
  • backend/variants/submit_filter.py
  • backend/varfish/vueapp/urls.py
  • backend/variants/submit_external.py
  • backend/variants/urls/__init__.py
  • backend/variants/models/case.py
  • backend/variants/models/jobs.py
  • backend/variants/models/importer.py
  • backend/variants/migrations/0110_drop_variant_summary.py
  • backend/variants/models/kiosk.py
  • backend/variants/file_export.py
  • backend/seqmeta/urls.py
  • backend/seqvars/urls.py
  • backend/svs/urls.py
  • backend/svs/views/bgjob.py
  • backend/svs/bg_db.py
  • backend/svs/models/importer.py
  • backend/varannos/urls.py
  • backend/genepanels/urls.py
  • backend/importer/urls.py
  • backend/importer/management/commands/rebuild_project_case_stats.py
  • backend/cohorts/urls.py
  • backend/cases_import/urls.py
  • backend/cases_qc/urls.py
  • backend/beaconsite/urls.py
  • backend/cases/urls.py
  • backend/cases_analysis/urls.py

Please update these instances to plugin_name to maintain consistency across the codebase.

🔗 Analysis chain

LGTM: Terminology update from app_name to plugin_name

The change from app_name to plugin_name in the AppSettingAPI.set() method call looks good. This update likely reflects a broader shift in terminology throughout the project.

To ensure consistency across the codebase, please run the following script to check for any remaining instances of app_name that might need updating:

This will help identify any other occurrences that might need to be updated for consistency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for remaining instances of 'app_name' in Python files
rg "app_name" --type py

# Search for instances of 'plugin_name' to verify the new terminology is being used
rg "plugin_name" --type py

Length of output: 3056

Comment on lines +67 to +77
if settings.IS_TESTING:
operations = []
else:
operations = [
migrations.RunSQL(
SQL_OUTER % SQL_INNER,
"""
DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;
""",
)
]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid using runtime conditions in migrations

Using settings.IS_TESTING to conditionally define operations can lead to inconsistent database schemas across different environments. Migrations should be deterministic and environment-agnostic to ensure the database remains consistent across testing, staging, and production.

Consider removing the conditional check and ensuring that the migration runs uniformly in all environments. If certain operations should be skipped during testing, handle this logic outside of the migration files, perhaps by adjusting test settings or mocking.

Comment on lines +89 to +99
if settings.IS_TESTING:
operations = []
else:
operations = [
migrations.RunSQL(
"""
DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;
""",
SQL_OUTER % SQL_INNER,
)
]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid conditional logic in migrations based on settings

Migrations should be deterministic and not depend on runtime settings like settings.IS_TESTING. Conditional logic can lead to inconsistent database schemas across different environments, which can cause unexpected behaviors and complicate maintenance.

Apply this diff to ensure the migration runs consistently:

-if settings.IS_TESTING:
-    operations = []
-else:
-    operations = [
-        migrations.RunSQL(
-            """
-            DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;
-            """,
-            SQL_OUTER % SQL_INNER,
-        )
-    ]
+operations = [
+    migrations.RunSQL(
+        """
+        DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;
+        """,
+        SQL_OUTER % SQL_INNER,
+    )
+]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if settings.IS_TESTING:
operations = []
else:
operations = [
migrations.RunSQL(
"""
DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;
""",
SQL_OUTER % SQL_INNER,
)
]
operations = [
migrations.RunSQL(
"""
DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary;
""",
SQL_OUTER % SQL_INNER,
)
]

Comment on lines +27 to +31
if self.instance.pk:
rows = [entry.symbol for entry in self.instance.genepanelentry_set.all()]
initial_value = "\n".join(rows)
else:
initial_value = ""
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize queryset to improve performance

To enhance performance when retrieving gene symbols, especially with a large number of entries, consider using values_list to fetch only the necessary data directly from the database.

Apply this diff to optimize the queryset:

-        rows = [entry.symbol for entry in self.instance.genepanelentry_set.all()]
+        rows = self.instance.genepanelentry_set.values_list('symbol', flat=True)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if self.instance.pk:
rows = [entry.symbol for entry in self.instance.genepanelentry_set.all()]
initial_value = "\n".join(rows)
else:
initial_value = ""
if self.instance.pk:
rows = self.instance.genepanelentry_set.values_list('symbol', flat=True)
initial_value = "\n".join(rows)
else:
initial_value = ""

@stolpeo stolpeo force-pushed the 1973-upgrade-to-sodar-core-v1 branch from 42f8b4e to 2fdd358 Compare October 22, 2024 10:59
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (9)
backend/cases/tests/test_views_ajax.py (1)

150-150: Consider making the query limit test more robust

The test_get_querylimit method is checking for performance optimization by limiting the number of queries. To make this test more robust and less likely to break with future optimizations, consider the following suggestions:

  1. Use a variable for the expected number of queries instead of hardcoding it in the assertion.
  2. Add a small buffer to the expected number of queries to allow for minor fluctuations.

Here's an example of how you could implement these suggestions:

MAX_EXPECTED_QUERIES = 70  # Slightly higher than the current 67
with self.assertNumQueriesLessThan(MAX_EXPECTED_QUERIES):
    response = self.client.get(url)

This approach will make the test more resilient to small changes in query count while still catching significant regressions.

backend/variants/tests/test_permissions_ajax_presets.py (3)

Line range hint 17-62: LGTM! Consider adding a docstring for better documentation.

The change to inherit from ProjectAPIPermissionTestBase is consistent with the refactoring effort. The test structure remains sound.

Consider adding a class-level docstring to explain the purpose of this test class, e.g.:

class TestFrequencyPresetsListCreateAjaxView(ProjectAPIPermissionTestBase):
    """Test permissions for listing and creating frequency presets."""

Line range hint 345-371: LGTM! Note the change in user reference.

The change to inherit from ProjectAPIPermissionTestBase is consistent with the refactoring. The test logic remains appropriate.

Note that the user reference has changed from self.user_owner to self.owner_as.user. Ensure this is consistent with the new base class implementation.


Line range hint 1-1270: Excellent refactoring work! Consider adding type hints for further improvement.

The refactoring of this file is thorough and consistent:

  1. All test classes now inherit from ProjectAPIPermissionTestBase.
  2. User references have been updated from self.user_owner to self.owner_as.user throughout.
  3. The overall structure and logic of the tests remain intact.

These changes likely contribute to a more standardized approach to permission testing across the project.

To further enhance the code quality, consider adding type hints to method parameters and return values. This would improve code readability and make it easier to catch type-related issues early. For example:

def setUp(self) -> None:
    super().setUp()
    self.presetset = PresetSetFactory(project=self.project)

def test_list(self) -> None:
    url = reverse(
        "variants:ajax-presetset-listall",
    )
    # ... rest of the method
backend/cases_import/models/executors.py (2)

Line range hint 1018-1052: LGTM: Comprehensive case creation/update logic.

The new _run_create_or_update method effectively consolidates the logic for creating or updating a case. It handles various aspects of the process, including error handling, file management, and data import.

However, consider the following suggestions for improvement:

  1. The method is quite long and performs multiple operations. Consider breaking it down into smaller, more focused methods to improve readability and maintainability.

  2. Some of the operations (e.g., file clearing, QC import) could potentially be moved to separate methods or even separate classes, following the Single Responsibility Principle.

  3. Consider adding more detailed logging throughout the method to aid in debugging and monitoring the import process.


Line range hint 1-1052: Overall improvements with room for further refinement.

The changes to this file, particularly in the CaseImportBackgroundJobExecutor class, represent a significant improvement in code organization and clarity. The separation of delete and create/update logic, along with the consolidation of case creation and update processes, enhances the overall structure of the case import functionality.

For future iterations, consider the following suggestions:

  1. Further break down the _run_create_or_update method into smaller, more focused methods to improve maintainability and testability.

  2. Evaluate the possibility of extracting some functionalities into separate classes or modules, adhering more closely to the Single Responsibility Principle.

  3. Enhance logging throughout the import process to facilitate debugging and monitoring.

  4. Consider implementing unit tests for the new and modified methods to ensure robustness and catch potential regressions.

These refinements would further improve the code quality and make it easier to maintain and extend in the future.

backend/varfish/tests/drf_openapi_schema/varfish_api_schema.yaml (2)

1110-1340: New endpoints for EnrichmentKit and TargetBedFile are well-implemented.

The addition of CRUD endpoints for EnrichmentKit and TargetBedFile resources is a valuable expansion of the API. These endpoints follow RESTful conventions and include proper authentication requirements, which is commendable.

Suggestion for consistency:
Consider adding a brief description for each endpoint, similar to other endpoints in the schema. This would improve the overall documentation and make it easier for API consumers to understand the purpose of each endpoint.


Line range hint 7000-7371: Component schema updates are comprehensive and well-structured.

The additions and modifications to component schemas, particularly for EnrichmentKit, TargetBedFile, and related objects, are well-implemented. These changes reflect the evolving data model of the application and provide clear definitions for the new resources.

Suggestion for improvement:
Consider adding more detailed descriptions for some of the new fields in the schemas. For example, in the EnrichmentKit schema, a brief explanation of what the "identifier" field represents would be helpful for API consumers.

Also applies to: 8168-8180

backend/config/settings/base.py (1)

691-693: Clarify the comment to accurately reflect code functionality

The comment # Remove all but DRF API endpoints may be misleading. The code excludes endpoints starting with "/project/" and "/timeline/", effectively removing these from processing. Consider updating the comment to precisely describe the endpoints being excluded.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 42f8b4e and 2fdd358.

⛔ Files ignored due to path filters (1)
  • backend/Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (78)
  • .github/workflows/main.yml (4 hunks)
  • backend/Makefile (1 hunks)
  • backend/Pipfile (4 hunks)
  • backend/beaconsite/tests/test_permissions.py (3 hunks)
  • backend/beaconsite/tests/test_permissions_ajax.py (2 hunks)
  • backend/beaconsite/tests/test_permissions_api.py (3 hunks)
  • backend/beaconsite/tests/test_views_ajax.py (1 hunks)
  • backend/beaconsite/urls.py (1 hunks)
  • backend/cases/tests/test_permissions.py (1 hunks)
  • backend/cases/tests/test_permissions_ajax.py (12 hunks)
  • backend/cases/tests/test_permissions_api.py (11 hunks)
  • backend/cases/tests/test_views.py (1 hunks)
  • backend/cases/tests/test_views_ajax.py (12 hunks)
  • backend/cases/urls.py (1 hunks)
  • backend/cases_analysis/tests/test_permissions_api.py (2 hunks)
  • backend/cases_import/models/executors.py (1 hunks)
  • backend/cases_import/tests/test_models_executor.py (1 hunks)
  • backend/cases_import/tests/test_permissions_api.py (1 hunks)
  • backend/cases_qc/tests/test_permissions_api.py (2 hunks)
  • backend/cases_qc/tests/test_views_api.py (1 hunks)
  • backend/cohorts/migrations/0008_alter_cohort_user.py (1 hunks)
  • backend/cohorts/tests/test_permissions_ajax.py (3 hunks)
  • backend/cohorts/tests/test_permissions_api.py (3 hunks)
  • backend/cohorts/tests/test_views_ui.py (1 hunks)
  • backend/cohorts/urls.py (1 hunks)
  • backend/config/settings/base.py (5 hunks)
  • backend/config/urls.py (5 hunks)
  • backend/genepanels/forms.py (1 hunks)
  • backend/genepanels/tests/test_models.py (2 hunks)
  • backend/genepanels/tests/test_permissions.py (2 hunks)
  • backend/genepanels/urls.py (1 hunks)
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py (1 hunks)
  • backend/importer/urls.py (1 hunks)
  • backend/seqmeta/tests/test_models.py (1 hunks)
  • backend/seqmeta/tests/test_permissions.py (2 hunks)
  • backend/seqmeta/urls.py (2 hunks)
  • backend/seqvars/tests/test_permissions_api.py (17 hunks)
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_presets.py (1 hunks)
  • backend/svs/tests/test_permissions_ajax_queries.py (6 hunks)
  • backend/svs/urls.py (2 hunks)
  • backend/varannos/tests/helpers.py (3 hunks)
  • backend/varannos/tests/test_models.py (1 hunks)
  • backend/varannos/tests/test_permissions.py (1 hunks)
  • backend/varannos/tests/test_permissions_api.py (1 hunks)
  • backend/varannos/urls.py (2 hunks)
  • backend/varfish/templates/users/login.html (1 hunks)
  • backend/varfish/tests/drf_openapi_schema/varfish_api_schema.yaml (40 hunks)
  • backend/varfish/users/management/commands/initdev.py (1 hunks)
  • backend/varfish/users/urls.py (1 hunks)
  • backend/varfish/vueapp/urls.py (1 hunks)
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py (1 hunks)
  • backend/variants/migrations/0110_drop_variant_summary.py (1 hunks)
  • backend/variants/migrations/0111_create_variant_summary.py (1 hunks)
  • backend/variants/models/maintenance.py (1 hunks)
  • backend/variants/tests/helpers.py (3 hunks)
  • backend/variants/tests/test_file_export.py (2 hunks)
  • backend/variants/tests/test_permissions_ajax.py (6 hunks)
  • backend/variants/tests/test_permissions_ajax_annos.py (1 hunks)
  • backend/variants/tests/test_permissions_ajax_presets.py (29 hunks)
  • backend/variants/tests/test_permissions_api.py (7 hunks)
  • backend/variants/tests/test_ui.py (1 hunks)
  • backend/variants/tests/test_views_ajax_presets.py (15 hunks)
  • backend/variants/urls/init.py (2 hunks)
  • backend/variants/urls/annos.py (1 hunks)
  • backend/variants/urls/presets.py (2 hunks)
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue (1 hunks)
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue (4 hunks)
  • frontend/src/varfish/components/FilterForm/DevPane.vue (2 hunks)
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/EffectPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FlagsPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue (1 hunks)
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue (3 hunks)
  • frontend/src/variants/components/FilterForm/QualityPane.vue (1 hunks)
  • frontend/src/variants/components/QueryPresets/SetEditor.vue (2 hunks)
  • frontend/src/variants/components/QueryPresets/SetProperties.vue (1 hunks)
  • utils/docker/Dockerfile (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (59)
  • backend/Makefile
  • backend/Pipfile
  • backend/beaconsite/tests/test_permissions.py
  • backend/beaconsite/tests/test_permissions_ajax.py
  • backend/beaconsite/tests/test_permissions_api.py
  • backend/beaconsite/tests/test_views_ajax.py
  • backend/beaconsite/urls.py
  • backend/cases/tests/test_permissions.py
  • backend/cases/tests/test_permissions_ajax.py
  • backend/cases/tests/test_permissions_api.py
  • backend/cases/tests/test_views.py
  • backend/cases_analysis/tests/test_permissions_api.py
  • backend/cases_import/tests/test_models_executor.py
  • backend/cases_import/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_permissions_api.py
  • backend/cases_qc/tests/test_views_api.py
  • backend/cohorts/migrations/0008_alter_cohort_user.py
  • backend/cohorts/tests/test_permissions_ajax.py
  • backend/cohorts/tests/test_permissions_api.py
  • backend/cohorts/tests/test_views_ui.py
  • backend/cohorts/urls.py
  • backend/genepanels/forms.py
  • backend/genepanels/tests/test_models.py
  • backend/genepanels/tests/test_permissions.py
  • backend/genepanels/urls.py
  • backend/importer/migrations/0012_alter_importcasebgjob_bg_job.py
  • backend/seqmeta/tests/test_models.py
  • backend/seqmeta/tests/test_permissions.py
  • backend/seqmeta/urls.py
  • backend/seqvars/tests/test_permissions_api.py
  • backend/svs/migrations/0029_alter_buildbackgroundsvsetjob_bg_job_and_more.py
  • backend/svs/tests/test_permissions_ajax_presets.py
  • backend/svs/tests/test_permissions_ajax_queries.py
  • backend/varannos/tests/helpers.py
  • backend/varannos/tests/test_models.py
  • backend/varannos/tests/test_permissions.py
  • backend/varannos/tests/test_permissions_api.py
  • backend/varfish/users/urls.py
  • backend/varfish/vueapp/urls.py
  • backend/variants/migrations/0109_alter_clearexpiredexportedfilesbgjob_bg_job_and_more.py
  • backend/variants/migrations/0111_create_variant_summary.py
  • backend/variants/tests/helpers.py
  • backend/variants/tests/test_file_export.py
  • backend/variants/tests/test_permissions_ajax.py
  • backend/variants/tests/test_permissions_ajax_annos.py
  • backend/variants/tests/test_permissions_api.py
  • backend/variants/tests/test_ui.py
  • backend/variants/urls/annos.py
  • frontend/src/svs/components/SvFilterForm/GenesRegionsPane.vue
  • frontend/src/svs/views/StrucvarFilterLegacy/StrucvarFilterLegacy.vue
  • frontend/src/varfish/components/FilterForm/DevPane.vue
  • frontend/src/variants/components/FilterForm/ClinvarPane.vue
  • frontend/src/variants/components/FilterForm/EffectPane.vue
  • frontend/src/variants/components/FilterForm/FlagsPane.vue
  • frontend/src/variants/components/FilterForm/FrequencyPane.vue
  • frontend/src/variants/components/FilterForm/GenesRegionsPane.vue
  • frontend/src/variants/components/FilterForm/QualityPane.vue
  • frontend/src/variants/components/QueryPresets/SetEditor.vue
  • frontend/src/variants/components/QueryPresets/SetProperties.vue
🧰 Additional context used
🪛 Ruff
backend/variants/models/maintenance.py

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

🔇 Additional comments (99)
backend/varfish/templates/users/login.html (1)

1-1: LGTM! Verify 'projectroles/login.html' exists and review custom functionality

The change to extend 'projectroles/login.html' aligns with the PR objective of upgrading to sodar core v1. This simplifies login functionality and promotes consistency across the application.

Please run the following script to verify the existence of 'projectroles/login.html':

#!/bin/bash
# Description: Verify the existence of 'projectroles/login.html'

# Test: Check if 'projectroles/login.html' exists
if fd --type f --hidden --no-ignore "login.html" | grep -q "projectroles/login.html"; then
    echo "The 'projectroles/login.html' template exists."
else
    echo "Warning: The 'projectroles/login.html' template was not found."
fi

Additionally, please review if any custom login functionality from the previous implementation needs to be preserved or migrated to the new template.

backend/varannos/urls.py (7)

1-1: LGTM: Import statement updated correctly.

The import statement has been correctly updated to use django.urls instead of django.conf.urls, which is consistent with the transition to the path() function.


7-11: LGTM: URL pattern updated correctly for VarAnnoSetListView.

The URL pattern has been successfully updated to use path() with a UUID path converter. This change improves readability and maintainability of the code.


12-16: LGTM: URL pattern updated correctly for VarAnnoSetDetailView.

The URL pattern for VarAnnoSetDetailView has been properly updated to use path() with a UUID path converter, maintaining consistency with the previous pattern update.


22-26: LGTM: API URL pattern updated correctly for VarAnnoSetListCreateApiView.

The API URL pattern for VarAnnoSetListCreateApiView has been correctly updated to use path() with a UUID path converter, maintaining consistency with the previous updates.


27-31: LGTM: API URL pattern updated correctly for VarAnnoSetRetrieveUpdateDestroyApiView.

The API URL pattern for VarAnnoSetRetrieveUpdateDestroyApiView has been properly updated to use path() with a UUID path converter, maintaining consistency with the previous updates.


32-36: LGTM: API URL pattern updated correctly for VarAnnoSetEntryListCreateApiView.

The API URL pattern for VarAnnoSetEntryListCreateApiView has been correctly updated to use path() with a UUID path converter, maintaining consistency with the previous updates.


37-41: LGTM: All URL patterns successfully updated to use path() function.

The API URL pattern for VarAnnoSetEntryRetrieveUpdateDestroyApiView, along with all other URL patterns in this file, have been correctly updated to use the path() function with appropriate UUID path converters. These changes improve code readability and align with modern Django practices.

Overall, the transition from url() to path() has been consistently applied throughout the file, enhancing maintainability and clarity of the URL routing definitions.

backend/importer/urls.py (17)

4-4: LGTM: Updated import statement for modern Django URL routing.

The change from url to path is correct and aligns with Django's current best practices for URL configuration.


11-15: LGTM: Updated URL pattern for "import-info" using path().

The conversion from url() to path() is correct. The new syntax is cleaner and easier to read while maintaining the same functionality.


12-16: LGTM: Improved URL pattern for "import-case-job-detail" using path() and UUID converters.

The conversion from url() to path() is correct and well-implemented. The use of <uuid:project> and <uuid:job> instead of regex patterns is a significant improvement, leveraging Django's built-in path converters for UUIDs. This change enhances readability and type safety.


20-24: LGTM: Updated API URL pattern for "api-case-import-info-list-create" using path().

The conversion from url() to path() is correct. The use of <uuid:project> improves readability and type safety compared to the previous regex pattern.


25-29: LGTM: Updated API URL pattern for "api-case-import-info-retrieve-update-destroy" using path().

The conversion from url() to path() is correct. The use of <uuid:project> and <uuid:caseimportinfo> improves readability and type safety compared to the previous regex patterns.


30-34: LGTM: Updated API URL pattern for "api-variant-set-import-info-list-create" using path().

The conversion from url() to path() is correct. The use of <uuid:caseimportinfo> improves readability and type safety compared to the previous regex pattern.


35-39: LGTM: Updated API URL pattern for "api-variant-set-import-info-retrieve-update-destroy" using path().

The conversion from url() to path() is correct. The use of <uuid:caseimportinfo> and <uuid:variantsetimportinfo> improves readability and type safety compared to the previous regex patterns.


40-44: LGTM: Updated API URL pattern for "api-bam-qc-file-list-create" using path().

The conversion from url() to path() is correct. The use of <uuid:caseimportinfo> improves readability and type safety compared to the previous regex pattern.


45-49: LGTM: Updated API URL pattern for "api-bam-qc-file-retrieve-destroy" using path().

The conversion from url() to path() is correct. The use of <uuid:caseimportinfo> and <uuid:bamqcfile> improves readability and type safety compared to the previous regex patterns.


50-54: LGTM: Updated API URL pattern for "api-case-gene-annotation-file-list-create" using path().

The conversion from url() to path() is correct. The use of <uuid:caseimportinfo> improves readability and type safety compared to the previous regex pattern.


55-59: LGTM: Updated API URL pattern for "api-case-gene-annotation-file-retrieve-destroy" using path().

The conversion from url() to path() is correct. The use of <uuid:caseimportinfo> and <uuid:casegeneannotationfile> improves readability and type safety compared to the previous regex patterns.


60-64: LGTM: Updated API URL pattern for "api-genotype-file-list-create" using path().

The conversion from url() to path() is correct. The use of <uuid:variantsetimportinfo> improves readability and type safety compared to the previous regex pattern.


65-69: LGTM: Updated API URL pattern for "api-genotype-file-retrieve-destroy" using path().

The conversion from url() to path() is correct. The use of <uuid:variantsetimportinfo> and <uuid:genotypefile> improves readability and type safety compared to the previous regex patterns.


70-74: LGTM: Updated API URL pattern for "api-effects-file-list-create" using path().

The conversion from url() to path() is correct. The use of <uuid:variantsetimportinfo> improves readability and type safety compared to the previous regex pattern.


75-79: LGTM: Updated API URL pattern for "api-effects-file-retrieve-destroy" using path().

The conversion from url() to path() is correct. The use of <uuid:variantsetimportinfo> and <uuid:effectsfile> improves readability and type safety compared to the previous regex patterns.


80-84: LGTM: Updated API URL pattern for "api-db-info-file-list-create" using path().

The conversion from url() to path() is correct. The use of <uuid:variantsetimportinfo> improves readability and type safety compared to the previous regex pattern.


85-89: LGTM: Updated API URL pattern for "api-db-info-file-retrieve-destroy" using path().

The conversion from url() to path() is correct. The use of <uuid:variantsetimportinfo> and <uuid:databaseinfofile> improves readability and type safety compared to the previous regex patterns.

Overall Summary:
All URL patterns in this file have been successfully updated from url() to path(). The changes consistently use UUID converters instead of regex patterns, which improves code readability and type safety. These updates align with Django's best practices for URL routing.

backend/variants/models/maintenance.py (5)

122-134: SQL query for materialized view management looks good

The SQL_OUTER query is well-structured and includes all necessary operations for managing the SmallVariantSummary materialized view:

  • Dropping the existing view if it exists
  • Creating the new materialized view
  • Creating appropriate indexes for performance optimization

The use of DROP ... IF EXISTS is a good practice to prevent errors during execution.


137-180: SQL query for data aggregation is well-structured

The SQL_INNER query is well-designed and uses appropriate SQL features:

  • The CTE for excluding cases based on project settings improves readability and potentially performance.
  • The use of window functions and aggregations for calculating genotype counts is correct.

Regarding a previous comment about using parameterized queries:
While it's generally a good practice to use parameterized queries, in this case, both SQL_OUTER and SQL_INNER are hardcoded constants within the file. There's no risk of SQL injection as long as these remain static. However, if any part of these queries becomes dynamic or user-influenced in the future, consider using parameterized queries for better security practices.


114-188: Summary of changes: Improved management of SmallVariantSummary materialized view

The changes introduced in this file significantly enhance the management of the SmallVariantSummary materialized view:

  1. New function drop_variants_smallvariantsummary allows for easy removal of the view.
  2. Well-structured SQL queries SQL_OUTER and SQL_INNER define the view creation and data aggregation logic.
  3. New function create_variants_smallvariantsummary facilitates the creation of the view.

These additions provide more granular control over the materialized view's lifecycle and improve the overall maintainability of the codebase. The suggested refactorings to combine with statements will further enhance code readability.

Great job on these improvements!

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


114-119: 🛠️ Refactor suggestion

Combine nested with statements for improved readability

As suggested in a previous review, we can improve readability by combining the nested with statements:

 def drop_variants_smallvariantsummary():
     """Drop the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute("DROP MATERIALIZED VIEW IF EXISTS variants_smallvariantsummary")

This change maintains the same functionality while simplifying the code structure.

🧰 Tools
🪛 Ruff

117-118: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)


183-188: 🛠️ Refactor suggestion

Combine nested with statements for improved readability

As suggested in a previous review, we can improve readability by combining the nested with statements:

 def create_variants_smallvariantsummary():
     """Create the ``SmallVariantSummary`` materialized view."""

-    with transaction.atomic():
-        with connection.cursor() as cursor:
+    with transaction.atomic(), connection.cursor() as cursor:
         cursor.execute(SQL_OUTER % SQL_INNER)

This change maintains the same functionality while simplifying the code structure.

🧰 Tools
🪛 Ruff

186-187: Use a single with statement with multiple contexts instead of nested with statements

Combine with statements

(SIM117)

.github/workflows/main.yml (2)

174-174: LGTM: Consistent Python version update.

The Python version for the Python-Lint job has been updated to 3.11, which is consistent with the change in the Python-Test job. This ensures that linting and testing are performed using the same Python version.


122-122: Verify compatibility with Python 3.11.

The Python version for the Python-Test job has been upgraded from 3.10.13 to 3.11.

Please ensure that:

  1. All project dependencies are compatible with Python 3.11.
  2. Any Python 3.11-specific features or syntax are not used if backward compatibility is required.
  3. The Pipfile and Pipfile.lock have been updated to reflect this change.

Run the following script to check if the Python version is consistently set across the project:

#!/bin/bash
# Check Python version consistency
echo "Python version in .github/workflows/main.yml:"
grep 'python-version' .github/workflows/main.yml
echo "Python version in Pipfile:"
grep 'python_version' backend/Pipfile
echo "Python version in Dockerfile:"
grep 'FROM python' Dockerfile
utils/docker/Dockerfile (8)

169-169: Approved: Addition of Bootstrap CSS map file

The inclusion of the Bootstrap CSS map file (bootstrap.min.css.map) is a positive change. This will improve the debugging experience by allowing developers to inspect the original source styles in the browser's developer tools.


177-177: Approved: Addition of Bootstrap JS bundle map file

The inclusion of the Bootstrap JS bundle map file (bootstrap.bundle.min.js.map) is beneficial. This will enhance the debugging experience by allowing developers to inspect the original source JavaScript in the browser's developer tools.


185-185: Approved: Addition of bootstrap-select JS map file

The inclusion of the bootstrap-select JS map file (bootstrap-select.min.js.map) is a welcome addition. This will improve the debugging experience specifically for the bootstrap-select component, allowing developers to inspect the original source code in the browser's developer tools.


188-191: Approved: Addition of jsrender and axios map files

The inclusion of map files for jsrender (jsrender.min.js.map) and axios (axios.min.map) is beneficial. These additions will enhance the debugging experience for templating and HTTP request-related code, allowing developers to inspect the original source in the browser's developer tools.


Line range hint 1-224: Overall assessment: Positive improvements to build process and debugging capabilities

The changes made to this Dockerfile are well-considered and beneficial to the project:

  1. Upgrading to Python 3.11 and PostgreSQL client 14 keeps the project current with the latest stable versions.
  2. The addition of various map files (CSS, JS, and library-specific) significantly enhances the debugging experience for developers.

These updates contribute to a more maintainable and developer-friendly codebase. Ensure that all dependencies are compatible with the new Python version and that the database server is compatible with the updated PostgreSQL client.


59-66: Approved: PostgreSQL client upgrade to version 14

Upgrading the PostgreSQL client to version 14 is a good practice for maintaining compatibility with newer server versions. This change aligns with modern PostgreSQL deployments.

Please ensure that this client version is compatible with your PostgreSQL server version. Run the following script to check the PostgreSQL server version:

#!/bin/bash
# Description: Check PostgreSQL server version compatibility

# Test: Connect to the PostgreSQL server and retrieve its version
PGPASSWORD=$POSTGRES_PASSWORD psql -h $POSTGRES_HOST -U $POSTGRES_USER -d $POSTGRES_DB -c "SELECT version();"

182-182: Approved: Addition of Sentry tracing bundle map file

The inclusion of the Sentry tracing bundle map file (bundle.tracing.min.js.map) is a positive addition. This will enhance error tracking and performance monitoring capabilities in the application.

Please ensure that Sentry is properly configured in your application settings. Run the following script to check for Sentry configuration:

#!/bin/bash
# Description: Check for Sentry configuration in Django settings

# Test: Search for Sentry configuration in Django settings files
grep -R "sentry" config/settings/

42-42: Approved: Python base image upgrade to 3.11

The upgrade to Python 3.11 is a positive change that can bring performance improvements and new features. This aligns with the updates observed in other files like backend/Pipfile.

Please ensure all dependencies are compatible with Python 3.11. Run the following script to check for any potential compatibility issues:

✅ Verification successful

Verified: Python 3.11 compatibility

All dependencies are compatible with Python 3.11, and no compatibility warnings or errors were found during installation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for Python 3.11 compatibility issues in requirements files.

# Test: Search for any compatibility warnings or errors in pip install output
pipenv install 2>&1 | grep -i "compatibility\|warning\|error"

Length of output: 184


Script:

#!/bin/bash
# Description: Check for Python 3.11 compatibility issues in Pipfile.lock.

# Navigate to the repository root
cd "$(git rev-parse --show-toplevel)" || exit

# Attempt to install dependencies with Python 3.11 and capture any compatibility warnings or errors
pipenv --python 3.11 install 2>&1 | grep -i "compatibility\|warning\|error"

Length of output: 129

backend/varfish/users/management/commands/initdev.py (3)

Line range hint 1-489: Overall review: Well-structured command with consistent terminology update

The initdev.py file contains a well-implemented Django management command for initializing a development instance. The change from app_name to plugin_name is consistent with the project's updated terminology. The command's structure and functionality appear robust, covering various aspects of setting up a development environment including users, projects, cases, and import jobs.

The terminology update seems to be part of a larger project-wide change. To ensure full consistency:

  1. Verify that all instances of app_name have been updated across the project.
  2. Confirm that the AppSettingAPI and related components have been updated to use plugin_name.
  3. Update project documentation to reflect this terminology change.

These steps will help maintain consistency and prevent potential confusion for developers working on the project.


285-285: Verify consistency with AppSettingAPI implementation

While the change from app_name to plugin_name is correct, it's important to ensure that this change is consistent with the AppSettingAPI implementation and other parts of the codebase that interact with project settings.

Let's check the AppSettingAPI class implementation and its usage across the project:

#!/bin/bash
# Search for AppSettingAPI class definition
rg "class AppSettingAPI" --type py

# Search for AppSettingAPI.set() method calls
rg "AppSettingAPI.*set\(" --type py

Please review the results to confirm that this change aligns with the overall implementation and usage of AppSettingAPI.


285-285: LGTM: Terminology update from app_name to plugin_name

The change from app_name to plugin_name in the AppSettingAPI.set() method call is correct and aligns with the project's updated naming conventions.

To ensure consistency, let's check for any remaining instances of app_name in this file:

✅ Verification successful

Verified: Terminology update confirmed

All instances of app_name have been successfully updated to plugin_name in backend/varfish/users/management/commands/initdev.py. No further action is required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for remaining instances of 'app_name' in this file
rg "app_name" backend/varfish/users/management/commands/initdev.py

# Search for instances of 'plugin_name' to verify the new terminology is being used
rg "plugin_name" backend/varfish/users/management/commands/initdev.py

Length of output: 168


Script:

#!/bin/bash
# Search for remaining instances of 'app_name' in this file
rg 'app_name' backend/varfish/users/management/commands/initdev.py

# Search for instances of 'plugin_name' to verify the new terminology is being used
rg 'plugin_name' backend/varfish/users/management/commands/initdev.py

Length of output: 188

backend/cases/tests/test_views_ajax.py (3)

8-8: Update to import statement

The import statement has been updated to use ProjectAPIPermissionTestBase instead of TestProjectAPIPermissionBase. This change is consistent with the modifications in the test class signatures throughout the file.


Line range hint 1-697: Summary of changes in test_views_ajax.py

The main change in this file is the consistent update of the base class for all test classes from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This modification appears to be part of a broader refactoring effort to standardize the testing framework across the project.

Key points:

  1. The change is applied consistently across all test classes in the file.
  2. There are no significant alterations to the test logic or structure.
  3. The file maintains good test coverage for various AJAX views related to cases.

These changes should improve consistency in the testing framework without introducing any functional changes to the tests themselves. However, it's important to ensure that this base class change is applied consistently across all relevant test files in the project.


41-41: Consistent update of base class for test classes

All test classes in this file have been updated to inherit from ProjectAPIPermissionTestBase instead of TestProjectAPIPermissionBase. This change appears to be part of a broader refactoring effort to standardize the testing framework across the project.

To ensure this change is consistent across the project, please run the following command:

This will help verify that all test classes have been updated to use the new base class.

Also applies to: 150-150, 228-228, 293-293, 363-363, 417-417, 488-488, 516-516, 599-599, 627-627, 667-667

✅ Verification successful

All test classes consistently inherit from ProjectAPIPermissionTestBase.

All instances of TestProjectAPIPermissionBase have been successfully updated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining uses of TestProjectAPIPermissionBase
rg "class \w+\(TestProjectAPIPermissionBase\)" -g "*.py"

Length of output: 58

backend/variants/tests/test_views_ajax_presets.py (8)

3-3: Base class updated to ProjectAPIPermissionTestBase

The base class for permission testing has been updated from TestProjectAPIPermissionBase to ProjectAPIPermissionTestBase. This change is consistent with the modifications mentioned in the AI-generated summary for other test files.


26-26: ApiViewTestBase now inherits from ProjectAPIPermissionTestBase

The ApiViewTestBase class has been updated to inherit from ProjectAPIPermissionTestBase. This change aligns with the base class update and ensures consistent permission testing across the application.


122-131: Improved test case for cloning factory presets

The changes in this test method enhance its effectiveness:

  1. Removal of mocking simplifies the test and ensures it's testing the actual behavior of the view.
  2. Using "any" instead of "the-name" makes the test more flexible.
  3. Direct assertion of the response status and content provides a more accurate test of the API's behavior.

These modifications result in a more robust and maintainable test case.


146-155: Consistent improvement in cloning other presets test

The changes in this test method mirror the improvements seen in the previous method:

  1. Removal of mocking for a more direct test of the view's behavior.
  2. Correct use of the "frequencypresets" parameter in the URL reversal.
  3. Direct assertion of the response status and content.

These changes maintain consistency across test methods and improve the overall quality of the test suite.


244-253: Consistent improvement in impact presets cloning test

The changes in this test method maintain the pattern of improvements seen in previous methods:

  1. Removal of mocking for more direct testing.
  2. Use of "any" in the URL reversal for increased flexibility.
  3. Direct assertion of the response status and content.

This consistency across different preset types (Frequency, Impact) improves the overall structure and reliability of the test suite.


268-277: Maintained consistency in impact presets cloning from other

The changes in this test method continue the pattern of improvements:

  1. Removal of mocking for direct testing of the view's behavior.
  2. Correct use of the "impactpresets" parameter in the URL reversal.
  3. Direct assertion of the response status and content.

This ongoing consistency across different preset types and cloning methods (factory and other) significantly enhances the maintainability and reliability of the test suite.


488-497: Consistent improvement with a note on parameter naming

The changes in this test method continue the pattern of improvements seen in previous methods:

  1. Removal of mocking for direct testing.
  2. Direct assertion of the response status and content.

However, there's a notable difference in the URL reversal:
3. Use of "whole_genome" instead of "any" in the name parameter.

While the overall changes improve the test, the use of "whole_genome" differs from the "any" used in other factory preset cloning tests. Is this intentional, or should it be consistent with other similar tests?


512-521: Maintained consistency in chromosome presets cloning from other

The changes in this test method continue the established pattern of improvements:

  1. Removal of mocking for direct testing of the view's behavior.
  2. Correct use of the "chromosomepresets" parameter in the URL reversal.
  3. Direct assertion of the response status and content.

This ongoing consistency across different preset types and cloning methods (factory and other) further reinforces the maintainability and reliability of the test suite.

backend/variants/tests/test_permissions_ajax_presets.py (19)

Line range hint 64-139: LGTM! Consistent with the refactoring.

The change to inherit from ProjectAPIPermissionTestBase is consistent with the overall refactoring effort. The test structure and logic remain intact.


Line range hint 140-165: LGTM! Consistent implementation.

The change to inherit from ProjectAPIPermissionTestBase is in line with the refactoring. The test logic remains unchanged and appropriate.


Line range hint 167-193: LGTM! Consistent with the refactoring pattern.

The change to inherit from ProjectAPIPermissionTestBase aligns with the overall refactoring effort. The test structure and logic are maintained.


Line range hint 195-240: LGTM! Consistent implementation for Impact Presets.

The change to inherit from ProjectAPIPermissionTestBase is in line with the refactoring. The test structure and logic for Impact Presets remain appropriate.


Line range hint 242-317: LGTM! Consistent refactoring for Impact Presets.

The change to inherit from ProjectAPIPermissionTestBase aligns with the overall refactoring effort. The test structure and logic for retrieving, updating, and destroying Impact Presets are maintained.


Line range hint 318-343: LGTM! Consistent implementation for cloning factory defaults.

The change to inherit from ProjectAPIPermissionTestBase is in line with the refactoring. The test logic for cloning factory defaults of Impact Presets remains appropriate.


Line range hint 373-418: LGTM! Consistent implementation for Quality Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user are consistent with the refactoring. The test structure and logic for Quality Presets remain appropriate.


Line range hint 420-495: LGTM! Consistent refactoring for Quality Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user align with the overall refactoring effort. The test structure and logic for retrieving, updating, and destroying Quality Presets are maintained.


Line range hint 496-520: LGTM! Consistent implementation for cloning factory defaults.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user are in line with the refactoring. The test logic for cloning factory defaults of Quality Presets remains appropriate.


Line range hint 521-547: LGTM! Consistent refactoring for cloning Quality Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user align with the overall refactoring effort. The test logic for cloning Quality Presets remains appropriate.


Line range hint 549-595: LGTM! Consistent implementation for Chromosome Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user are consistent with the refactoring. The test structure and logic for Chromosome Presets remain appropriate.


Line range hint 596-671: LGTM! Consistent refactoring for Chromosome Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user align with the overall refactoring effort. The test structure and logic for retrieving, updating, and destroying Chromosome Presets are maintained.


Line range hint 672-698: LGTM! Consistent implementation for cloning factory defaults.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user are in line with the refactoring. The test logic for cloning factory defaults of Chromosome Presets remains appropriate.


Line range hint 699-725: LGTM! Consistent refactoring for cloning Chromosome Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user align with the overall refactoring effort. The test logic for cloning Chromosome Presets remains appropriate.


Line range hint 727-773: LGTM! Consistent implementation for Flags Etc Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user are consistent with the refactoring. The test structure and logic for Flags Etc Presets remain appropriate.


Line range hint 774-849: LGTM! Consistent refactoring for Flags Etc Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user align with the overall refactoring effort. The test structure and logic for retrieving, updating, and destroying Flags Etc Presets are maintained.


Line range hint 850-876: LGTM! Consistent implementation for cloning factory defaults.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user are in line with the refactoring. The test logic for cloning factory defaults of Flags Etc Presets remains appropriate.


Line range hint 877-903: LGTM! Consistent refactoring for cloning Flags Etc Presets.

The change to inherit from ProjectAPIPermissionTestBase and the use of self.owner_as.user align with the overall refactoring effort. The test logic for cloning Flags Etc Presets remains appropriate.


Line range hint 905-1270: LGTM! Consistent refactoring across all remaining test classes.

The changes in all remaining test classes (TestQuickPresetsListCreateAjaxView, TestQuickPresetsRetrieveUpdateDestroyAjaxView, TestQuickPresetsCloneOtherView, TestPresetSetListCreateAjaxView, TestPresetSetListAllAjaxView, TestPresetSetRetrieveUpdateDestroyAjaxView, TestPresetSetCloneFactoryDefaultsView, TestPresetSetCloneOtherView) are consistent with the overall refactoring effort:

  1. All classes now inherit from ProjectAPIPermissionTestBase.
  2. The user reference has been updated to self.owner_as.user consistently.
  3. Test structures and logic remain unchanged and appropriate for each preset type and operation.

These changes maintain the integrity of the tests while aligning with the new base class implementation.

backend/cases_import/models/executors.py (2)

139-139: LGTM: Consistent usage of "plugin_name".

The change from "app_name" to "plugin_name" is consistent with the update mentioned in the previous review comment. This change aligns with the updated naming conventions across the codebase.


Line range hint 1010-1016: LGTM: Improved clarity in action handling.

The updated _run method now clearly separates the logic for delete and create/update actions. This change enhances code readability and maintainability.

backend/varfish/tests/drf_openapi_schema/varfish_api_schema.yaml (3)

Line range hint 1-7: LGTM: OpenAPI version and basic info are correct.

The OpenAPI version (3.0.3) and basic information about the VarFish API are correctly defined.


Line range hint 444-487: Improved API structure with standardized UUID usage.

The changes to use UUID formats instead of regex patterns for various identifiers (e.g., case, caseanalysis, casephenotypeterms) across multiple endpoints is a positive improvement. This standardization enhances consistency and ensures unique identification across the API. The addition of new endpoints for EnrichmentKit and TargetBedFile resources also expands the API's functionality.

Benefits:

  1. Improved consistency across the API
  2. Enhanced uniqueness for resource identifiers
  3. Easier integration with client applications due to standardized ID formats

Also applies to: 529-582, 624-665, 693-733, 772-792, 847-882, 912-954, 995-1020


Line range hint 1-9999: Overall, excellent improvements to the VarFish API schema.

The changes made to this OpenAPI schema file significantly enhance the VarFish API's structure, consistency, and capabilities. Key improvements include:

  1. Standardization of identifier formats to UUIDs across multiple endpoints.
  2. Addition of new endpoints for EnrichmentKit and TargetBedFile resources.
  3. Comprehensive updates to component schemas reflecting the evolving data model.
  4. Maintenance of consistent security schemes and overall file structure.

These changes will likely improve the API's usability, maintainability, and integration capabilities. The attention to detail in maintaining consistency throughout the file is commendable.

backend/variants/migrations/0110_drop_variant_summary.py (5)

8-13: Function is_migration_applied is correctly implemented

The function appropriately checks if a specific migration has been applied, handling any ProgrammingError exceptions that may arise if the migration table does not exist.


16-25: Dynamic determination of run_before dependencies

The logic for setting run_before based on the migration state ensures proper execution order, accommodating fresh installations and existing setups efficiently.


28-40: SQL statements for materialized view are well-structured

The SQL_OUTER script accurately drops and recreates the variants_smallvariantsummary materialized view, including the creation of necessary indexes for performance optimization.


43-86: Efficient aggregation in the SQL_INNER query

The inner SQL query effectively aggregates variant data while excluding cases based on project settings, utilizing common table expressions for clarity and performance.


89-99: Consistent operations definition

The conditional assignment of operations based on settings.IS_TESTING ensures that test environments are not affected by the migration, which is appropriate for maintaining testing integrity.

backend/svs/urls.py (3)

2-2: Correctly Importing re_path for Regex URL Patterns

The addition of re_path to the imports is appropriate for handling regex-based URL patterns used later in the file.


11-128: Updated URL Patterns Using path() with Appropriate Converters

The URL patterns have been accurately updated to use path() with relevant path converters like <uuid:project>, <uuid:job>, <uuid:case>, <uuid:svquery>, etc. This enhances readability and aligns with Django's recommended practices for URL routing.


133-140: Appropriate Use of re_path() for Complex URL Patterns

The use of re_path() with regex patterns for the worker and tracks URLs is suitable, as it allows for more complex URL matching that isn't easily achieved with path().

backend/cases/urls.py (5)

104-106: Inconsistent Route Prefix in API URL Pattern

The route on line 104 starts with "ajax/" within the api_urlpatterns section. For consistency, it should be "api/" to match the other API routes.


129-131: Inconsistent View Reference in API URL Pattern

The view on line 129 references an AJAX view (views_ajax.CaseGeneAnnotationListAjaxView) within the API URL patterns. It should reference the corresponding API view (views_api.CaseGeneAnnotationListApiView) to maintain consistency.


134-136: Inconsistent View Reference in API URL Pattern

The view on line 134 uses an AJAX view instead of an API view. Please update it to views_api.CaseAlignmentStatsListApiView to ensure consistent API behavior.


139-141: Inconsistent View Reference in API URL Pattern

On line 139, the pattern references an AJAX view within the api_urlpatterns. It should be updated to use views_api.SampleVariantStatisticsListApiView for consistency.


144-146: Inconsistent View Reference in API URL Pattern

The view on line 144 references an AJAX view in the API URL patterns. To maintain a clear separation between AJAX and API endpoints, update it to views_api.PedigreeRelatednessListApiView.

backend/variants/urls/presets.py (2)

3-3: Import statement updated appropriately

The import statement has been correctly updated to use from django.urls import path, which is suitable for the path() function used in the URL configurations.


12-163: URL patterns updated to use path() with correct converters

The URL patterns have been successfully transitioned from using url() to path(). The use of path converters like <uuid:...> and <slug:...> is appropriate and enhances the readability and maintainability of the URL configurations.

backend/config/urls.py (3)

29-70: URL patterns successfully updated to use path()

The migration from url() to path() in the URL patterns enhances readability and aligns with Django 2.0+ best practices.


94-140: Correct use of re_path() for regex-based proxy URLs

The transition to re_path() for the proxy URL patterns ensures proper handling of regex patterns in the routes.


198-198: Conditional inclusion of debug toolbar URLs

Including the debug toolbar URLs when DEBUG is True and checking if "debug_toolbar" is in INSTALLED_APPS is appropriate and follows best practices.

backend/variants/urls/__init__.py (1)

Line range hint 1-450: The URL patterns have been updated appropriately

The conversion from url() to path() with appropriate parameter converters modernizes the URL configurations and aligns with current Django best practices. The use of <uuid:...> converters ensures that only valid UUIDs are accepted, maintaining strict parameter validation.

backend/config/settings/base.py (2)

80-83: Addition of 'social_django' to THIRD_PARTY_APPS

Including 'social_django' in THIRD_PARTY_APPS is appropriate and necessary for enabling OIDC authentication support.


438-438: Verify the change of 'ADMIN_URL' from a regex pattern to a string

Changing ADMIN_URL from r"^admin/" to "admin/" may affect URL patterns in your project. Ensure that this change is compatible with your URL configurations and does not introduce any unexpected behavior in admin URL resolution.

@@ -14,7 +14,7 @@ jobs:
- 6379:6379

postgres:
image: postgres:14
image: postgres:16
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Update remaining PostgreSQL references to version 16

The PostgreSQL version has been upgraded to 16 in .github/workflows/main.yml, but references to version 14 still exist in the following files:

  • CHANGELOG.md
  • utils/docker/Dockerfile

Please update all PostgreSQL references to ensure consistency and compatibility across the codebase.

🔗 Analysis chain

Verify compatibility with PostgreSQL 16.

The PostgreSQL image has been upgraded from version 14 to 16. This is a major version upgrade that may introduce breaking changes.

Please ensure that:

  1. The application is compatible with PostgreSQL 16.
  2. All database migrations have been tested with the new version.
  3. Performance impact, if any, has been evaluated.

Run the following script to check for any PostgreSQL version-specific code or comments in the codebase:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for PostgreSQL version-specific code or comments
rg -i 'postgres(ql)?\s*(9|10|11|12|13|14|15)' --type py

Length of output: 518


Script:

#!/bin/bash
# Search for PostgreSQL version-specific code or comments across all files
rg -i 'postgres(ql)?\s*(9|10|11|12|13|14|15)' 

Length of output: 166

Comment on lines +610 to +619
with self.login(self.superuser):
response = self.client.post(
reverse(
"variants:ajax-flagsetcpresets-clonefactorypresets",
kwargs={"name": "defaults"},
),
data=data,
)
self.assertEqual(response.status_code, 201)
mock_create.assert_called_with("the-name", data["label"], self.presetset)
self.assertEqual(response.json()["presetset"], str(self.presetset.sodar_uuid))
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent "name" Parameters in Factory Preset Cloning Tests

The shell script execution revealed inconsistencies in the "name" parameters across factory preset cloning tests:

  • backend/variants/tests/test_views_ajax_presets.py:492 uses "whole_genome"
  • backend/variants/tests/test_views_ajax_presets.py:614 uses "defaults"

Please review these instances to confirm whether the differing "name" values are intentional or should be standardized.

🔗 Analysis chain

Consistent improvement with another note on parameter naming

The changes in this test method maintain the pattern of improvements:

  1. Removal of mocking for direct testing.
  2. Direct assertion of the response status and content.

However, there's another difference in the URL reversal:
3. Use of "defaults" instead of "any" in the name parameter.

While the overall changes improve the test, the use of "defaults" differs from the "any" used in some other factory preset cloning tests. This is similar to the "whole_genome" case noted earlier. It might be worth verifying if these differences are intentional or if there should be consistency across all factory preset cloning tests.

To check the consistency of name parameters across all factory preset cloning tests, you can run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check consistency of name parameters in factory preset cloning tests

echo "Checking name parameters in factory preset cloning tests:"
rg -n 'kwargs=\{"name": "([^"]+)"\}' backend/variants/tests/test_views_ajax_presets.py

Length of output: 467

@stolpeo stolpeo assigned stolpeo and unassigned stolpeo Oct 22, 2024
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.

Upgrade to sodar core v1
2 participants