Skip to content

Commit

Permalink
Merge pull request #81 from nmfs-opensci/main
Browse files Browse the repository at this point in the history
update from main
  • Loading branch information
eeholmes authored Oct 22, 2024
2 parents e28353f + a03c5ea commit 8bc871e
Show file tree
Hide file tree
Showing 43 changed files with 11,221 additions and 87 deletions.
26 changes: 2 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
Expand All @@ -26,17 +24,14 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
Expand All @@ -50,57 +45,43 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
Expand All @@ -109,21 +90,18 @@ venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
.Rproj.user
py-rocket-base.Rproj
1 change: 1 addition & 0 deletions book/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
47 changes: 47 additions & 0 deletions book/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
project:
type: book
output-dir: ../docs # Path to output directory, relative to _quarto.yml

book:
page-navigation: true
title: "py-rocket-base documentation"
site-url: "https://nmfs-opensci.github.io/py-rocket-base"
repo-url: "https://github.com/nmfs-opensci/py-rocket-base"
repo-actions: [edit, source, issue]
favicon: assets/favicon.ico
search: true
author:
- name: Eli Holmes
affiliations:
- name: NOAA Fisheres
department: NMFS Open Science
chapters:
- index.qmd
- customizing.qmd
- configuration_files.qmd
- desktop.qmd
- tex.qmd
- py-rocket-base.qmd

sidebar:
background: "#D9E3E4"
logo: "https://raw.githubusercontent.com/nmfs-opensci/assets/main/logo/nmfs-opensci-logo3.png"
pinned: true
align: center
tools:
- icon: globe
href: https://nmfs-opensci.github.io
text: "NMFS Open Science"
style: "docked"
search: true
collapse-level: 1


format:
html:
theme:
light: [cosmo, theme.scss]
dark: [cosmo, theme-dark.scss]
code-copy: true
code-overflow: wrap
toc: true
1 change: 1 addition & 0 deletions book/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This folder has various formatting files.
Binary file added book/assets/favicon.ico
Binary file not shown.
115 changes: 115 additions & 0 deletions book/assets/include-files.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
--- include-files.lua – filter to include Markdown files
---
--- Copyright: © 2019–2021 Albert Krewinkel
--- License: MIT – see LICENSE file for details

-- Module pandoc.path is required and was added in version 2.12
PANDOC_VERSION:must_be_at_least '2.12'

local List = require 'pandoc.List'
local path = require 'pandoc.path'
local system = require 'pandoc.system'

--- Get include auto mode
local include_auto = false
function get_vars (meta)
if meta['include-auto'] then
include_auto = true
end
end

--- Keep last heading level found
local last_heading_level = 0
function update_last_level(header)
last_heading_level = header.level
end

--- Update contents of included file
local function update_contents(blocks, shift_by, include_path)
local update_contents_filter = {
-- Shift headings in block list by given number
Header = function (header)
if shift_by then
header.level = header.level + shift_by
end
return header
end,
-- If image paths are relative then prepend include file path
Image = function (image)
if path.is_relative(image.src) then
image.src = path.normalize(path.join({include_path, image.src}))
end
return image
end,
-- Update path for include-code-files.lua filter style CodeBlocks
CodeBlock = function (cb)
if cb.attributes.include and path.is_relative(cb.attributes.include) then
cb.attributes.include =
path.normalize(path.join({include_path, cb.attributes.include}))
end
return cb
end
}

return pandoc.walk_block(pandoc.Div(blocks), update_contents_filter).content
end

--- Filter function for code blocks
local transclude
function transclude (cb)
-- ignore code blocks which are not of class "include".
if not cb.classes:includes 'include' then
return
end

-- Markdown is used if this is nil.
local format = cb.attributes['format']

-- Attributes shift headings
local shift_heading_level_by = 0
local shift_input = cb.attributes['shift-heading-level-by']
if shift_input then
shift_heading_level_by = tonumber(shift_input)
else
if include_auto then
-- Auto shift headings
shift_heading_level_by = last_heading_level
end
end

--- keep track of level before recusion
local buffer_last_heading_level = last_heading_level

local blocks = List:new()
for line in cb.text:gmatch('[^\n]+') do
if line:sub(1,2) ~= '//' then
local fh = io.open(line)
if not fh then
io.stderr:write("Cannot open file " .. line .. " | Skipping includes\n")
else
local contents = pandoc.read(fh:read '*a', format).blocks
last_heading_level = 0
-- recursive transclusion
contents = system.with_working_directory(
path.directory(line),
function ()
return pandoc.walk_block(
pandoc.Div(contents),
{ Header = update_last_level, CodeBlock = transclude }
)
end).content
--- reset to level before recursion
last_heading_level = buffer_last_heading_level
blocks:extend(update_contents(contents, shift_heading_level_by,
path.directory(line)))
fh:close()
end
end
end
return blocks
end

return {
{ Meta = get_vars },
{ Header = update_last_level, CodeBlock = transclude }
}
26 changes: 26 additions & 0 deletions book/assets/theme-dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*-- scss:defaults --*/

@import 'https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible&display=swap';

$font-family: "Atkinson Hyperlegible", sans-serif;

// Base document colors
$body-bg: #181818;
$body-color: white;
$link-color: #75AADB;

$light: #525252;

// Navigation element colors
$footer-bg: #181818;
$navbar-bg: #303030;
$sidebar-bg: #303030;

// Code blocks
$code-block-bg-alpha: -.8;

// Bootstrap popovers
$popover-bg: #242424;

// Bootstrap inputs
$input-bg: #242424;
6 changes: 6 additions & 0 deletions book/assets/theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*-- scss:defaults --*/

@import 'https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible&display=swap';

$font-family: "Atkinson Hyperlegible", sans-serif;

15 changes: 15 additions & 0 deletions book/configuration_files.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Configuration files

The presence of these files will trigger the following behavior. Do not use these names if you do not want this behavior and you instead want
to write you own code in your Dockerfile.

## environment.yml

## install.R

## apt.txt

## postBuild

## Desktop directory

57 changes: 57 additions & 0 deletions book/customizing.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Using py-rocket-base

py-rocket-base is designed to be used in the FROM line of a Dockerfile. It behaves like repo2docker in that it looks for special files and will
install Python package or R packages if those special files are present. You do not need to add anything to the Dockerfile to have it process these files. py-rocker-base does this automatically for you.

If you don't want it to do this then do not name your files one of these names:

- environment.yml
- install.R
- postBuild
- apt.txt
- start

## File structure

Only Dockerfile is required. The rest are optional.

```
your-repo/
├── Dockerfile
├── apt.txt
├── environment.yml
├── install.R
├── postBuild
├── start
├── Desktop/
│ ├── qgis.desktop
│ ├── qgis.xml
│ └── qgis.png
```

Read [configuration_files](configuration_files.html) to learn about apt.txt, environment.yml, install.R, postBuild, and start. Read [Desktop](desktop.html) to learn about the Desktop folder and files for applications.

## Examples

You want to add some Python packages to py-rocker-base.

```
your-repo/
├── Dockerfile
├── environment.yml
```

Dockerfile
```
FROM ghcr.io/nmfs-opensci/py-rocket-base:latest
```

environment.yml
```
name: optional
channels:
- conda-forge
dependencies:
- cmocean
- numpy
```
Loading

0 comments on commit 8bc871e

Please sign in to comment.