Skip to content

Issue 17 - guidance on running cookbooks #15

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@ jobs:
if: github.repository == 'ProjectPythiaCookbooks/projectpythiacookbooks.github.io'
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.9.1
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: conda-incubator/setup-miniconda@master
with:
@@ -41,7 +41,7 @@ jobs:
rm -rf site.zip
fi
zip -r site.zip ./site/_build/html
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: site-zip
path: ./site.zip
14 changes: 7 additions & 7 deletions .github/workflows/preview.yaml
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set message value
run: |
echo "comment_message=This pull request is being automatically built with [GitHub Actions](https://github.com/features/actions) and [Netlify](https://www.netlify.com/). To see the status of your deployment, click below." >> $GITHUB_ENV
- name: Find Pull Request
uses: actions/github-script@v4
uses: actions/github-script@v6
id: find-pull-request
with:
script: |
@@ -45,7 +45,7 @@ jobs:
core.info(`Found pull request ${pullRequestNumber}, with head sha: ${pullRequestHeadSHA}`)
}
- name: Find Comment
uses: peter-evans/find-comment@v1
uses: peter-evans/find-comment@v2
if: steps.find-pull-request.outputs.number != ''
id: fc
with:
@@ -57,7 +57,7 @@ jobs:
github.event.workflow_run.conclusion != 'success'
&& steps.find-pull-request.outputs.number != ''
&& steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ steps.find-pull-request.outputs.number }}
body: |
@@ -69,7 +69,7 @@ jobs:
github.event.workflow_run.conclusion != 'success'
&& steps.find-pull-request.outputs.number != ''
&& steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v1
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
@@ -82,7 +82,7 @@ jobs:
github.event.workflow_run.conclusion == 'success'
&& steps.find-pull-request.outputs.number != ''
&& steps.fc.outputs.comment-id != ''
uses: dawidd6/action-download-artifact@v2.14.1
uses: dawidd6/action-download-artifact@v2.21.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: ci.yaml
@@ -119,7 +119,7 @@ jobs:
github.event.workflow_run.conclusion == 'success'
&& steps.find-pull-request.outputs.number != ''
&& steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v1
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# projectpythiatutorials.github.io
Root site for the ProjectPythiaTutorials GitHub Pages

projectpythiacookbooks.github.io
39 changes: 35 additions & 4 deletions site/_extensions/gallery_generator.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,29 @@
from truncatehtml import truncate


def _generate_url_from_repo(repo):
cookbook_url = f'https://cookbooks.projectpythia.org/{repo}/README.html'
return cookbook_url


def _generate_github_url_from_repo(repo):
github_url = f'https://github.com/ProjectPythiaCookbooks/{repo}'
return github_url


#def _get_thumbnail_url(repo):
# github_url = _generate_github_url_from_repo(repo)
# return f'{github_url}/thumbnail.png'


def _generate_status_badge_html(repo):
github_url = _generate_github_url_from_repo(repo)

return f"""
<a class="reference external" href="{github_url}/actions/workflows/nightly-build.yaml"><img alt="nightly-build" src="{github_url}/actions/workflows/nightly-build.yaml/badge.svg" /></a>
<a class="reference external" href="https://binder-staging.2i2c.cloud/v2/gh/ProjectPythiaTutorials/{repo}.git/main"><img alt="Binder" src="https://binder-staging.2i2c.cloud/badge_logo.svg" /></a>
"""

def _generate_sorted_tag_keys(all_items):

key_set = set(itertools.chain(*[item['tags'].keys() for item in all_items]))
@@ -71,13 +94,19 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
# Build the gallery file
panels_body = []
for item in items:
repo = item['repo']
#thumbnail = _get_thumbnail_url(repo)
cookbook_url = _generate_url_from_repo(repo)
status_badges = _generate_status_badge_html(repo)

if not item.get('thumbnail'):
item['thumbnail'] = '/_static/images/ebp-logo.png'
thumbnail = item['thumbnail']

tag_list = sorted((itertools.chain(*item['tags'].values())))
tag_list_f = [tag.replace(' ', '-') for tag in tag_list]

tags = [f'<span class="badge bg-primary">{tag}</span>' for tag in tag_list_f]
tags = [f'<span class="badge bg-primary mybadges">{tag}</span>' for tag in tag_list_f]
tags = '\n'.join(tags)

tag_class_str = ' '.join(tag_list_f)
@@ -122,7 +151,7 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
{institutions_str}
<p class="my-2">{item['description']}</p>
<p class="my-2">{tags}</p>
<p class="mt-3 mb-0"><a href="{item["url"]}" class="btn btn-outline-primary btn-block">Visit Website</a></p>
<p class="mt-3 mb-0"><a href="{cookbook_url}" class="btn btn-outline-primary btn-block">Visit Website</a></p>
</div>
</div>
"""
@@ -137,16 +166,18 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
<div class="d-flex gallery-card">
<img src="{thumbnail}" class="gallery-thumbnail" />
<div class="container">
<a href="{item["url"]}" class="text-decoration-none"><h4 class="display-4 p-0">{item["title"]}</h4></a>
<a href="{cookbook_url}" class="text-decoration-none"><h4 class="display-4 p-0">{item["title"]}</h4></a>
<p class="card-subtitle">{authors_str}<br/>{institutions_str}</p>
<p class="my-2">{short_description}</p>
</div>
</div>
{modal_str}

+++

<div class="tagsandbadges">
{tags}
<div{status_badges}</div>
</div>

"""
)
10 changes: 9 additions & 1 deletion site/_static/custom.css
Original file line number Diff line number Diff line change
@@ -118,4 +118,12 @@ main.banner-main #project-pythia {
height: 1px;
width: 0px;
}


.badge.mybadges {
margin-bottom: 0;
font-weight: 0;
}

.tagsandbadges {
padding: 0 0;
}
4 changes: 2 additions & 2 deletions site/cookbook_gallery.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- title: Radar Cookbook
url: https://projectpythiatutorials.github.io/radar-cookbook/landing-page.html
repo: radar-cookbook
description: |
This Project Pythia Cookbook covers the basics of working with weather radar data in Python.
authors:
@@ -9,5 +9,5 @@
domains:
- radar
packages:
- py-art
- Py-ART

24 changes: 18 additions & 6 deletions site/index.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,13 @@

Pythia Cookbooks provide example workflows on more advanced and domain-specific problems developed by the Pythia community. Cookbooks build on top of skills you learn in Pythia Foundations.

Cookbooks are created from Jupyter Notebooks that we strive to *binderize*
so each Cookbook can be executed in the cloud with a single click from your
browswer. See documentation
[here](https://foundations.projectpythia.org/preamble/how-to-use.html#interacting-with-jupyter-notebooks-in-the-cloud-via-binder)
for details. In some instances executing a Cookbook will require downloading
the Notebook to your local laptop or desktop as described [here](https://foundations.projectpythia.org/preamble/how-to-use.html#interacting-with-jupyter-books-locally).

<div class="d-sm-flex mt-3 mb-4">
<div class="d-flex gallery-menu">
</div>
@@ -27,7 +34,7 @@ Domains
Packages
</button>
<ul class="dropdown-menu" aria-labelledby="packagesDropdown">
<li><label class="dropdown-item checkbox packages"><input type="checkbox" rel=py-art onchange="change();">&nbsp;Py-art</label></li>
<li><label class="dropdown-item checkbox packages"><input type="checkbox" rel=Py-ART onchange="change();">&nbsp;Py-art</label></li>
</ul>
</div>

@@ -44,12 +51,12 @@ Packages
:footer: p-1

---
:column: + tagged-card py-art radar
:column: + tagged-card Py-ART radar

<div class="d-flex gallery-card">
<img src="_static/images/thumbnails/arm_logo.png" class="gallery-thumbnail" />
<div class="container">
<a href="https://projectpythiatutorials.github.io/radar-cookbook/landing-page.html" class="text-decoration-none"><h4 class="display-4 p-0">Radar Cookbook</h4></a>
<a href="https://cookbooks.projectpythia.org/radar-cookbook/README.html" class="text-decoration-none"><h4 class="display-4 p-0">Radar Cookbook</h4></a>
<p class="card-subtitle"><strong>Author:</strong> Max Grover<br/></p>
<p class="my-2">This Project Pythia Cookbook covers the basics of working with weather radar data in Python.
</p>
@@ -58,9 +65,14 @@ Packages


+++

<span class="badge bg-primary">py-art</span>
<span class="badge bg-primary">radar</span>
<div class="tagsandbadges">
<span class="badge bg-primary mybadges">Py-ART</span>
<span class="badge bg-primary mybadges">radar</span>
<div
<a class="reference external" href="https://github.com/ProjectPythiaCookbooks/radar-cookbook/actions/workflows/nightly-build.yaml"><img alt="nightly-build" src="https://github.com/ProjectPythiaCookbooks/radar-cookbook/actions/workflows/nightly-build.yaml/badge.svg" /></a>
<a class="reference external" href="https://binder-staging.2i2c.cloud/v2/gh/ProjectPythiaTutorials/radar-cookbook.git/main"><img alt="Binder" src="https://binder-staging.2i2c.cloud/badge_logo.svg" /></a>
</div>
</div>


````