-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hongxin Liang <[email protected]>
- Loading branch information
Showing
13 changed files
with
243 additions
and
162 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
flytekit-jackson/src/main/java/org/flyte/flytekit/jackson/BlobTypeDescription.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2020-2023 Flyte Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.flyte.flytekit.jackson; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** Annotation a blob's type */ | ||
@Target({ElementType.FIELD, ElementType.METHOD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface BlobTypeDescription { | ||
/** | ||
* Describes the blob's format | ||
* | ||
* @return format, not {@code null} | ||
*/ | ||
String format(); | ||
|
||
/** | ||
* Describes the blob's dimensionality | ||
* | ||
* @return dimensionality, not {@code null} | ||
*/ | ||
String dimensionality(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ekit-jackson/src/main/java/org/flyte/flytekit/jackson/deserializers/BlobDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2023 Flyte Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.flyte.flytekit.jackson.deserializers; | ||
|
||
import static org.flyte.flytekit.jackson.deserializers.JsonTokenUtil.verifyToken; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.flyte.api.v1.Blob; | ||
import org.flyte.api.v1.Literal; | ||
import org.flyte.api.v1.Scalar; | ||
import org.flyte.api.v1.Struct.Value; | ||
|
||
public class BlobDeserializer extends StdDeserializer<Literal> { | ||
private static final long serialVersionUID = 0L; | ||
|
||
public BlobDeserializer() { | ||
super(Literal.class); | ||
} | ||
|
||
@Override | ||
public Literal deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { | ||
Blob blob = readValueAsBlob(p); | ||
return Literal.ofScalar(Scalar.ofBlob(blob)); | ||
} | ||
|
||
private static Blob readValueAsBlob(JsonParser p) throws IOException { | ||
verifyToken(p, JsonToken.START_OBJECT); | ||
p.nextToken(); | ||
|
||
Map<String, Value> fields = new HashMap<>(); | ||
|
||
while (p.currentToken() != JsonToken.END_OBJECT) {} | ||
|
||
return Blob.builder().build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.