By using AWS re:Post, you agree to the Terms of Use

Lifecycle scripts to access the notebook instance git repository


Hi there,
Is it possible for the lifecycle scripts to access the content of the checkout-ed git repository? A use case would be to access the already available in the repository pip requirements file and to populate the notebook instance with the required python modules on start up.
I guess the answer to this question depends on the order of the executed events when a notebook is created. Are you executing the lifecycle scripts first and then checkout the repository or vice versa.



Well, I did my experiment as follows.

I added a simple 'ls -al SageMaker' in the start and create lifecycle scripts and inspected the logs.
It seems that on initial notebook instance creation the git repository is checked out after the execution of the start and create scripts.
On subsequent notebook starts, the start script is executed and the repository folder is present in the SageMaker folder with a timestamp indicating that the repository folder was created after the initial start/create scripts executions.

So, can someone confirm that this is what's expected and that we can access the repository only on subsequent notebook starts?

Edited by: ainkov on Apr 3, 2019 7:25 AM

asked 4 years ago89 views
2 Answers

Hi and thank you for using SageMaker!

Currently, Git repositories are checked out after Lifecycle Configuration scripts are executed, so unfortunately they will not have access to them. We are always considering new features and functionality, so I've added this as a feature request.

In the mean time, I have two recommendations to workaround this limitation:

  1. Manually clone or download the requirements.txt files from within your Lifecycle Configuration.
  2. From your Lifecycle Configuration, create a cron job or similar background process that waits until the Git Clone operation is complete.

Let me know if that helps!


answered 3 years ago

Hey there, sorry for this late reply.
Thanks much, the workarounds would help!

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions