Skip to content

Commit

Permalink
test: Don't require pydantic for client unit test suite (#4106)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuverta authored Sep 26, 2023
1 parent 9ca5373 commit 7afb5e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
5 changes: 2 additions & 3 deletions client/verta/tests/registry/test_standard_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import warnings

import hypothesis
import hypothesis.strategies as st
import pytest

from verta._internal_utils import _artifact_utils, model_validator
from verta.environment import Python
from verta.registry import _constants, verify_io

from ..models import standard_models
from ..strategies import json_strategy
from tests.models import standard_models
from tests.unit_tests.strategies import json_strategy


verta_models = standard_models.verta_models()
Expand Down
11 changes: 0 additions & 11 deletions client/verta/tests/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

from datetime import timedelta
import os
import re
import string
import warnings

import hypothesis
import hypothesis.strategies as st
from hypothesis import given

from tests.registry.pydantic_models import AnInnerClass, InputClass, OutputClass
from verta._internal_utils.time_utils import duration_millis
Expand All @@ -25,15 +23,6 @@ def duration_millis_ignore_warn(delta):
millis_uint64_strategy = millis_timedelta_strategy.map(duration_millis_ignore_warn)


# from https://hypothesis.readthedocs.io/en/latest/data.html#recursive-data
json_strategy = st.recursive(
st.none() | st.booleans() | st.floats() | st.text(string.printable),
lambda children: st.lists(children)
| st.dictionaries(st.text(string.printable), children),
max_leaves=500,
)


@st.composite
def filepath(draw, allow_parent_dir_segments=False):
"""A valid filepath. Does **not** create the file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from verta._pipeline_orchestrator._step_handler import ModelObjectStepHandler

from tests.models.standard_models import VertaModelDecorated
from tests.strategies import json_strategy
from tests.unit_tests.strategies import json_strategy


class TestModelObjectStepHandler:
Expand Down
11 changes: 9 additions & 2 deletions client/verta/tests/unit_tests/strategies.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
# -*- coding: utf-8 -*-

"""Hypothesis composite strategies for use in client unit tests."""
from string import ascii_letters, ascii_lowercase, hexdigits
from string import ascii_letters, ascii_lowercase, hexdigits, printable
from typing import Any, Dict, Optional

import hypothesis.strategies as st

from tests.strategies import json_strategy
from verta._internal_utils._utils import _VALID_FLAT_KEY_CHARS, python_to_val_proto
from verta._protos.public.common import CommonService_pb2
from verta._protos.public.modeldb.versioning import Code_pb2, Dataset_pb2
from verta.endpoint import build, KafkaSettings
from verta.endpoint.resources import NvidiaGPU, NvidiaGPUModel, Resources


# from https://hypothesis.readthedocs.io/en/latest/data.html#recursive-data
json_strategy = st.recursive(
st.none() | st.booleans() | st.floats() | st.text(printable),
lambda children: st.lists(children) | st.dictionaries(st.text(printable), children),
max_leaves=500,
)


@st.composite
def uint64(draw) -> int:
"""Generate an integer within the range of an uint64."""
Expand Down

0 comments on commit 7afb5e5

Please sign in to comment.