简体   繁体   English

GitHub Actions 在子目录中时不创建文件

[英]GitHub Actions not creating files when it's in a subdirectory

I'm trying to learn how to use GitHub Actions and I'm running into a small issue.我正在尝试学习如何使用 GitHub Actions,但遇到了一个小问题。 When I run the code locally, the files created while python training/train.py is running are created in the correct folder.当我在本地运行代码时,在运行python training/train.py创建的文件会在正确的文件夹中创建。 However, when I try to do the same thing with GitHub Actions, the files are only created when I choose to create them in the root directory rather than /training/outputs/ .但是,当我尝试用 GitHub Actions 做同样的事情时,只有当我选择在根目录而不是/training/outputs/创建文件时,才会创建文件。 Is there a way to resolve this?有没有办法解决这个问题?

Here's my GitHub repository: https://github.com/JayThibs/github-actions-ml-template这是我的 GitHub 存储库: https : //github.com/JayThibs/github-actions-ml-template

I've figured out how to resolve this so I figured I should share here.我已经想出了如何解决这个问题,所以我想我应该在这里分享。

Since I am using CML (Continuous Machine Learning), I could simply include the following line in my GitHub Actions cml.yaml file:由于我使用的是 CML(连续机器学习),我可以简单地在我的 GitHub Actions cml.yaml 文件中包含以下行:

cml-pr training/outputs/*

This is because cml does not push outputs to my code automatically.这是因为 cml 不会自动将输出推送到我的代码。

Besides using cml-pr , you can also use the following github push manually:除了使用cml-pr ,您还可以手动使用以下 github push:

git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

git add training/outputs/*
git commit --message "Commit training outputs"
git push

Please keep in mind that the latter solution won't handle merge conflicts gracefully if there is a race condition between several simultaneous runs.请记住,如果多个同时运行之间存在竞争条件,后一种解决方案将无法正常处理合并冲突。

Since the action will push files to your repository, it will trigger another GitHub Action if your action is triggered on push.由于操作会将文件推送到您的存储库,如果您的操作在推送时触发,它将触发另一个 GitHub 操作。 To resolve this, simply add something like [skip ci] in your commit message and GitHub will prevent an action to be triggered.要解决此问题,只需在提交消息中添加类似 [skip ci] 的内容,GitHub 将阻止触发操作。 You can learn more about it here: https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/你可以在这里了解更多信息: https : //github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/

0x2b3bfa0 on GitHub helped me resolve this issue, you can find our conversation here: https://github.com/iterative/cml/issues/658 GitHub 上的 0x2b3bfa0 帮助我解决了这个问题,你可以在这里找到我们的对话: https : //github.com/iterative/cml/issues/658

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM