Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Conda Lock Updating Action #5

Merged
merged 2 commits into from
Aug 19, 2021
Merged

Conversation

ajelinski
Copy link
Contributor

This GitHub Action creates or updates Conda Lock from the freshly created Conda Environment based on the Conda environment.yml file. The Pull Request is automatically issued if there is any change in the Conda Lock.

The workflow using this Action is available at: https://github.com/antmicro/symbiflow-examples-bot/blob/master/.github/workflows/update_conda_locks.yml
The example workflow jobs can be checked at: https://github.com/antmicro/symbiflow-examples-bot/actions/runs/453502941
The lock is quite fresh in there on the master branch so apart from the environment's name change (due to the script change) in the latest PR there's only one package updated but it can be seen how the Conda Lock looks like: https://github.com/antmicro/symbiflow-examples-bot/pull/41/files

@ajelinski
Copy link
Contributor Author

I can see that I need to add #.*coding: utf-8 and LICENSE to satisfy the Checks test. Should the license simply resemble that found in the other files @mithro @umarcor? https://github.com/SymbiFlow/actions/blob/77e0cafc07a9dfbe39d41aad30c57c0211ba5af6/checks/check_license.sh#L3-L7

update_conda_lock/action.yml Outdated Show resolved Hide resolved
update_conda_lock/action.yml Outdated Show resolved Hide resolved
update_conda_lock/action.yml Outdated Show resolved Hide resolved
update_conda_lock/action.yml Outdated Show resolved Hide resolved
update_conda_lock/action.yml Outdated Show resolved Hide resolved
@umarcor
Copy link
Contributor

umarcor commented Dec 30, 2020

I can see that I need to add #.*coding: utf-8 and LICENSE to satisfy the Checks test. Should the license simply resemble that found in the other files @mithro @umarcor?

Yes, please. Unless you have any specific requirement.

@umarcor
Copy link
Contributor

umarcor commented Dec 30, 2020

Please, add it to the README too.

@ajelinski ajelinski force-pushed the add_conda_locker branch 2 times, most recently from da38492 to 4c154b8 Compare December 31, 2020 01:49
@ajelinski
Copy link
Contributor Author

I had to make some small fixes after testing on symbiflow-arch-defs CI. I've fixed failing checks although I have to make sure about the copyright. Therefore I'll make it draft for now.

@mithro
Copy link
Contributor

mithro commented Apr 19, 2021

@ajelinski - Ping? I would like to get this GitHub action moving again?

@ajelinski
Copy link
Contributor Author

I still need to test if everything works well after these changes but please take a look if you like it more now @umarcor.

@ajelinski ajelinski force-pushed the add_conda_locker branch 3 times, most recently from e2cf5d3 to 0d69a68 Compare April 29, 2021 23:17
@ajelinski
Copy link
Contributor Author

ajelinski commented Apr 29, 2021

Rebased and fixed after testing on a symbiflow-examples repository clone. A PR created by this action is e.g.
antmicro/symbiflow-examples-bot#142 (created during https://github.com/antmicro/symbiflow-examples-bot/actions/runs/797726587).

GitHub
Contribute to antmicro/symbiflow-examples-bot development by creating an account on GitHub.

Copy link
Contributor

@umarcor umarcor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The structure looks much nicer and easier to understand/maintain. Congrats for the cleanup!

@ajelinski ajelinski marked this pull request as ready for review May 13, 2021 16:39
@ajelinski
Copy link
Contributor Author

I'm glad you like it @umarcor!

I've cleaned the commit history. I think now this PR is ready to be merged.

@ajelinski ajelinski force-pushed the add_conda_locker branch 2 times, most recently from c7ccc09 to eec0e64 Compare May 21, 2021 08:15
@ajelinski
Copy link
Contributor Author

ajelinski commented May 21, 2021

I tested the bot again to make sure that everything still works as intended before it's merged.

Somehow after separating scripts and steps I skipped the test of the special case when the lock is up to date. It needed a little modification to work properly (exit 0 was enough when it was a single script): https://github.com/SymbiFlow/actions/compare/d358d22afdaf54376197be3bd1c9af265e79ecb2..6970a7e6257a3e66dec67b97cd51c44a0c34ad5b

BTW there's also an issue with pip that doesn't handle simultaneous installation of git-based packages with their git-based dependencies properly. I've found a way to avoid it, i.e. making pip ignore package dependencies when Conda creates the environment based on the Conda Lock. It is absolutely safe to do since all packages, including the dependencies, are in the Conda Lock anyway.

I have created an issue on pip so maybe it won't be needed in the future: pypa/pip#10002

For now, I added information on how to handle such a situation to the README: eec0e64 .

Could you please take another look at the action changes @umarcor? Now the action is definitely ready to be merged if you find them acceptable.

GitHub
GitHub Actions to be reused in CI workflows. Contribute to SymbiFlow/actions development by creating an account on GitHub.

@umarcor
Copy link
Contributor

umarcor commented May 21, 2021

LGTM! @mithro, I'll let you merge 😉

@mithro
Copy link
Contributor

mithro commented May 21, 2021

BTW there's also an issue with pip that doesn't handle simultaneous installation of git-based packages with their git-based dependencies properly. I've found a way to avoid it, i.e. making pip ignore package dependencies when Conda creates the environment based on the Conda Lock. It is absolutely safe to do since all packages, including the dependencies, are in the Conda Lock anyway.

I have created an issue on pip so maybe it won't be needed in the future: pypa/pip#10002

We should not have any packages which use the @ symbol in their install_requires as we determined that functionality is fundamentally broken. Instead the install_requires should list the package name and then the requirements.txt should specify how/where to get the package from (IE a git+http:// URL).

Copy link
Contributor

@mithro mithro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor formatting / style issues.

Can you run pylint or flake8 on your Python files?

README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
run: $GITHUB_ACTION_PATH/check_prepare_env.sh

- shell: bash
run: |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would probably be better as a Python script?

Copy link
Contributor Author

@ajelinski ajelinski May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you meant it this way but I can't make it a separate script since it uses GH Action inputs so it has to be in the action.yml file.

If you thought about only converting it to Python but leaving it in action.yml then I'm not sure. Why would it be better?

@@ -0,0 +1,48 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make this file Python it can work on windows / mac / linux? We already require Python for other parts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script should work on all these OSs, there's nothing really OS-specific.

@@ -0,0 +1,50 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we make this file Python it can work on windows / mac / linux? We already require Python for other parts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script itself should work on all these OSs but I'm not sure about update_lock.py on Windows with its \r\n newlines as there are some file manipulations involved.

update_conda_lock/create_pull_request.py Outdated Show resolved Hide resolved
update_conda_lock/update_lock.py Outdated Show resolved Hide resolved
update_conda_lock/update_lock.py Outdated Show resolved Hide resolved
update_conda_lock/update_lock.py Outdated Show resolved Hide resolved
Signed-off-by: Adam Jeliński <[email protected]>
@ajelinski
Copy link
Contributor Author

BTW there's also an issue with pip that doesn't handle simultaneous installation of git-based packages with their git-based dependencies properly. I've found a way to avoid it, i.e. making pip ignore package dependencies when Conda creates the environment based on the Conda Lock. It is absolutely safe to do since all packages, including the dependencies, are in the Conda Lock anyway.
I have created an issue on pip so maybe it won't be needed in the future: pypa/pip#10002

We should not have any packages which use the @ symbol in their install_requires as we determined that functionality is fundamentally broken. Instead the install_requires should list the package name and then the requirements.txt should specify how/where to get the package from (IE a git+http:// URL).

From what I saw working with pip on this action I can only agree but can you show me some example of this cooperation between install_requires and the requirements.txt?

@ajelinski
Copy link
Contributor Author

ajelinski commented May 27, 2021

The Python scripts had many changes, e.g. docstrings were added, since I found many parts not easily understandable after these few months. They fully conform to the flake8 and pylint rules now.

@ajelinski
Copy link
Contributor Author

@mithro Should I make any changes to have this PR merged?

@mithro
Copy link
Contributor

mithro commented Aug 18, 2021

Check with @acomodi and @kgugala - If they are happy merge away!

@acomodi
Copy link
Contributor

acomodi commented Aug 19, 2021

@ajelinski LGTM

@kgugala kgugala merged commit e22f88d into f4pga:main Aug 19, 2021
@ajelinski ajelinski deleted the add_conda_locker branch August 19, 2021 08:54
@mithro
Copy link
Contributor

mithro commented Aug 19, 2021

@acomodi - Now we just need to deploy this everywhere?

@acomodi
Copy link
Contributor

acomodi commented Aug 19, 2021

@mithro Yes, we can test this right away with arch-defs for starters

@mithro
Copy link
Contributor

mithro commented Aug 19, 2021

Would symbiflow-examples be an easier starting repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants