[英]Run Python Code within Azure Devops Pipeline and Export output to folder in Devops Repos ($(Build.SourcesDirectory))
How could I rewrite this python script so that it can run within azure devops pipeline and export the dataframe as a csv to the devops repository.我如何重写这个 python 脚本,以便它可以在 azure devops 管道中运行,并将数据帧作为 csv 导出到 devops 存储库。 I'm able to achieve this locally but would like to achieve this remotely.
我能够在本地实现这一点,但想远程实现这一点。
Put different, how can I export a pandas dataframe to devops repos folder as a csv file using an azure devops pipeline task.换句话说,如何使用 azure devops 管道任务将 Pandas 数据帧作为 csv 文件导出到 devops repos 文件夹。 Below is the python script that needs to run as a pipeline task.
下面是需要作为管道任务运行的 python 脚本。
local_path in this case should be azure devops path.在这种情况下 local_path 应该是 azure devops 路径。
from azureml.core import Workspace, Dataset
local_path = 'data/prepared.csv'
dataframe.to_csv(local_path)
⚠️You really should not do this. ⚠️你真的不应该这样做。 Azure pipelines are for building code, not for processing data.
Azure 管道用于构建代码,而不是用于处理数据。 Assuming that you meant Azure DevOps Pipelines , opposed to Azure ML Pipelines .
假设您指的是Azure DevOps Pipelines ,而不是Azure ML Pipelines 。
Also you should not commit data to your repository.此外,您不应将数据提交到您的存储库。
If you still want to proceed, here is an example for what you try to achieve.如果您仍想继续,这里是您尝试实现的目标的示例。 Note that for the last line, ie
git push
, you need to give the agent permission to write the repository.请注意,对于最后一行,即
git push
,您需要授予代理写入存储库的权限。 See Run Git commands in a script for an approximate ☹️ documentation on how to do that on your account.有关如何在您的帐户上执行此操作的大致☹️ 文档,请参阅在脚本中运行 Git 命令。
trigger: none
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
persistCredentials: true
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
addToPath: true
architecture: 'x64'
- script: |
python your_data_generating_script.py
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git add data/prepared.csv
git commit -m'test commit'
git push origin HEAD:master
displayName: 'push data to master'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.