Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
habedi committed Jan 8, 2025
1 parent 45ab537 commit 3470d70
Show file tree
Hide file tree
Showing 18 changed files with 222 additions and 272 deletions.
17 changes: 0 additions & 17 deletions .coveragerc

This file was deleted.

15 changes: 0 additions & 15 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,12 @@ indent_size = 4 # Default indentation size
insert_final_newline = true # Make sure files end with a newline
trim_trailing_whitespace = true # Remove trailing whitespace

# Python specific settings, complying with PEP 8 style guide, except for the line length
[*.py]
max_line_length = 100

# Markdown files
[*.md]
trim_trailing_whitespace = false # Don't remove trailing whitespace in Markdown files
max_line_length = 120
# Bash scripts
[*.sh]
indent_size = 4
# SQL files
[*.sql]
indent_size = 4
# YAML files
[*.yml]
indent_size = 4
# JSON files
[*.json]
indent_size = 4
70 changes: 0 additions & 70 deletions .gitattributes

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build

on:
workflow_dispatch: # Only enable manual runs for now

jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4

# Step 2: Prepare Build Environment
- name: Prepare Environment
run: |
bash build.sh --just-prepare
# Step 3: Set up Snapcraft
- name: Set up Snapcraft
uses: snapcore/action-build@v1
id: build
with:
snapcraft-channel: stable

# Step 4: Validate the built Snap
- name: Validate Snap
uses: diddlesnaps/snapcraft-review-action@v1
with:
snap: ${{ steps.build.outputs.snap }}
isClassic: 'false'
34 changes: 34 additions & 0 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Publish

on:
workflow_dispatch: # Only enable manual runs for now

jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4

# Step 2: Prepare Build Environment
- name: Prepare Environment
run: |
bash build.sh --just-prepare
# Step 3: Set up Snapcraft
- name: Set up Snapcraft
uses: snapcore/action-build@v1
id: build
with:
snapcraft-channel: stable
continue-on-error: false

# Step 4: Publish Snap
- name: Publish Snap
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
snap: ${{ steps.build.outputs.snap }}
release: stable
44 changes: 0 additions & 44 deletions .github/workflows/tests.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ poetry.lock

# Miscellaneous files and directories to ignore
# Add any additional file patterns a directory names that should be ignored down here
stage/
prime/
*.snap
test.csv
snap/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Hassan Abedi
Copyright (c) 2025 Hassan Abedi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
66 changes: 36 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,51 @@
# A Template Repository for Data Science Projects
# DuckDB Snap Package

[![Tests](https://github.com/habedi/template-python-project/actions/workflows/tests.yml/badge.svg)](https://github.com/habedi/template-python-project/actions/workflows/tests.yml)
[![Python Version](https://img.shields.io/badge/Python-%3E=3.10-blue)](https://github.com/habedi/template-python-project)
[![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/habedi/template-python-project/blob/main/LICENSE)
[![Build](https://github.com/habedi/duckdb-snap/actions/workflows/build.yml/badge.svg)](https://github.com/habedi/duckdb-snap/actions/workflows/build.yml)
[![Snapcraft.io](https://snapcraft.io/duckdb/badge.svg)](https://snapcraft.io/duckdb)
[![License](https://img.shields.io/badge/License-MIT-yellow)](https://github.com/habedi/duckdb-snap/blob/main/LICENSE)

This is a simple and minimalistic template repository for starting new data science and machine learning projects in
Python.
This repository contains the source code for building a Snap package (called a `snap`) from the latest stable
release of [DuckDB](https://github.com/duckdb/duckdb/releases/).

I created this template to help me speed up the setup process for my projects.
And to have a consistent structure across all my personal and professional projects.
I'm sharing it here in the hope that others find it useful.
So, feel free to use it as a starting point for your projects.
I made this package to make it easier to install DuckDB on different GNU/Linux distributions like Debian, Ubuntu,
Fedora, etc. and to keep it up-to-date.
Currently, the package is built for the `amd64` architecture only.

---
Note that this is an unofficial Snap package for DuckDB.

## Notable Features
Please use the [Issues page](https://github.com/habedi/duckdb-snap/issues) to report bugs.

- A predefined file and folder layout that should be suitable for most data science workflows.
- Easy dependency and environment management with [Poetry](https://python-poetry.org/).
- Extra configuration files for various tasks like linting, formatting, and testing.
## Installation

---
```bash
# Install the Snap package from the Snap Store
sudo snap install duckdb
```

## Folder Structure
## Development

The repository is organized as follows:
```bash
# Install Snap, Snapcraft, and Multipass
sudo apt install snapd
sudo snap install snapcraft --classic
sudo snap install multipass --classic
```

```plaintext
template-python-project/
├── bin/ # Scripts and command-line tools
├── data/ # Raw and processed datasets
├── notebooks/ # Jupyter notebooks for exploration, analysis, and prototyping
├── src/ # Source code for the project
├── models/ # ML models and related files
├── tests/ # Unit tests and test files
├── pyproject.toml # Project metadata and dependencies
├── LICENSE # License information
└── README.md # Project documentation
```bash
# Clone this repository
git clone --depth=1 https://github.com/habedi/duckdb-snap.git
```

---
```bash
# Build the package
cd duckdb-snap/
bash build.sh
```

```bash
# Install the package manually (optional)
sudo snap install --dangerous duckdb_VER_amd64.snap # Replace VER with the actual version
```

## License

Expand Down
Empty file removed bin/.gitkeep
Empty file.
57 changes: 57 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

# Directory containing versioned Snapcraft files
SNAPCRAFT_FILES_DIR="snapcraft_files"

# Function to compare semantic versions and find the highest
get_highest_version() {
# Find directories matching the pattern "vX.X.X" and extract valid semantic versions
versions=$(ls -d ${SNAPCRAFT_FILES_DIR}/v* 2>/dev/null | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -V)

# If no valid versions are found, exit with an error
if [[ -z "$versions" ]]; then
echo "Error: No valid semantic version directories found in '$SNAPCRAFT_FILES_DIR'."
exit 1
fi

# Return the highest version
echo "$versions" | tail -n 1
}

# Get the highest version
FOLDER_NAME=$(get_highest_version)
if [[ $? -ne 0 ]]; then
exit 1
fi

# Remove the 'v' prefix to get the version number
VERSION="${FOLDER_NAME#v}"
echo "Detected highest version: $VERSION"

# Handle the `--just-prepare` argument
if [[ "$1" == "--just-prepare" ]]; then
echo "Preparing Snapcraft files for version $VERSION..."
mkdir -p snap
cp -f "$SNAPCRAFT_FILES_DIR/$FOLDER_NAME/snapcraft.yaml" snap/snapcraft.yaml
echo "Snapcraft.yaml prepared in the 'snap' directory."
exit 0
fi

# Build the Snap package for the highest version
echo "Building Snap package for version $VERSION..."
if pushd "$SNAPCRAFT_FILES_DIR/v$VERSION" > /dev/null; then
SNAPCRAFT_BUILD_ENVIRONMENT=multipass snapcraft # Build the package using Multipass
if [[ $? -eq 0 ]]; then
echo "Build successful. Moving Snap package to the root directory..."
mv -f *.snap ../../ # Move the built snap file to the root directory
else
echo "Error: Snap build failed."
exit 1
fi
popd > /dev/null || exit
else
echo "Error: Failed to access directory '$SNAPCRAFT_FILES_DIR/v$VERSION'."
exit 1
fi

echo "Snap package build process completed."
Empty file removed data/.gitkeep
Empty file.
Empty file removed models/.gitkeep
Empty file.
Empty file removed notebooks/.gitkeep
Empty file.
Loading

0 comments on commit 3470d70

Please sign in to comment.