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

[dagster-azure]: log manager metadata represented as namedtuple instead of json string #27000

Draft
wants to merge 1 commit into
base: mlarose/AD-721-tests
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import os
import subprocess
from pathlib import Path
Expand Down Expand Up @@ -66,7 +65,7 @@ def test_compute_log_manager(
assert logs_captured_data.external_stderr_url.endswith(logs_captured_data.stderr_uri_or_path)

assert logs_captured_data.log_manager_metadata
metadata = json.loads(logs_captured_data.log_manager_metadata)
assert metadata["type"] == "AzureBlobComputeLogManager"
assert metadata["storage_account"] == os.getenv("TEST_AZURE_STORAGE_ACCOUNT_ID")
assert metadata["container"] == os.getenv("TEST_AZURE_CONTAINER_ID")
metadata = logs_captured_data.log_manager_metadata
assert metadata.log_manager_class == "AzureBlobComputeLogManager"
assert metadata.container == os.getenv("TEST_AZURE_CONTAINER_ID")
assert metadata.storage_account == os.getenv("TEST_AZURE_STORAGE_ACCOUNT_ID")
4 changes: 2 additions & 2 deletions js_modules/dagster-ui/packages/ui-core/client.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 36 additions & 2 deletions js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,12 @@ export const CapturedOrExternalLogPanel = React.memo(
if (logCaptureInfo?.logManagerMetadata) {
const path =
ioType === 'stdout' ? logCaptureInfo.stdoutUriOrPath : logCaptureInfo.stderrUriOrPath;

try {
const metadata = JSON.parse(logCaptureInfo.logManagerMetadata);
switch (metadata.type) {
case 'AzureBlobComputeLogManager':
if (metadata.storage_account && metadata.container) {
return `az storage blob download --account-name ${metadata.storage_account} --container-name ${metadata.container} --name ${path}`;
}
}
} catch {
return undefined;
const metadata = logCaptureInfo.logManagerMetadata;
switch (metadata.logManagerClass) {
case 'AzureBlobComputeLogManager':
if (metadata.storageAccount && metadata.container) {
return `az storage blob download --account-name ${metadata.storageAccount} --container-name ${metadata.container} --name ${path}`;
}
}
}
return undefined;
Expand Down
8 changes: 7 additions & 1 deletion js_modules/dagster-ui/packages/ui-core/src/runs/LogsRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ export const LOGS_ROW_STRUCTURED_FRAGMENT = gql`
externalUrl
externalStdoutUrl
externalStderrUrl
logManagerMetadata
logManagerMetadata {
... on LogManagerMetadata {
logManagerClass
container
storageAccount
}
}
stdoutUriOrPath
stderrUriOrPath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
RunStepStatsQuery,
RunStepStatsQueryVariables,
} from './types/RunMetadataProvider.types';
import {StepEventStatus} from '../graphql/types';
import {LogManagerMetadata, StepEventStatus} from '../graphql/types';
import {METADATA_ENTRY_FRAGMENT} from '../metadata/MetadataEntryFragment';

export enum IStepState {
Expand Down Expand Up @@ -73,7 +73,7 @@ export interface ILogCaptureInfo {
pid?: string;
externalStdoutUrl?: string;
externalStderrUrl?: string;
logManagerMetadata?: string;
logManagerMetadata?: LogManagerMetadata;
stdoutUriOrPath?: string;
stderrUriOrPath?: string;
}
Expand Down Expand Up @@ -460,7 +460,13 @@ export const RUN_METADATA_PROVIDER_MESSAGE_FRAGMENT = gql`
pid
externalStdoutUrl
externalStderrUrl
logManagerMetadata
logManagerMetadata {
... on LogManagerMetadata {
logManagerClass
container
storageAccount
}
}
stdoutUriOrPath
stderrUriOrPath
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def from_dagster_event_record(event_record: EventLogEntry, pipeline_name: str) -
externalUrl=data.external_url,
externalStdoutUrl=data.external_stdout_url or data.external_url,
externalStderrUrl=data.external_stderr_url or data.external_url,
logManagerMetadata=data.log_manager_metadata,
logManagerMetadataRaw=data.log_manager_metadata,
stdoutUriOrPath=data.stdout_uri_or_path,
stderrUriOrPath=data.stderr_uri_or_path,
pid=dagster_event.pid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ class Meta:
name = "HookErroredEvent"


class GrapheneLogManagerMetadata(graphene.ObjectType):
class Meta:
name = "LogManagerMetadata"

logManagerClass = graphene.String(required=True)
storageAccount = graphene.String()
container = graphene.String()


class GrapheneLogsCapturedEvent(graphene.ObjectType):
class Meta:
interfaces = (GrapheneMessageEvent,)
Expand All @@ -309,14 +318,25 @@ class Meta:
externalUrl = graphene.String()
externalStdoutUrl = graphene.String()
externalStderrUrl = graphene.String()
logManagerMetadata = graphene.String() # TODO - replace with union?
logManagerMetadataRaw = graphene.JSONString()
logManagerMetadata = graphene.Field(GrapheneLogManagerMetadata)
stderrUriOrPath = graphene.String()
stdoutUriOrPath = graphene.String()
pid = graphene.Int()
# legacy name for compute log file key... required for back-compat reasons, but has been
# renamed to fileKey for newer versions of the Dagster UI
logKey = graphene.NonNull(graphene.String)

def resolve_logManagerMetadata(self, info):
if not self.logManagerMetadataRaw:
return None

return GrapheneLogManagerMetadata(
logManagerClass=self.logManagerMetadataRaw.log_manager_class,
container=self.logManagerMetadataRaw.container,
storageAccount=self.logManagerMetadataRaw.storage_account,
)


def _construct_asset_event_metadata_params(event, metadata):
metadata_params = {"label": metadata.label, "description": metadata.description}
Expand Down
Loading
Loading