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

Adding runner.sh.j2 and zenodo_uploader.py files #9

Merged
merged 50 commits into from
Jul 28, 2021

Conversation

GioRosario
Copy link
Contributor

@GioRosario GioRosario commented Jul 23, 2021

Checklist:

  • Demonstrate generation of the runner.sh file based on the config .yml files (use https://github.com/NSLS-II/conda-pack-template/blob/main/configs/n2sn.yml for now, that should produce a small environment .tar.gz file of ~50MB in size, and update as necessary).
  • Demonstrate automated uploading to quay.io, DockerHub, and GHCR and post the links in this PR in a comment below.
  • Demonstrate automated uploading to Zenodo and post the link in this PR in a comment below.

Copy link
Collaborator

@mrakitin mrakitin left a comment

Choose a reason for hiding this comment

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

Thanks, @johngedell. I left a few suggestions and comments on how to tweak the code to be more ready for production (batch mode).

I'd expect the pull request body to contain some output of the scripts, and examples of application of the renderer with the config .yml files to generate the resulting runner.sh scripts. Can it be done?

Also, can you please demonstrate that this script could upload Docker images to all 3 places (quay, dockerhub, ghcr) and provide the resulting links?

Same would be great for Zenodo, at least using their sandbox website, but keeping in mind we need to eventually upload to their production site.

runner.sh.j2 Outdated Show resolved Hide resolved
runner.sh.j2 Outdated
timestamp=$(date +%Y%m%d%H%M%S)
env_name="nsls2-analysis-2021-1.2"

{% if -f "${image}.tar.gz" %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

These jinja conditions should be used for values based on config files, not the actual state during runtime. I suggest converting this condition to a normal bash if.

zenodo_uploader.py Show resolved Hide resolved
zenodo_uploader.py Outdated Show resolved Hide resolved
zenodo_uploader.py Outdated Show resolved Hide resolved
zenodo_uploader.py Outdated Show resolved Hide resolved
zenodo_uploader.py Outdated Show resolved Hide resolved
runner.sh.j2 Outdated Show resolved Hide resolved
runner.sh.j2 Outdated
Comment on lines 26 to 47
{% for v in range(VALUE) %}
read -p "To which repository would you like to upload? (Enter 'ghcr', 'dockerhub', or 'quay') " REPO
{% if "REPO" == "ghcr" %}
echo $GITHUB_TOKEN | docker login ghcr.io --username $GITHUB_USERNAME --password-stdin
docker tag ${image}:${timestamp} ghcr.io/$GITHUB_USERNAME/${image}:${timestamp}
docker image push ghcr.io/$GITHUB_USERNAME/${image}:${timestamp}
{% elif "REPO" == "dockerhub" %}
echo $DOCKER_PASSWORD | docker login --username $DOCKER_USERNAME --password-stdin
docker tag ${image}:${timestamp} $DOCKER_REPO
docker push $DOCKER_REPO
{% elif "REPO" == "quay" %}
docker create --name extra-container ${image}:${timestamp}
echo $QUAY_PASSWORD | docker login quay.io -u $QUAY_USERNAME --password-stdin
docker commit extra-container quay.io/$QUAY_REPO
docker push quay.io/$QUAY_REPO
docker rm extra-container
docker image rm quay.io/$QUAY_REPO
{% else %}
echo "Invalid entry."
exit 1
{% endif %}
{% endfor %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest reworking it to exclude the jinja conditions, and rather use the .yml config files as input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I missed this when I was initially created the files. I will add this on my list of changes to make and leave unresolved.

runner.sh.j2 Outdated
Comment on lines 49 to 52
read -p "Would like to upload the file to Zenodo? " ZEN
{% if "ZEN" == "yes" -o "$ZEN" == "y" %}
python3 -m zenodo_upload
{% endif %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above - use config files to manage that part.

@mrakitin
Copy link
Collaborator

mrakitin commented Jul 23, 2021

I updated the PR body with the checklist:
image

Copy link
Collaborator

@mrakitin mrakitin left a comment

Choose a reason for hiding this comment

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

I spotted a couple of issues with the new addition to the Zenodo uploader code. Please use the "Commit suggestion" button(s) to commit the suggested changes, and then go git pull on your local clone.

zenodo_uploader.py Outdated Show resolved Hide resolved
zenodo_uploader.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@mrakitin mrakitin left a comment

Choose a reason for hiding this comment

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

@johngedell, here is my review. I did not see the items that you mentioned yesterday (such as moving runner.sh from conda/ to the top of the dir, moving all template .j2 files into the templates directory, etc.)

Please address my comments, and add the discussed changes.

conda/Dockerfile.j2 Outdated Show resolved Hide resolved
conda/Dockerfile.j2 Outdated Show resolved Hide resolved
conda/Dockerfile.j2 Outdated Show resolved Hide resolved
conda/Dockerfile.j2 Outdated Show resolved Hide resolved
ENV PATH="opt/conda/bin/:$PATH"
ENV env_name="{{env_name}}"
ENV python_version="{{python_version}}"
ENV pkg_name="{% if pkg_name %}{{pkg_name}}={{pkg_version}}{% endif %}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if the pkg_name is undefined?

Suggested change
ENV pkg_name="{% if pkg_name %}{{pkg_name}}={{pkg_version}}{% endif %}"
ENV pkg_name="{% if pkg_name %}{{ pkg_name }}={{ pkg_version }}{% endif %}"

conda/zenodo_uploader.py Outdated Show resolved Hide resolved
conda/zenodo_uploader.py Outdated Show resolved Hide resolved
conda/zenodo_uploader.py Outdated Show resolved Hide resolved
conda/zenodo_uploader.py Outdated Show resolved Hide resolved
)
args = parser.parse_args()
upload_to_zenodo(args.file_name_to_upload)
print("Upload Done!")
Copy link
Collaborator

Choose a reason for hiding this comment

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

The print needs to have some resulting information, such as the full URL to where it was uploaded.

GioRosario and others added 3 commits July 27, 2021 10:41
Co-authored-by: Maksim Rakitin <mrakitin@users.noreply.github.com>
Co-authored-by: Maksim Rakitin <mrakitin@users.noreply.github.com>
Copy link
Collaborator

@mrakitin mrakitin left a comment

Choose a reason for hiding this comment

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

I am going to merge this PR now, and Zenodo uploading features can be added in subsequent PRs.

@mrakitin mrakitin merged commit 2a44009 into nsls2-conda-envs:main Jul 28, 2021
@mrakitin
Copy link
Collaborator

The result for the third task is demonstrated in #13 and #11.

@mrakitin
Copy link
Collaborator

The result for the first task is demonstrated in #11 and #9 (here, implemented via b3dc5f1).

@mrakitin mrakitin mentioned this pull request Jul 30, 2021
2 tasks
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.

2 participants