- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use Boto3 to get the details of a job that is bookmarked in AWS Glue Data Catalog?
Example − Retrieve the details of bookmarked job ‘book-job’ in AWS Glue Data Catalog.
Problem Statement − Use boto3 library in Python to retrieve the details of a bookmarked job in AWS Glue Data Catalog.
Approach/Algorithm to solve this problem
Step 1 − Import boto3 and botocore exceptions to handle exceptions.
Step 2 − bookmarked_job_name is the mandatory parameter. It should have job_name that is already bookmarked, otherwise it will throw EntityNotFoundException.
Step 3 − Create an AWS session using boto3 library. Make sure region_name is mentioned in default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.
Step 4 − Create an AWS client for glue.
Step 5 − Now use get_job_bookmark function and pass bookmarked_job_name as JobName parameter.
Step 6 − It returns the details related to bookmark entry. Note that if job_name is not bookmarked, it will throw an exception as EntityNotFound.
Step 7 − Handle the generic exception if something went wrong while checking the job.
Example
Use the following code to retrieve the details of a bookmarked job in AWS Glue Data Catalog −
import boto3 from botocore.exceptions import ClientError def retrieves_details_of_bookmarked_job(bookmarked_job_name) session = boto3.session.Session() glue_client = session.client('glue') try: response = glue_client.get_job_bookmark(JobName=bookmarked_job_name) return response except ClientError as e: raise Exception("boto3 client error in retrieves_details_of_bookmarked_job: " + e.__str__()) except Exception as e: raise Exception("Unexpected error in retrieves_details_of_bookmarked_job: " + e.__str__()) print(retrieves_details_of_bookmarked_job("book-job"))
Output
{'JobBookmarkEntry': {'JobName': 'book-job', 'Version': 8, 'Run': 2, 'Attempt': 2, 'PreviousRunId': 'jr_dee547c2f78422e34136aa12c85de010b823787833eee04fbf34bc9b8cb4f7b9', 'RunId': 'jr_a035fe15daa31e9a751f02876c26e5d11a829f2689803a9e9643bd61f70273e4', 'JobBookmark': '{"gdf":{"jsonClass":"HadoopDataSourceJobBookmarkState","timestamps":{"R UN":"1","HIGH_BAND":"900000","CURR_LATEST_PARTITION":"0","CURR_LATEST_PA RTITIONS":"","CURR_RUN_START_TIME":"2020-10- 30T13:03:43.730Z","INCLUDE_LIST":""}}}'}, 'ResponseMetadata': {'RequestId': 'bacf1497-***************996f05b3c1', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Sun, 28 Feb 2021 13:00:19 GMT', 'contenttype': 'application/x-amz-json-1.1', 'content-length': '535', 'connection': 'keep-alive', 'x-amzn-requestid': 'bacf1497- ******************996f05b3c1'}, 'RetryAttempts': 0}}
- Related Articles
- How to use Boto3 to get the details of a classifier from AWS Glue Data catalog?
- How to use Boto3 to get the details of a connection from AWS Glue Data catalog?
- How to use Boto3 to get the details of a database from AWS Glue Data Catalog?
- How to use Boto3 get the details of all the databases from AWS Glue Data Catalog?
- How to use Boto3 to get the details of all classifiers available in AWS Glue Data catalog?
- How to use Boto3 to get the details of all connection available in AWS Glue Data catalog?
- How to get the details of a trigger from AWS Glue Data catalog using Boto3
- How to get the details of all the triggers associated with a job from AWS Glue Data catalog using Boto3
- How to use Boto3 to update the details of a workflow in AWS Glue Catalog
- How to use Boto3 to get the security configuration/encryption settings of a catalog from AWS Glue Data Catalog?
- How to use Boto3 to start a crawler in AWS Glue Data Catalog
- How to use Boto3 to start a trigger in AWS Glue Data Catalog
- How to use Boto3 to stop a trigger in AWS Glue Data Catalog
- How to use Boto3 to start a workflow in AWS Glue Data Catalog
- How to use Boto3 to stop a workflow in AWS Glue Data Catalog
