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

Fixes issues in which foreign key IDs were not displayed in the UI (+ a few others) #962

Merged
merged 6 commits into from
Jun 15, 2024
Merged
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
6 changes: 3 additions & 3 deletions examples/hamilton_ui/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
@click.option(
"--load-from-parquet", is_flag=True, help="Load from saved parquet or load fresh dataset."
)
@click.option("--email", help="Email for the Hamilton UI", type=str, required=True)
@click.option("--username", help="Email for the Hamilton UI", type=str, required=True)
@click.option(
"--project-id", help="Project ID to log to for the Hamilton UI", type=int, required=True
)
def run(load_from_parquet: bool, email: str, project_id: int):
def run(load_from_parquet: bool, username: str, project_id: int):
"""
Runs the machine_learning hamilton DAG emitting metadata to the Hamilton UI.

Expand All @@ -34,7 +34,7 @@ def run(load_from_parquet: bool, email: str, project_id: int):

# create tracker object
tracker = adapters.HamiltonTracker(
username=email,
username=username,
project_id=project_id,
dag_name=dag_name,
tags={
Expand Down
12 changes: 12 additions & 0 deletions ui/backend/server/commands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import sys
import threading
Expand All @@ -9,6 +10,8 @@
import requests
from django.core.management import execute_from_command_line

logger = logging.getLogger(__name__)


@contextmanager
def extend_sys_path(path):
Expand Down Expand Up @@ -73,6 +76,15 @@ def run(port: int, base_dir: str, no_migration: bool, no_open: bool):
thread.start()
with set_env_variables(env):
with extend_sys_path(hamilton_ui.__path__[0]):
# This is here as some folks didn't have it created automatically through django
if not os.path.exists(base_dir):
try:
os.makedirs(os.path.join(base_dir, "blobs"))
os.makedirs(os.path.join(base_dir, "db"))
except Exception as e:
logger.exception(
f"Error creating directories -- manually create them instead: {e}"
)
if not no_migration:
execute_from_command_line(
["manage.py", "migrate", "--settings=server.settings_mini"]
Expand Down
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
4 changes: 3 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,8 @@ 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
code_artifacts = list(
{
code_artifact
Expand All @@ -306,7 +308,7 @@ async def get_dag_template_catalog(
}
)
out = CatalogResponse(
nodes=node_templates,
nodes=node_templates[:],
code_artifacts=code_artifacts,
)
logger.info(
Expand Down
3 changes: 2 additions & 1 deletion ui/backend/server/trackingserver_template/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ class Meta:


class NodeTemplateOut(ModelSchema):
dag_template_id: int

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

primary_code_artifact: Optional[str] = None

Expand Down
2 changes: 1 addition & 1 deletion ui/backend/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def load_requirements():

setup(
name="sf-hamilton-ui", # there's already a hamilton in pypi
version="0.0.5",
version="0.0.6",
description="Hamilton, the micro-framework for creating dataframes.",
long_description="""Hamilton tracking server, see [the docs for more](https://github.com/dagworks-inc/hamilton/tree/main/ui/)""",
long_description_content_type="text/markdown",
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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just double checking, this is the right port?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

"apiFile": "./src/state/api/emptyApi.ts",
"apiImport": "emptySplitApi",
"outputFile": "./src/state/api/backendApiRaw.ts",
Expand Down
26 changes: 18 additions & 8 deletions ui/frontend/src/components/dashboard/Runs/RunSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ function serialize(query: Query): URLSearchParams {

function deserialize(
searchParams: URLSearchParams,
minDate: Date,
maxDate: Date
minDate: Date | null,
maxDate: Date | null
): Query {
const selectedTags = searchParams.get("selectedTags");
const startDate = searchParams.get("startDate");
Expand Down Expand Up @@ -652,14 +652,24 @@ export const RunSummary = (props: {
run.run_start_time ? new Date(run.run_start_time) : new Date(Date.now())
)
.sort((a, b) => a.getTime() - b.getTime());
const minDate = new Date(runsSortedByStartDate[0]);
const maxDate = new Date(
runsSortedByStartDate[runsSortedByStartDate.length - 1]
);
const minDate =
runsSortedByStartDate.length > 0
? new Date(runsSortedByStartDate[0])
: null;
const maxDate =
runsSortedByStartDate.length > 0
? new Date(runsSortedByStartDate[runsSortedByStartDate.length - 1])
: null;

// Quick buffer to ensure no runs are missed
minDate.setDate(minDate.getDate() - 1);
maxDate.setDate(maxDate.getDate() + 1);
console.log("minDate", minDate);
console.log("maxDate", maxDate);
if (minDate !== null) {
minDate.setDate(minDate.getDate() - 1);
}
if (maxDate !== null) {
maxDate.setDate(maxDate.getDate() + 1);
}

const [searchParams, setSearchParams] = useSearchParams();
const [query, setQuery] = useState(() =>
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
Loading