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

Fix legacy support for outdated displayName field of datasets #8263

Merged
merged 3 commits into from
Dec 5, 2024

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented Dec 5, 2024

Fixes a compatibility bug introduced in #8075. wk.Dataset.open_remote("...").display_name = "fancy name" did not result in any changes due to two bugs:

  1. displayName was no longer part of the ds objects returned by the API, even in legacy routes.
  2. When updating a dataset, the name given by the update request took precedence. This discarded all updates to the ds name done via displayName as "old" clients like wklibs always send the current name of the ds and the updated displayName. Therefore, the displayName should take precedence. Clients using new API version should no longer send the `displayName prop and thus renaming with them should also still work.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • Test whether renaming a dataset via the web UI works
  • with wklibs run the following and check if the console shows the success of the renaming:
    with webknossos_context(token="<token>", url="http://localhost:9000"):
        ds = Dataset.open_remote("l4_sample_small")
        print("current ds name", ds.display_name)
        ds.display_name = "blue"
        print("name after renaming", ds.display_name)
  • run that script on another branch again. Each print should have a name None as the displayName is not included in the json format of the dataset. This should be fixed in this pr.

Issues:


(Please delete unneeded items, merge only when none are left open)

Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Warning

Rate limit exceeded

@MichaelBuessemeyer has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between cc72de1 and 3207ef8.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces changes to the DatasetController and LegacyApiController classes. In the DatasetController, the update method's logic for determining the dataset name is modified to prioritize legacyDatasetDisplayName over datasetName. The LegacyApiController sees the addition of a new method, migrateDatasetJsonToOldFormat, which alters JSON structures for datasets and integrates with existing methods to enhance legacy data handling. Overall, the changes maintain existing functionalities while refining how dataset names and JSON formats are processed.

Changes

File Change Summary
app/controllers/DatasetController.scala Modified update method to prioritize legacyDatasetDisplayName over datasetName. updatePartial method referenced but unchanged.
app/controllers/LegacyApiController.scala Added private def migrateDatasetJsonToOldFormat(jsResult: JsObject): Fox[JsObject]. Updated readDatasetV8, updateDatasetV8, and other methods to use replaceInResult and handle legacy data formats.

Possibly related PRs

Suggested reviewers

  • normanrz
  • fm3

Poem

🐇 In the meadow where datasets play,
A new name shines bright as day.
With JSONs transformed, they dance and twirl,
Legacy whispers in a digital swirl.
Hops of joy for changes made,
In the code, a bright parade! 🌼


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.

Comment on lines 340 to 345
withJsonBodyUsing(datasetPublicReads) {
case (description, datasetName, legacyDatasetDisplayName, sortingKey, isPublic, tags, metadata, folderId) => {
val name = if (datasetName.isDefined) datasetName else legacyDatasetDisplayName
val name = if (legacyDatasetDisplayName.isDefined) legacyDatasetDisplayName else datasetName
for {
datasetIdValidated <- ObjectId.fromString(datasetId)
dataset <- datasetDAO.findOne(datasetIdValidated) ?~> notFoundMessage(datasetIdValidated.toString) ~> NOT_FOUND
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the precedence issue described in the pr description

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)
CHANGELOG.unreleased.md (1)

35-35: Enhance the changelog entry to better describe the fix.

The current entry could be more descriptive about the specific issues being fixed. Consider expanding it to:

-Fix read and update dataset route for versions 8 and lower. [#8263](https://github.com/scalableminds/webknossos/pull/8263)
+Fixed legacy support for dataset displayName field in read and update routes for API versions 8 and lower, ensuring proper handling of dataset renaming via displayName. [#8263](https://github.com/scalableminds/webknossos/pull/8263)

This provides more context about:

  • The specific field affected (displayName)
  • The nature of the fix (legacy support)
  • The impact (proper handling of dataset renaming)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 20f3afe and cc72de1.

📒 Files selected for processing (1)
  • CHANGELOG.unreleased.md (1 hunks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants