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

Dev #150

Merged
merged 9 commits into from
Nov 6, 2023
Merged

Dev #150

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile-domino-piece.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim
FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-domino-piece.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim
FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/@types/piece/piece.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface PieceSchema {
type: "object";

properties: SchemaProperties;
definitions: Definitions;
$defs: Definitions;
}

export interface Piece {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/@types/piece/properties.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
interface Reference {
$ref: `#/definitions/${string}`;
$ref: `#/$defs/${string}`;
}
type FromUpstream = "always" | "never" | "allowed";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function renderPieceProperties(
if ("allOf" in argument && argument.allOf.length > 0) {
typeName = "enum";
const typeClass = argument.allOf[0].$ref.split("/").pop() as string;
valuesOptions = (schema?.definitions?.[typeClass] as EnumDefinition).enum;
valuesOptions = (schema?.$defs?.[typeClass] as EnumDefinition).enum;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const PieceForm: React.FC<PieceFormProps> = ({ formId, schema }) => {
schema={schema.properties[key]}
itemKey={key}
control={control}
definitions={schema?.definitions}
definitions={schema?.$defs}
upstreamOptions={upstreamOptions[key] ?? []}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback } from "react";
import { generateTaskName, getUuidSlice } from "utils";

export interface Option {
Expand All @@ -22,12 +23,27 @@ const getInputType = (schema: Record<string, any>) => {
} else if ("anyOf" in schema) {
type = [];
for (const item of schema.anyOf) {
type.push(item.type);
let _type = item.type;
_type = _type === "number" ? "float" : (_type as string);
type.push(_type);
}
}
return type === "number" ? "float" : (type as string);
};

const validateUpstreamType = (upType: string, type: string) => {
if (upType === type) {
return true;
}
if (Array.isArray(upType) && !Array.isArray(type)) {
return upType.includes(type);
}
if (Array.isArray(upType) && Array.isArray(type)) {
return upType.some((element) => type.includes(element));
}
return false;
};

const getOptions = (
upstreamPieces: Record<string, any>,
type: string,
Expand All @@ -43,11 +59,7 @@ const getOptions = (
for (const property in upSchema) {
const upType = getInputType(upSchema[property]);

if (
upType === type ||
(upType === "string" && type === "object") ||
(Array.isArray(type) && type.includes(upType))
) {
if (validateUpstreamType(upType, type)) {
const value = `${upPiece?.name} (${getUuidSlice(upPiece.id)}) - ${
upSchema[property].title
}`;
Expand Down Expand Up @@ -96,7 +108,7 @@ export const getUpstreamOptions = (
let itemsSchema = currentSchema?.items;
if (currentSchema?.items?.$ref) {
const subItemSchemaName = currentSchema.items.$ref.split("/").pop();
itemsSchema = schema.definitions?.[subItemSchemaName];
itemsSchema = schema.$defs?.[subItemSchemaName];
}

const array = getOptions(upstreamPieces, currentType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function createInputsSchemaValidation(schema: any) {
let subItemSchema: any = subSchema?.items;
if (subSchema?.items?.$ref) {
const subItemSchemaName = subSchema.items.$ref.split("/").pop();
subItemSchema = schema.definitions?.[subItemSchemaName];
subItemSchema = schema.$defs?.[subItemSchemaName];
}
const required = true; // for arrays, we always require the value
inputSchema = yup.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const SidebarPieceForm: React.FC<ISidebarPieceFormProps> = (props) => {
return (
"items" in inputSchema &&
"$ref" in inputSchema.items &&
inputSchema.items.$ref === "#/definitions/OutputModifierModel"
inputSchema.items.$ref === "#/$defs/OutputModifierModel"
);
},
);
Expand Down Expand Up @@ -173,7 +173,7 @@ const SidebarPieceForm: React.FC<ISidebarPieceFormProps> = (props) => {
minWidth: "300px",
},
}}
BackdropProps={{ style: { backgroundColor: "transparent" } }}
slotProps={{ backdrop: { style: { backgroundColor: "transparent" } } }}
>
<div
style={{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/workflowEditor/utils/jsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getFromUpstream } from "./getFromUpstream";

export const extractDefaultInputValues = (pieceSchema: Piece) => {
const schema = pieceSchema.input_schema.properties;
const definitions = pieceSchema.input_schema.definitions;
const definitions = pieceSchema.input_schema.$defs;
const defaultData = extractDefaultValues(pieceSchema.input_schema);

const defaultInputs: IWorkflowPieceData["inputs"] = {};
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
"PyYAML==6.0.1",
"jsonschema==4.18.0",
"click==8.1.3",
"rich==12.6.0",
"rich>=13.4.2",
"colorama==0.4.6",
]

Expand Down
2 changes: 1 addition & 1 deletion src/domino/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.6.1
Loading