Skip to content

Commit

Permalink
Merge pull request #13 from sandialabs/main
Browse files Browse the repository at this point in the history
testing
  • Loading branch information
tnelson-integral authored Sep 4, 2024
2 parents 82d6042 + b833f1f commit eb80e59
Show file tree
Hide file tree
Showing 15 changed files with 2,404 additions and 1,354 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Black Code Formatter

on: [push, pull_request]

jobs:
black:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.12"

- name: Install Black
run: |
python -m pip install --upgrade pip
pip install black
- name: Check Black Formatting
run: black --check .
72 changes: 72 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Pylint

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
linting:
runs-on: ubuntu-latest
services:
docker:
image: qgis/qgis:latest
options: --user root
ports:
- 99:99

steps:
- name: Checkout qgis-plugin
uses: actions/checkout@v4

- name: Run QGIS Docker container
run: |
docker run -d --name qgis-testing-environment \
-v ${GITHUB_WORKSPACE}:/tests_directory \
-e DISPLAY=:99 qgis/qgis:latest tail -f /dev/null
- name: Wait for Docker to be ready
run: |
until docker exec qgis-testing-environment sh -c "ls /"; do sleep 1; done
- name: Install plugin manually via Copy
run: |
docker exec qgis-testing-environment sh -c '
PLUGIN_SRC_PATH=/tests_directory/seat
PLUGIN_DEST_DIR=/usr/share/qgis/python/plugins/seat
mkdir -p $PLUGIN_DEST_DIR
cp -r $PLUGIN_SRC_PATH/* $PLUGIN_DEST_DIR/
'
- name: Install Dependencies
run: |
docker exec qgis-testing-environment sh -c "apt-get update && apt-get install -y python3-pandas python3-netcdf4"
- name: Create a Virtual Environment with system site packages
run: |
docker exec qgis-testing-environment sh -c "/usr/bin/python3.12 -m venv --system-site-packages /tests_directory/venv"
- name: Add Plugin to PYTHONPATH in Virtual Environment
run: |
docker exec qgis-testing-environment sh -c "echo '/usr/share/qgis/python/plugins' > /tests_directory/venv/lib/python3.12/site-packages/seat.pth"
- name: Install Pylint in Virtual Environment
run: |
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pip install pylint"
- name: Run Pylint
run: |
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/modules/velocity_module.py"
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/modules/shear_stress_module.py"
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/modules/power_module.py"
docker exec qgis-testing-environment sh -c "/tests_directory/venv/bin/pylint /tests_directory/seat/modules/stressor_utils.py"
- name: Clean up Docker container
if: always()
run: |
docker stop qgis-testing-environment
docker rm qgis-testing-environment
7 changes: 1 addition & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
push:
branches:
- main
- workflow

jobs:
test-seat-package:
Expand All @@ -33,7 +32,7 @@ jobs:
run: |
until docker exec qgis-testing-environment sh -c "ls /"; do sleep 1; done
- name: Install plugin by manually via Copy
- name: Install plugin manually via Copy
run: |
docker exec qgis-testing-environment sh -c '
PLUGIN_SRC_PATH=/tests_directory/seat
Expand All @@ -47,10 +46,6 @@ jobs:
docker exec qgis-testing-environment sh -c "python3 /tests_directory/tests/install_dependencies.py"
docker exec qgis-testing-environment sh -c "apt-get update && apt-get install -y python3-pandas python3-netcdf4 python3-pytest"
- name: List installed packages
run: |
docker exec qgis-testing-environment sh -c "pip list"
- name: Run Pytest
run: |
docker exec qgis-testing-environment pytest /tests_directory/tests
Expand Down
24 changes: 12 additions & 12 deletions docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

# -- Project information -----------------------------------------------------

project = 'SEAT'
copyright = '2023 Sandia National Laboratories'
author = 'Tim Nelson, Caleb Grant, Eben Pendleton, Sterling Olson'
project = "SEAT"
copyright = "2023 Sandia National Laboratories"
author = "Tim Nelson, Caleb Grant, Eben Pendleton, Sterling Olson"

# The full version, including alpha/beta/rc tags
release = '[1.0.0-beta1]'
release = "[1.0.0-beta1]"


# -- General configuration ---------------------------------------------------
Expand All @@ -33,13 +33,13 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.intersphinx',
'sphinx_autodoc_typehints',
'sphinx_rtd_theme',
'sphinx_rtd_dark_mode',
'sphinx_copybutton',
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx_autodoc_typehints",
"sphinx_rtd_theme",
"sphinx_rtd_dark_mode",
"sphinx_copybutton",
]

# Add any paths that contain templates here, relative to this directory.
Expand All @@ -48,7 +48,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# Napoleon settings
Expand Down
26 changes: 13 additions & 13 deletions docs/src/media/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,37 @@ def compress_image(image_path, output_path, quality=100):
The quality parameter controls the quality of the compression.
Lowering the quality value will decrease the file size.
"""
image = Image.open(image_path).convert(
'RGB') # Ensure the image is in RGB mode
image = Image.open(image_path).convert("RGB") # Ensure the image is in RGB mode
max_width = 1000
width_percent = (max_width / float(image.size[0]))
width_percent = max_width / float(image.size[0])
height_size = int((float(image.size[1]) * float(width_percent)))
resized_img = image.resize((max_width, height_size), Image.ANTIALIAS)

resized_img.save(output_path, 'WEBP', quality=quality)
resized_img.save(output_path, "WEBP", quality=quality)


def process_single_png(filename):
if not filename.endswith('.png'):
if not filename.endswith(".png"):
print(f"{filename} is not a .png file.")
return

print(f"Processing {filename}...")
file_path = filename
output_path = os.path.splitext(file_path)[0] + '.webp'
output_path = os.path.splitext(file_path)[0] + ".webp"

# Convert PNG to WEBP without compressing, just for the format change
image = Image.open(file_path).convert('RGB')
image.save(output_path, 'WEBP')
image = Image.open(file_path).convert("RGB")
image.save(output_path, "WEBP")

print(f"{filename} converted to {os.path.basename(output_path)}\n")


def process_webp_files():
for filename in os.listdir('.'):
if filename.endswith('.webp'):
for filename in os.listdir("."):
if filename.endswith(".webp"):
print(f"Processing {filename}...")
file_path = os.path.join('.', filename)
output_path = os.path.splitext(file_path)[0] + '.webp'
file_path = os.path.join(".", filename)
output_path = os.path.splitext(file_path)[0] + ".webp"

# Get initial file size in kB
initial_file_size_kb = os.path.getsize(file_path) / 1024
Expand All @@ -55,7 +54,8 @@ def process_webp_files():
# Get final file size in kB
final_file_size_kb = os.path.getsize(output_path) / 1024
print(
f"{os.path.basename(output_path)}: Final Size: {final_file_size_kb:.2f} kB\n")
f"{os.path.basename(output_path)}: Final Size: {final_file_size_kb:.2f} kB\n"
)


def main():
Expand Down
Loading

0 comments on commit eb80e59

Please sign in to comment.