- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 reset the bookmark of job in AWS account
In this article, we will see how a user can reset the bookmark of a job present in ann AWS account.
Example
Reset the bookmark of a job available in an AWS Glue Data Catalog.
Problem Statement: Use boto3 library in Python to reset the bookmark of a job.
Approach/Algorithm to solve this problem
Step 1: Import boto3 and botocore exceptions to handle exceptions.
Step 2: job_name is the parameter in this function.
Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the 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 reset_job_bookmark function and pass the parameter job_name as JobName.
Step 6: It returns a dictionary having the details of Job bookmark entry.
Step 7: Handle the generic exception if something went wrong while resetting the bookmark.
Example Code
The following code resets the bookmark of a job −
import boto3 from botocore.exceptions import ClientError def reset_bookmark_of_a_job(job_name) session = boto3.session.Session() glue_client = session.client('glue') try: response = glue_client.reset_job_bookmark(JobName=job_name) return response except ClientError as e: raise Exception("boto3 client error in reset_bookmark_of_a_job: " + e.__str__()) except Exception as e: raise Exception("Unexpected error in reset_bookmark_of_a_job: " + e.__str__()) print(reset_bookmark_of_a_job("test_job"))
Output
{'JobBookmarkEntry': {'JobName': 'test-job', 'Version': 3, 'Run': 3, 'Attempt': 0, 'JobBookmark': ''}, 'ResponseMetadata': {'RequestId': '03d40d90-******************f', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Sat, 27 Mar 2021 10:14:58 GMT', 'content-type': 'application/x-amz-json-1.1', 'content-length': '104', 'connection': 'keep-alive', 'x-amzn-requestid': '03d40d90-***************************f'}, 'RetryAttempts': 0}}
- Related Articles
- How to use Boto3 to get the list of schemas present in AWS account
- How to use Boto3 to paginate through the job runs of a job present in AWS Glue
- How to use Boto3 to get the list of triggers present in an AWS account
- How to use Boto3 to get the list of workflows present an in AWS account
- How to use Boto3 to delete a glue job from AWS Glue?
- How to use Boto3 to get the details of a job that is bookmarked in AWS Glue Data Catalog?
- How to get the list of all crawlers present in an AWS account using Boto3
- How to get the list of all registries present in an AWS account using Boto3
- How to use Boto3 to check the status of a running Glue Job?
- How to use Boto3 to add tags in AWS Glue Resources
- How to use Boto3 to add tags in specified AWS secrets
- How to use Boto3 to remove tags in specified AWS secrets
- How to use Boto3 library in Python to run a Glue Job?
- How to use Boto3 to get the workflows that are created in your account?
- How to use Boto3 to update the details of a workflow in AWS Glue Catalog
