Skip to content

Validate 'ml.update_job' #523

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

Merged
merged 2 commits into from
Jul 30, 2021
Merged

Validate 'ml.update_job' #523

merged 2 commits into from
Jul 30, 2021

Conversation

sethmlarson
Copy link
Contributor

  • Ran into the MlCustomSettings issue I've seen before, not sure how to handle arbitrary fields plus a few known fields.
  • Hit a validation error where a value wasn't fitting into the MlAppliesTo enum but that value wasn't printed and when I checked out the workbench directory it was consistently empty, not sure what to do here?

Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

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

Ran into the MlCustomSettings issue I've seen before, not sure how to handle arbitrary fields plus a few known fields.

Very likely what you need is the AdditionalPropertiesbehavior.

Hit a validation error where a value wasn't fitting into the MlAppliesTo enum but that value wasn't printed and when I checked out the workbench directory it was consistently empty, not sure what to do here?

Not sure I follow, can you provide an example?

@sethmlarson
Copy link
Contributor Author

Receiving an error that I don't know how to resolve since it looks correct to me?

  workbench/xpack-Test_update_job_2_request.json.test-d.ts:9:2
  ✖  9:2  Type { "groups": string[]; "description": string; "detectors": ({ "detector_index": number; "custom_rules": { "conditions": { "applies_to": string; "operator": string; "value": number; }[]; }[]; } | { "detector_index": number; "description": string; })[]; ... 5 more ...; "custom_settings": { ...; }; } is not assignable to type { allow_lazy_open?: boolean | undefined; analysis_limits?: MlAnalysisMemoryLimit | undefined; background_persist_interval?: string | number | undefined; ... 11 more ...; system_annotations_retention_days?: number | undefined; }.
  Types of property detectors are incompatible.
    Type ({ "detector_index": number; "custom_rules": { "conditions": { "applies_to": string; "operator": string; "value": number; }[]; }[]; } | { "detector_index": number; "description": string; })[] is not assignable to type MlDetector[].
      Type { "detector_index": number; "custom_rules": { "conditions": { "applies_to": string; "operator": string; "value": number; }[]; }[]; } | { "detector_index": number; "description": string; } is not assignable to type MlDetector.
        Type { "detector_index": number; "custom_rules": { "conditions": { "applies_to": string; "operator": string; "value": number; }[]; }[]; } is not assignable to type MlDetector.
          Types of property custom_rules are incompatible.
            Type { "conditions": { "applies_to": string; "operator": string; "value": number; }[]; }[] is not assignable to type MlDetectionRule[].
              Type { "conditions": { "applies_to": string; "operator": string; "value": number; }[]; } is not assignable to type MlDetectionRule.
                Types of property conditions are incompatible.
                  Type { "applies_to": string; "operator": string; "value": number; }[] is not assignable to type MlRuleCondition[].
                    Type { "applies_to": string; "operator": string; "value": number; } is not assignable to type MlRuleCondition.
                      Types of property applies_to are incompatible.
                        Type string is not assignable to type MlAppliesTo.

The test in the workbench:

expectAssignable<T.MlUpdateJobRequest>({
  "job_id": "jobs-crud-update-job",
  "body": {
    "groups": [
      "group-1",
      "group-2"
    ],
    "description": "Post update description",
    "detectors": [
      {
        "detector_index": 0,
        "custom_rules": [
          {
            "conditions": [
              {
                "applies_to": "actual",
                "operator": "gt",
                "value": 10
              }
            ]
          }
        ]
      },
      {
        "detector_index": 1,
        "description": "updated description"
      }
    ],
    "model_plot_config": {
      "enabled": false,
      "terms": "foobar"
    },
    "renormalization_window_days": 10,
    "background_persist_interval": "3h",
    "model_snapshot_retention_days": 30,
    "results_retention_days": 40,
    "custom_settings": {
      "setting3": "custom3"
    }
  }
})

actual is an entry in the AppliesTo enum, not sure what to do here?

@delvedor delvedor merged commit 6c98e77 into main Jul 30, 2021
@delvedor delvedor deleted the ml-update-job branch July 30, 2021 15:37
delvedor added a commit that referenced this pull request Aug 13, 2021
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