Skip to main content
Solved

using python sdk reading particular version of pipeline


himanshu1234567
Discovered Fame

Using python sdk can we read particular version of pipeline like if pipeline has two version then can we read first version.

 

this line 
pipeline=sch.pipelines.get(name="Test")

gives latest version only can we get previous version also.

Best answer by Bikram

@himanshu1234567 

 

Can you please try the below code snippet and check if it helps.

 

# Get the history of the pipeline

pipeline_history = client.get_pipeline_history('pipeline_name')

# Get the previous version of the pipeline

previous_pipeline = pipeline_history[1]

# Print information about the previous pipeline

print("Previous pipeline version:", previous_pipeline['version'])

View original
Did this topic help you find an answer to your question?

2 replies

Bikram
Headliner
Forum|alt.badge.img+1
  • Headliner
  • 486 replies
  • Answer
  • March 15, 2023

@himanshu1234567 

 

Can you please try the below code snippet and check if it helps.

 

# Get the history of the pipeline

pipeline_history = client.get_pipeline_history('pipeline_name')

# Get the previous version of the pipeline

previous_pipeline = pipeline_history[1]

# Print information about the previous pipeline

print("Previous pipeline version:", previous_pipeline['version'])


saleempothiwala
Headliner
Forum|alt.badge.img

@himanshu1234567 

Another way is to get the latest version of your pipeline like you mentioned in the sample code:

 

pipeline=sch.pipelines.get(name="Test")

You can now use

pipeline.commits

This will list all the commits for this pipeline, you will see the commit_id and also the version number for each commit.

 

So if you want version=1, select the commit_id for that version and use this code to get the reference to the pipeline

pipeline=sch.pipelines.get(commit_id="YOUR COMMIT_ID")

 


Reply