Skip to content

Commit

Permalink
Fixes issues in which foreign key IDs were not displayed in the UI
Browse files Browse the repository at this point in the history
This is a bit ugly -- we're still identifying the underlying cause, but
it turns out that in the SQL orm interaction with django ninja, foreign
keys will not show up as IDs.

If you have foreign_key_id: int in the model it'll work. So adding this
in fixed it.
  • Loading branch information
elijahbenizzy committed Jun 14, 2024
1 parent d57e20d commit bfb2a3c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
3 changes: 3 additions & 0 deletions examples/model_examples/scikit-learn/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def get_model_config(model_type: str) -> dict:
# ensure you have done "pip install "sf-hamilton[visualization]"" for the following to work:
# dr.visualize_execution(['classification_report', 'confusion_matrix', 'fit_clf'],
# f'./model_dag_{_data_set}_{_model_type}.dot', {"format": "png"})
import pdb

pdb.set_trace()
results = dr.execute(["classification_report", "confusion_matrix", "fit_clf"])
for k, v in results.items():
print(k, ":\n", v)
5 changes: 4 additions & 1 deletion ui/backend/server/trackingserver_run_tracking/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ class DAGRunUpdate(Schema):


class DAGRunOut(ModelSchema):
dag_template_id: int

class Meta:
model = DAGRun
fields = "__all__"

username_resolved: Optional[str] = None
dag_template_id: int

@classmethod
def create_with_username(cls, orm_model: DAGRun) -> "DAGRunOut":
Expand Down Expand Up @@ -62,6 +63,8 @@ class Meta:


class NodeRunAttributeOut(ModelSchema):
dag_run_id: int

class Meta:
model = NodeRunAttribute
fields = "__all__"
Expand Down
6 changes: 5 additions & 1 deletion ui/backend/server/trackingserver_template/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ async def get_dag_template_catalog(
node_templates = [
NodeTemplateOut.from_orm(node_template) for node_template in all_node_templates
]
for i, node_template in enumerate(node_templates):
node_template.dag_template = all_node_templates[i].dag_template_id
# node_templates = []
# dag_template = node_template.dag_template_id
code_artifacts = list(
{
code_artifact
Expand All @@ -306,7 +310,7 @@ async def get_dag_template_catalog(
}
)
out = CatalogResponse(
nodes=node_templates,
nodes=node_templates[:],
code_artifacts=code_artifacts,
)
logger.info(
Expand Down
9 changes: 8 additions & 1 deletion ui/backend/server/trackingserver_template/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ class Meta:


class NodeTemplateOut(ModelSchema):
dag_template_id: int

class Meta:
model = NodeTemplate
fields = "__all__"
# exclude =

primary_code_artifact: Optional[str] = None

# @classmethod
# def from_orm(cls, obj: Any, **kw: Any) -> "NodeTemplateOut":
# out = super().from_orm(obj, **kw)
# out.dag_template_id = obj.dag_template_id
# return out


class File(Schema):
path: str
Expand Down
2 changes: 1 addition & 1 deletion ui/frontend/openapi-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"schemaFile": "http://127.0.0.1:8000/api/openapi.json",
"schemaFile": "http://127.0.0.1:8241/api/openapi.json",
"apiFile": "./src/state/api/emptyApi.ts",
"apiImport": "emptySplitApi",
"outputFile": "./src/state/api/backendApiRaw.ts",
Expand Down
20 changes: 16 additions & 4 deletions ui/frontend/src/state/api/backendApiRaw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ const injectedRtkApi = api.injectEndpoints({
>({
query: () => ({ url: `/api/v1/metadata/node_metadata/schema` }),
}),
trackingserverBaseApiHealthCheck: build.query<
TrackingserverBaseApiHealthCheckApiResponse,
TrackingserverBaseApiHealthCheckApiArg
>({
query: () => ({ url: `/api/v1/health` }),
}),
trackingserverAuthApiPhoneHome: build.query<
TrackingserverAuthApiPhoneHomeApiResponse,
TrackingserverAuthApiPhoneHomeApiArg
Expand Down Expand Up @@ -260,6 +266,9 @@ export type TrackingserverBaseApiGetCodeVersionTypesApiArg = void;
export type TrackingserverBaseApiGetNodeMetadataTypesApiResponse =
/** status 200 OK */ AllNodeMetadataTypes;
export type TrackingserverBaseApiGetNodeMetadataTypesApiArg = void;
export type TrackingserverBaseApiHealthCheckApiResponse =
/** status 200 OK */ boolean;
export type TrackingserverBaseApiHealthCheckApiArg = void;
export type TrackingserverAuthApiPhoneHomeApiResponse =
/** status 200 OK */ PhoneHomeResult;
export type TrackingserverAuthApiPhoneHomeApiArg = void;
Expand Down Expand Up @@ -587,10 +596,10 @@ export type ProjectOut = {
updated_at: string;
};
export type Visibility = {
user_ids_visible: (number | string)[];
user_ids_visible: (string | number)[];
team_ids_visible: number[];
team_ids_writable: number[];
user_ids_writable: (number | string)[];
user_ids_writable: (string | number)[];
};
export type ProjectAttributeIn = {
name: string;
Expand Down Expand Up @@ -700,6 +709,7 @@ export type DagTemplateIn = {
code_version_info_schema?: number | null;
};
export type NodeTemplateOut = {
dag_template_id: number;
primary_code_artifact?: string | null;
id?: number | null;
created_at: string;
Expand Down Expand Up @@ -760,8 +770,8 @@ export type DagTemplateUpdate = {
is_active?: boolean;
};
export type DagRunOut = {
username_resolved?: string | null;
dag_template_id: number;
username_resolved?: string | null;
id?: number | null;
created_at: string;
updated_at: string;
Expand All @@ -784,6 +794,7 @@ export type DagRunIn = {
outputs: any[];
};
export type NodeRunAttributeOut = {
dag_run_id: number;
id?: number | null;
created_at: string;
updated_at: string;
Expand All @@ -810,8 +821,8 @@ export type NodeRunOutWithAttributes = {
dag_run_id: number;
};
export type DagRunOutWithData = {
username_resolved?: string | null;
dag_template_id: number;
username_resolved?: string | null;
id?: number | null;
created_at: string;
updated_at: string;
Expand Down Expand Up @@ -873,6 +884,7 @@ export const {
useTrackingserverBaseApiGetAttributesTypeQuery,
useTrackingserverBaseApiGetCodeVersionTypesQuery,
useTrackingserverBaseApiGetNodeMetadataTypesQuery,
useTrackingserverBaseApiHealthCheckQuery,
useTrackingserverAuthApiPhoneHomeQuery,
useTrackingserverAuthApiWhoamiQuery,
useTrackingserverAuthApiCreateApiKeyMutation,
Expand Down

0 comments on commit bfb2a3c

Please sign in to comment.