forked from alexellis/actions-batch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from meta-automata-nix/master
Add nix...y things
- Loading branch information
Showing
7 changed files
with
281 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: Sweep Issue -- Build with Python | ||
title: 'Sweep: Build-a-py-binary' | ||
description: For small bugs, features, refactors, and tests to be handled by Sweep, an AI-powered junior developer. | ||
labels: sweep | ||
body: | ||
- type: textarea | ||
id: description | ||
attributes: | ||
label: Details | ||
description: "[url.to/owner/project-repo-name.git] <- should be the only description" | ||
placeholder: | | ||
"Build-a-py-binary: Take a git repo URL that is python based and then | ||
Step 1: Create a new script /examples/build-a-py-binary/[project-name].sh based on the below. | ||
Step 2: Replace the environmental variables in the script based on the issue's description/url | ||
Step 3: (conditional) Retrieve the projects README.md to: | ||
a) add/modify/remove logic in the script | ||
b) scan the code repository and create a README.md that sets up the environment for pyinstaller. | ||
Step 4: Build-a-py-binary! | ||
``` | ||
#!/bin/bash | ||
# Exit immediately if a command exits with a non-zero status, | ||
# and ensure that any command in a pipeline failing causes the pipeline to fail. | ||
# Print each command before executing it. | ||
set -e -x -o pipefail | ||
# Variables | ||
REPO_URL="https://url.to/owner/project-name.git" | ||
REPO_DIR="project-name" | ||
VENV_DIR="$REPO_DIR/venv" | ||
UPLOADS_DIR="$REPO_DIR/uploads" | ||
# Function to display messages | ||
function message() { | ||
echo "==> $1" | ||
} | ||
# Function to create aliases for python3 and pip3 | ||
function create_aliases() { | ||
message "Creating aliases for python3 and pip3..." | ||
alias python=python3 | ||
alias pip=pip3 | ||
} | ||
# Ensure we are using the correct Python version | ||
message "Ensuring correct Python version..." | ||
create_aliases | ||
# Clone the repository | ||
message "Cloning the repository from $REPO_URL..." | ||
git clone $REPO_URL | ||
# Navigate into the repository directory | ||
cd $REPO_DIR | ||
# Set up a virtual environment | ||
message "Setting up a virtual environment..." | ||
python -m venv $VENV_DIR | ||
# Activate the virtual environment | ||
message "Activating the virtual environment..." | ||
source $VENV_DIR/bin/activate | ||
# Upgrade pip | ||
message "Upgrading pip..." | ||
pip install --upgrade pip | ||
# Install the required dependencies | ||
message "Installing the required dependencies..." | ||
pip install -r requirements.txt | ||
# Install PyInstaller | ||
message "Installing PyInstaller..." | ||
pip install pyinstaller | ||
# Build the binary using PyInstaller | ||
# Assuming the main script of the project is named 'main.py' | ||
MAIN_SCRIPT="main.py" | ||
message "Building the binary using PyInstaller..." | ||
pyinstaller --onefile $MAIN_SCRIPT | ||
# The output binary will be in the 'dist' directory | ||
BINARY_PATH="dist/${MAIN_SCRIPT%.py}" | ||
# Calculate the SHA-256 hash of the binary | ||
message "Calculating the SHA-256 hash of the binary..." | ||
SHA256_HASH=$(shasum -a 256 $BINARY_PATH | awk '{print $1}') | ||
# Save the hash to a .txt file | ||
HASH_FILE="${BINARY_PATH}.txt" | ||
echo $SHA256_HASH > $HASH_FILE | ||
# Create uploads directory if it doesn't exist | ||
message "Creating uploads directory..." | ||
mkdir -p $UPLOADS_DIR | ||
# Move the binary and the hash file to the uploads directory | ||
message "Moving the binary and the hash file to the uploads directory..." | ||
mv $BINARY_PATH $UPLOADS_DIR/ | ||
mv $HASH_FILE $UPLOADS_DIR/ | ||
# Deactivate the virtual environment | ||
message "Deactivating the virtual environment..." | ||
deactivate | ||
message "Build process completed successfully. Files are in the 'uploads' directory." | ||
``` | ||
" | ||
- type: input | ||
id: branch | ||
attributes: | ||
label: Branch | ||
description: The branch to work off of (optional) | ||
placeholder: | | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/bash | ||
|
||
# Exit immediately if a command exits with a non-zero status | ||
set -e | ||
# Causes a pipeline to return the exit status of the last command in the pipe that failed | ||
set -o pipefail | ||
|
||
# Define the base directory for GaiaNet installation (default is $HOME/gaianet) | ||
BASE_DIR=${1:-$HOME/gaianet} | ||
|
||
# Function to install the GaiaNet node software stack | ||
install_gaianet_node() { | ||
echo "Installing GaiaNet node software stack..." | ||
# Download and execute the installation script from the official GaiaNet GitHub repository | ||
curl -sSfL 'https://github.com/GaiaNet-AI/gaianet-node/releases/latest/download/install.sh' | bash -s -- --base $BASE_DIR | ||
} | ||
|
||
# Function to initialize the GaiaNet node | ||
initialize_gaianet_node() { | ||
echo "Initializing GaiaNet node..." | ||
# Initialize the node, which downloads necessary model and vector database files | ||
$BASE_DIR/gaianet init | ||
} | ||
|
||
# Function to start the GaiaNet node | ||
start_gaianet_node() { | ||
echo "Starting GaiaNet node..." | ||
# Start the GaiaNet node | ||
$BASE_DIR/gaianet start | ||
} | ||
|
||
# Function to stop the GaiaNet node | ||
stop_gaianet_node() { | ||
echo "Stopping GaiaNet node..." | ||
# Stop the GaiaNet node | ||
$BASE_DIR/gaianet stop | ||
} | ||
|
||
# Function to update the configuration of the GaiaNet node | ||
update_gaianet_config() { | ||
local chat_url=$1 | ||
local chat_ctx_size=$2 | ||
echo "Updating GaiaNet node configuration..." | ||
# Update the chat model URL and context size in the GaiaNet node configuration | ||
$BASE_DIR/gaianet config --chat-url "$chat_url" --chat-ctx-size "$chat_ctx_size" | ||
echo "Reinitializing GaiaNet node after configuration update..." | ||
# Reinitialize the node to apply the updated configuration | ||
$BASE_DIR/gaianet init | ||
} | ||
|
||
# Parse command-line arguments for configuration updates | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
# Handle chat model URL update | ||
--chat-url) chat_url="$2"; shift ;; | ||
# Handle chat context size update | ||
--chat-ctx-size) chat_ctx_size="$2"; shift ;; | ||
# Flag to indicate that configuration needs to be updated | ||
--update-config) update_config=true ;; | ||
# Unknown parameter handler | ||
*) echo "Unknown parameter passed: $1"; exit 1 ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Execute the installation and setup process | ||
install_gaianet_node | ||
initialize_gaianet_node | ||
|
||
# Update the configuration if the update-config flag is set | ||
if [ "$update_config" = true ]; then | ||
# Ensure both chat model URL and context size are provided | ||
if [ -z "$chat_url" ] || [ -z "$chat_ctx_size" ]; then | ||
echo "Error: Both --chat-url and --chat-ctx-size must be provided to update the configuration." | ||
exit 1 | ||
fi | ||
# Update the GaiaNet node configuration | ||
update_gaianet_config "$chat_url" "$chat_ctx_size" | ||
fi | ||
|
||
# Start the GaiaNet node | ||
start_gaianet_node | ||
|
||
# Print completion message and instructions to stop the node | ||
echo "GaiaNet node setup complete." | ||
echo "To stop the node, run the following command:" | ||
echo "$BASE_DIR/gaianet stop" | ||
|
||
# If you want to update the chat URL and context size during setup, you can run the script with the following options: | ||
# ./setup_gaianet.sh --update-config --chat-url "https://huggingface.co/second-state/Llama-2-13B-Chat-GGUF/resolve/main/Llama-2-13b-chat-hf-Q5_K_M.gguf" --chat-ctx-size 5120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -e -x -o pipefail | ||
|
||
# Example by Alex Ellis | ||
|
||
curl -s https://checkip.amazonaws.com > ip.txt | ||
curl -L https://1drv.ms/u/s!AqGdTk4hyeaFiLN7YfczXkKMsylQVg?e=s1vO0s -o noblerom.zip | ||
|
||
mkdir -p uploads | ||
cp ip.txt ./uploads/ | ||
mv noblerom.zip ./uploads/ | ||
sha256sum ./uploads/noblerom.zip > SHA256-noblerom.zip.txt | ||
mv SHA256-noblerom.zip.txt ./uploads/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit on any error, and set pipefail to catch any errors in pipelines | ||
set -eo pipefail | ||
|
||
# Install Nix using the Determinate Nix Installer | ||
echo "Installing Nix..." | ||
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- --daemon | ||
|
||
# Ensure the Nix profile script is sourced | ||
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then | ||
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' | ||
else | ||
echo "Nix profile script not found. Installation may have failed." | ||
exit 1 | ||
fi | ||
|
||
# Clone the divnix/hive repository | ||
echo "Cloning divnix/hive repository..." | ||
git clone https://github.com/divnix/hive.git | ||
cd hive | ||
|
||
# Check for presence of flake.nix configuration file | ||
if [ -f flake.nix ]; then | ||
# Build the environment using Nix flakes | ||
echo "Building the environment..." | ||
nix build .# --no-link | ||
|
||
# Run the built environment | ||
echo "Running the environment..." | ||
nix run .#defaultPackage | ||
else | ||
echo "flake.nix not found in the repository. Please ensure the repository contains a flake.nix file." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
set -e -x -o pipefail | ||
|
||
wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh | ||
bash menu.sh [option] [lisence/url/token] | ||
|
||
mkdir -p uploads | ||
cp *.txt ./uploads/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters