Teradata Package for Python Function Reference | 20.00 - view_log - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.
Teradata® Package for Python Function Reference - 20.00
- Deployment
- VantageCloud
- VantageCore
- Edition
- Enterprise
- IntelliFlex
- VMware
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- ft:locale
- en-US
- ft:lastEdition
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Enterprise_2000
- Product Category
- Teradata Vantage
- teradataml.dbutils.dbutils.view_log = view_log(log_type='script', num_lines=1000, query_id=None, log_dir=None)
- DESCRIPTION:
Function for viewing script, apply or byom log on Vantage.
Logs are pulled from 'script_log' or 'byom.log' file on database node.
When log_type is "script", logs are pulled from 'scriptlog' file on database node.
This is useful when Script.execute() is executed to run user scripts in Vantage.
When log_type is set to "apply", function downloads the log files to a folder.
Notes:
* Logs files will be downloaded based on "log_dir".
* teradataml creates a sub directory with the name as "query_id"
and downloads the logs to the sub directory.
* files generated from "query_id" requires few seconds to generate,
provide "query_id" to function view_log() after few seconds else
it will return empty sub directory.
PARAMETERS:
log_type:
Optional Argument.
Specifies which logs to view.
If set to 'script', script log is pulled from database node.
If set to 'byom', byom log is pulled from database node.
If set to 'apply' logs are pulled from kubernetes container.
Permitted Values: 'script', 'apply', 'byom'
Default Value: 'script'
Types: str
num_lines:
Optional Argument.
Specifies the number of lines to be read and displayed from log.
Note:
This argument is applicable when log_type is 'script' otherwise ignored.
Default Value: 1000
Types: int
query_id:
Required Argument when log_type is 'apply', otherwise ignored.
Specifies the id of the query for which logs are to be retrieved.
This query id is part of the error message received when Apply class
or Dataframe apply method calls fail to execute the Apply table operator
query.
Types: str
log_dir:
Optional Argument.
Specifies the directory path to store all the log files for "query_id".
Notes:
* This argument is applicable when log_type is 'apply' otherwise ignored.
* when "log_dir" is not provided, function creates temporary folder
and store the log files in the temp folder.
Types: str
RETURNS:
when log_type="apply" returns log files, otherwise teradataml dataframe.
RAISES:
TeradataMLException.
EXAMPLES:
# Example 1: View script log.
>>> view_log(log_type="script", num_lines=200)
>>> view_log(log_type="byom", num_lines=200)
# Example 2: Download the Apply query logs to a default temp folder.
# Use query id from the error messages returned by Apply class.
>>> view_log(log_type="apply", query_id='307161028465226056')
Logs for query_id "307191028465562578" is stored at "C:\local_repo\AppData\Local\Temp\tmp00kuxlgu\307161028465226056"
# Example 3: Download the Apply query logs to a specific folder.
# Use query id from the error messages returned by Apply class.
>>> view_log(log_type="apply", query_id='307161028465226056',log_dir='C:\local_repo\workspace')
Logs for query_id "307191028465562578" is stored at "C:\local_repo\workspace\307161028465226056"