From GraphQL, get the compute logs for a certain j...
# ask-ai
r
From GraphQL, get the compute logs for a certain job, and run id
s
To retrieve the compute logs for a specific job and run ID using GraphQL, you can use the
launchRun
mutation to execute a job and then query for the logs of that run. Here's a step-by-step guide based on the documentation: 1. Launch a run: First, you need to launch a run for the job using the
launchRun
mutation. You will need to provide the
selector
with the repository location name, repository name, and job name, as well as the
runConfigData
for the job execution.
Copy code
graphql     mutation LaunchRunMutation(       $repositoryLocationName: String!       $repositoryName: String!       $jobName: String!       $runConfigData: RunConfigData!     ) {       launchRun(         executionParams: {           selector: {             repositoryLocationName: $repositoryLocationName             repositoryName: $repositoryName             jobName: $jobName           }           runConfigData: $runConfigData         }       ) {         __typename         ... on LaunchRunSuccess {           run {             runId           }         }         ... on RunConfigValidationInvalid {           errors {             message             reason           }         }         ... on PythonError {           message         }       }     }
2. Query for compute logs: After you have successfully launched a run and obtained the
runId
, you can query for the compute logs associated with that run. The documentation does not provide a specific GraphQL query for fetching compute logs directly. However, the compute logs are typically available in the Run details page of the Dagster UI, where you can view both structured event logs and raw compute logs. If you need to access the compute logs programmatically, you would typically look for a query or mutation in the GraphQL schema that allows you to fetch the logs for a given
runId
. The exact query or mutation would depend on the schema provided by your Dagster instance, which may include fields for retrieving stdout and stderr logs. Please note that the documentation does not explicitly provide a GraphQL query for fetching compute logs, so you may need to refer to your Dagster instance's GraphQL schema or contact Dagster support for further assistance on constructing the appropriate query.
r
@Scout but if I’m not using graphql to launch a run, how could I fetch the logs?
s
If you are not using GraphQL to launch a run but still want to fetch the compute logs, you can use the Dagster UI to view the logs for a specific run. Here's how you can do it according to the documentation: 1. Navigate to the Run details page: In the Dagster UI, locate the run you are interested in by going to the Runs page. Click on the specific run to open the Run details page. 2. View compute logs: On the Run details page, you can view structured event logs and raw compute logs. The logs are displayed at the bottom of the page, and you can filter and search through them. If you need to access the logs programmatically and the GraphQL API is not an option, you may need to consider the following alternatives: - Dagster API: If there is a Python API provided by Dagster for accessing logs, you could use that to programmatically retrieve the logs. The documentation does not explicitly mention such an API, so you may need to check the Dagster codebase or contact Dagster support for more information. - Compute Log Manager: Dagster allows you to configure a Compute Log Manager, which can be used to manage the storage and retrieval of compute logs. If you have configured a custom Compute Log Manager, you may be able to use it to access the logs directly from the storage backend (e.g., a file system, S3 bucket). - Direct Access to Storage: If you know where the logs are stored (e.g., a specific directory on a file system or a cloud storage service), you could access them directly using standard file I/O operations or the appropriate cloud storage SDK. Please note that the documentation does not provide specific details on accessing compute logs outside of the UI or GraphQL API. If you require further assistance, you may need to refer to the Dagster instance configuration or contact Dagster support for guidance on accessing compute logs programmatically.