Skip to content

Adding CSS to new domain #2

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

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GLOBAL OWNER
* @ProjectPythia/infrastructure
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
# - package-ecosystem: pip
# directory: "/"
# schedule:
# interval: daily
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
# Check for updates once a week
interval: 'weekly'
84 changes: 84 additions & 0 deletions .github/workflows/collect-user-submission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import json
import os
import typing

import frontmatter
import pydantic
from markdown_it import MarkdownIt


class Author(pydantic.BaseModel):
name: str = 'anonymous'
affiliation: str = None
affiliation_url: typing.Union[str, pydantic.HttpUrl] = None
email: typing.Union[str, pydantic.EmailStr] = None


class Submission(pydantic.BaseModel):
title: str
description: str
url: pydantic.HttpUrl
thumbnail: typing.Union[str, pydantic.HttpUrl] = None
authors: typing.List[Author] = None
tags: typing.Dict[str, typing.List[str]] = None


@pydantic.dataclasses.dataclass
class IssueInfo:
gh_event_path: pydantic.FilePath
submission: Submission = pydantic.Field(default=None)

def __post_init_post_parse__(self):
with open(self.gh_event_path) as f:
self.data = json.load(f)

def create_submission(self):
self._get_inputs()
self._create_submission_input()
return self

def _get_inputs(self):
self.author = self.data['issue']['user']['login']
self.title = self.data['issue']['title']
self.body = self.data['issue']['body']

def _create_submission_input(self):
md = MarkdownIt()
inputs = None
for token in md.parse(self.body):
if token.tag == 'code':
inputs = frontmatter.loads(token.content).metadata
break
name = inputs.get('name')
title = inputs.get('title')
description = inputs.get('description')
url = inputs.get('url')
thumbnail = inputs.get('thumbnail')
_authors = inputs.get('authors')
authors = []
if _authors:
for item in _authors:
authors.append(
Author(
name=item.get('name', 'anyonymous'),
affiliation=item.get('affiliation'),
affiliation_url=item.get('affiliation_url'),
email=item.get('email', ''),
)
)
else:
authors = [Author(name='anyonymous')]
_tags = inputs.get(
'tags', {'packages': ['unspecified'], 'formats': ['unspecified'], 'domains': ['unspecified']}
)
self.submission = Submission(
name=name, title=title, description=description, url=url, thumbnail=thumbnail, authors=authors, tags=_tags
)


if __name__ == '__main__':

issue = IssueInfo(gh_event_path=os.environ['GITHUB_EVENT_PATH']).create_submission()
inputs = issue.submission.dict()
with open('gallery-submission-input.json', 'w') as f:
json.dump(inputs, f)
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
portal/_build/
dist/
49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-json
- id: check-yaml
- id: double-quote-string-fixer

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: https://github.com/keewis/blackdoc
rev: v0.3.4
hooks:
- id: blackdoc

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort

# - repo: https://github.com/prettier/pre-commit
# rev: 57f39166b5a5a504d6808b87ab98d41ebf095b46
# hooks:
# - id: prettier

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.3.1
hooks:
- id: nbqa-black
additional_dependencies: [black==20.8b1]
- id: nbqa-pyupgrade
additional_dependencies: [pyupgrade==2.7.3]
# - id: nbqa-isort
# additional_dependencies: [isort==5.6.4]
14 changes: 14 additions & 0 deletions ci/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pythia-tutorial-dev
channels:
- conda-forge
- nodefaults
dependencies:
- matplotlib
- myst-nb
- pandas
- pip
- pyyaml
- pre-commit
- sphinx-panels
- pip:
- sphinx-pythia-theme
20 changes: 20 additions & 0 deletions portal/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:root {
--tabs-color-label-active: hsla(231, 99%, 66%, 1);
--tabs-color-label-inactive: rgba(178, 206, 245, 0.62);
--tabs-color-overline: rgb(207, 236, 238);
--tabs-color-underline: rgb(207, 236, 238);
--tabs-size-label: 1rem;
}
17 changes: 17 additions & 0 deletions portal/_extensions/cookbook_gallery_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import yaml
from gallery_generator import build_from_items, generate_menu


def main(app):

with open('cookbook_gallery.yaml') as fid:
all_items = yaml.safe_load(fid)

title = 'Cookbooks Gallery'
subtext = '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.'
menu_html = generate_menu(all_items)
build_from_items(all_items, 'index', title=title, subtext=subtext, menu_html=menu_html)


def setup(app):
app.connect('builder-inited', main)
Loading