Solved

using python sdk reading particular version of pipeline

  • 15 March 2023
  • 2 replies
  • 49 views

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.

icon

Best answer by Bikram 15 March 2023, 14:05

View original

2 replies

Userlevel 4
Badge

@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")

 

Userlevel 5
Badge +1

@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'])

Reply