Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw committed Nov 16, 2021
1 parent d7cc11a commit 99f6a75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 7 additions & 3 deletions flytekit/core/type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from google.protobuf.json_format import MessageToDict as _MessageToDict
from google.protobuf.json_format import ParseDict as _ParseDict
from google.protobuf.struct_pb2 import Struct
from marshmallow_enum import LoadDumpOptions
from marshmallow import fields
from marshmallow_enum import EnumField, LoadDumpOptions
from marshmallow_jsonschema import JSONSchema

from flytekit.common.exceptions import user as user_exceptions
Expand Down Expand Up @@ -228,7 +229,11 @@ def get_literal_type(self, t: Type[T]) -> LiteralType:
schema = None
try:
s = cast(DataClassJsonMixin, t).schema()
s.fields["y"].load_by = LoadDumpOptions.name
for _, v in s.fields.items():
# marshmallow-jsonschema only supports enums loaded by name.
# https://github.com/fuhrysteve/marshmallow-jsonschema/blob/81eada1a0c42ff67de216923968af0a6b54e5dcb/marshmallow_jsonschema/base.py#L228
if isinstance(v, EnumField):
v.load_by = LoadDumpOptions.name
schema = JSONSchema().dump(s)
except Exception as e:
logger.warn("failed to extract schema for object %s, (will run schemaless) error: %s", str(t), e)
Expand Down Expand Up @@ -780,7 +785,6 @@ def convert_json_schema_to_python_class(schema: dict, schema_name) -> Type[datac
:param schema: dict representing valid JSON schema
:param schema_name: dataclass name of return type
"""
print(schema)
attribute_list = []
for property_key, property_val in schema[schema_name]["properties"].items():
# Handle list
Expand Down
3 changes: 0 additions & 3 deletions tests/flytekit/unit/core/test_type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,6 @@ class Datum(object):
x: int
y: Color

def __str__(self):
return self.value

lt = TypeEngine.to_literal_type(Datum)
schema = Datum.schema()
schema.fields["y"].load_by = LoadDumpOptions.name
Expand Down

0 comments on commit 99f6a75

Please sign in to comment.