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

[unit testing] unit testing versioned models #121

Open
graciegoheen opened this issue Feb 8, 2024 · 1 comment
Open

[unit testing] unit testing versioned models #121

graciegoheen opened this issue Feb 8, 2024 · 1 comment

Comments

@graciegoheen
Copy link

add support for yml that adds a unit test to a specific version or versions of a model - spec outlined here.

@graciegoheen graciegoheen changed the title [unit testing] [unit testing] unit testing versioned models Feb 8, 2024
@joellabes
Copy link
Collaborator

@graciegoheen I have been trying to make this work, but with the current spec it's not possible to represent in JSON Schema 😔

Consider these examples:

unit_tests:
  - name: test_normal_model
    model: unversioned_model
  - name: test_is_valid_email_address
    model: dim_customers
      versions:
        include: 
          - 2

The former is represented simply:

/*skipping the truly wild amount of boilerplate it takes to set up a JSON Schema */
...
"properties": {
  "model": {"type": "string"}
}
...

model is a string and its type is easy to set.

For the latter, there needs to be a versions object, which is easy enough:

...
"properties": { 
  "model": {
    "type": "object",
    "properties": {
      "versions": {
        "type": "object",
        /*skipping the truly wild amount of brackets it would take to 
        spell out the include/exclude stuff inside this object, but it's doable*/
      }
    }
  }
}

but there also needs to be a place to put the name of the model - now that its type is set as an object, it can't also be a string.

So to be able to validate this, we'd need to have it look more like this:

unit_tests:
  - name: test_normal_model
    model: unversioned_model #note that this can stay as-is, we can say "either a string or an object"
  - name: test_is_valid_email_address
    model: 
      model_name: dim_customers #break this out to its own key
      versions:
        include: 
          - 2

If we don't want to change the spec, then we would just have to change the model block in the JSON Schema to accept whatever input it gets. In this case we would lose the autocomplete and YAML validation for that block, but at least it wouldn't incorrectly mark a versioned model as invalid for not being a string.

JSON Schema is a very hard language to explain so I'm happy to sync with you live on this, or here's my buddy chatgpt working through the options with me too: https://chat.openai.com/share/e/04bba711-8488-443b-851c-68249285ba47

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

No branches or pull requests

2 participants