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: LEAP-634: Actualize label config validation #5313

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

Gondragos
Copy link
Collaborator

@Gondragos Gondragos commented Jan 19, 2024

Config validation didn't take into account many tags and their attributes. This PR might fix this.

It also fixes nested Choice validation.

It also will fix validation messages. (Usually there is no path at all and sometimes it doesn't tell about the problem itself)

PR fulfills these requirements

  • Tests for the changes have been added/updated
  • Docs have been added/updated
  • Best efforts were made to ensure docs/code are concise and coherent (checked for spelling/grammatical errors, commented out code, debug logs etc.)
  • Self-reviewed and ran all changes on a local instance

Explain the changes you've made

  1. Changing exc.path into exc.absolute_path fixes displaying validation paths from Validation failed on : to Validation failed on View/Labels/Label: .
  2. Changing
{
  "anyOf": [
    {
      "type": "array",
      "items": {"$ref": "#/definitions/ref1"}
    }, 
    {
      "$ref": "#/definitions/ref1"
    }
  ]
}  

into

{
  "anyOf": [
    {
      "$ref": "#/definitions/ref1"
    },
    {
      "type": "array",
      "items": {"$ref": "#/definitions/ref1"}
    } 
  ]
}  

fixes displaying cause of validation fails from OrderedDict() is not of type 'array' to something more meaningful like 'value' is a required property

  1. The line
# config = _fix_choices(config)

was hidden under the comment due to the problem, which caused this workaround, was solved by json schema itself.

What alternative approaches were there?

Fixing displayed paths has leaded to the situation when

<View>
  <Text name="text" value="$text" />
  <Choices name="choice" toName="choice">
    <Choice />
    <Choice value="any" />
  </Choices>
</View>

shows View/Choices/Choice/0, but

<View>
  <Text name="text" value="$text" />
  <Choices name="choice" toName="choice">
    <Choice />
  </Choices>
</View>

shows View/Choices/Choice. And previously it was just Choice/0 in this case.

To make it more consistent we can use removed right now function _fix_choices but convert all tags into arrays and in the same time get rid of MaybeMultiple* rules in schema. But so far it doesn't look to me that it's necessary, 'cause doesn't really affects user's navigation.

This change affects (describe how if yes)

  • Performance
  • Security
  • UX

Does this PR introduce a breaking change?

  • Yes, and covered entirely by feature flag(s)
  • Yes, and covered partially by feature flag(s)
  • No
  • Not sure (briefly explain the situation below)

It depends on the validity of the validation rules.

What level of testing was included in the change?

  • e2e (codecept)
  • integration (cypress)
  • unit (jest)

Which logical domain(s) does this change affect?

Labeling Interface

Copy link

netlify bot commented Jan 19, 2024

Deploy Preview for heartex-docs ready!

Name Link
🔨 Latest commit 4c0521b
🔍 Latest deploy log https://app.netlify.com/sites/heartex-docs/deploys/65b9c4c175233900080212d5
😎 Deploy Preview https://deploy-preview-5313--heartex-docs.netlify.app/guide/billing
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 19, 2024

Deploy Preview for label-studio-docs-new-theme ready!

Name Link
🔨 Latest commit 4c0521b
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-docs-new-theme/deploys/65b9c4c13df3b30008064e90
😎 Deploy Preview https://deploy-preview-5313--label-studio-docs-new-theme.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the fix label Jan 19, 2024
@Gondragos Gondragos force-pushed the fb-leap-245/config-validation branch from 464e4ff to 4fc649c Compare January 22, 2024 15:54
Copy link

codecov bot commented Jan 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.79%. Comparing base (4e0f517) to head (4c0521b).
Report is 828 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5313      +/-   ##
===========================================
- Coverage    75.88%   75.79%   -0.10%     
===========================================
  Files          154      154              
  Lines        12931    12930       -1     
===========================================
- Hits          9813     9800      -13     
- Misses        3118     3130      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -84,7 +84,7 @@ def parse_config_to_json(config_string):
if xml is None:
raise etree.ParseError('xml is empty or incorrect')
config = xmljson.badgerfish.data(xml)
config = _fix_choices(config)
# config = _fix_choices(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentionally left in? Why don't we want to _fix_choices anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

nevermind, I see this was mentioned in the description - my feeling is that if we really don't need this we can delete the line (?)

Copy link
Contributor

@jombooth jombooth left a comment

Choose a reason for hiding this comment

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

I don't know that much about this label config validation code, and don't feel extremely confident approving without doing a sync review to understand its impact better. Is there anyone else more familiar with this who could take a look?

I will say we probably don't want to check in a commented-out function call; one way forward would be to remove the line and add a comment like

# previously we called `_fix_choices` here, but no longer need to because...

@Gondragos
Copy link
Collaborator Author

Gondragos commented Jan 31, 2024

I will say we probably don't want to check in a commented-out function call; one way forward would be to remove the line and add a comment like

# previously we called `_fix_choices` here, but no longer need to because...

@jombooth Thanks for that! It looks much better.

@Gondragos Gondragos requested review from jombooth and removed request for jombooth January 31, 2024 03:59
Copy link
Contributor

@jombooth jombooth left a comment

Choose a reason for hiding this comment

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

LGTM, if someone more knowledgeable can do a second look that'd be great but I think we should get this over to QA, and the changes look reasonable!

@Gondragos Gondragos changed the title fix: LEAP-245: Actualize label config validation fix: LEAP-634: Actualize label config validation Jan 31, 2024
@robot-ci-heartex
Copy link
Collaborator

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@robot-ci-heartex
Copy link
Collaborator

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

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

Successfully merging this pull request may close these issues.

4 participants