Skip to content

Commit

Permalink
Merge pull request #29 from KeesGeerligs/kees-dev
Browse files Browse the repository at this point in the history
Added github url to the info.json, changed the validation script
  • Loading branch information
laurensV authored Dec 5, 2024
2 parents 23e9cc5 + 084bcd3 commit 9d37953
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 69 deletions.
64 changes: 52 additions & 12 deletions scripts/validate.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { validateJobDefinition } from '@nosana/sdk';
import * as fs from 'fs';
import * as path from 'path';
import fetch from 'node-fetch';

// Store all IDs to check for uniqueness
const allIds = new Set();

// Required fields that must be present in info.json
const REQUIRED_FIELDS = ['id', 'name', 'description', 'category', 'subcategory'];

// Validate a single template directory
function validateTemplate(folder) {
async function validateTemplate(folder) {
const templatePath = path.join('./templates', folder);

// Check if README.md exists
Expand All @@ -29,16 +33,23 @@ function validateTemplate(folder) {
}

// Check required fields in info.json
const requiredFields = ['id', 'name', 'description', 'category', 'icon'];
for (const field of requiredFields) {
for (const field of REQUIRED_FIELDS) {
if (!info[field]) {
throw new Error(`${folder}: Missing required field '${field}' in info.json`);
}
}

// Validate icon URL length
if (info.icon.length > 256) {
throw new Error(`${folder}: Icon URL exceeds 256 characters`);
// Ensure only one category and one subcategory
if (!Array.isArray(info.category) || info.category.length !== 1) {
throw new Error(`${folder}: 'category' must be an array with exactly one item in info.json`);
}
if (!Array.isArray(info.subcategory) || info.subcategory.length !== 1) {
throw new Error(`${folder}: 'subcategory' must be an array with exactly one item in info.json`);
}

// Skip icon validation if github_url is provided
if (!info.icon && !info.github_url) {
throw new Error(`${folder}: Missing 'icon' in info.json and no 'github_url' provided`);
}

// Check for unique IDs
Expand All @@ -47,9 +58,19 @@ function validateTemplate(folder) {
}
allIds.add(info.id);

// Validate category is an array
if (!Array.isArray(info.category)) {
throw new Error(`${folder}: 'category' must be an array in info.json`);
// Validate github_url if present
if (info.github_url) {
if (!isValidURL(info.github_url)) {
throw new Error(`${folder}: 'github_url' is not a valid URL`);
}
try {
const response = await fetch(info.github_url);
if (!response.ok) {
throw new Error(`${folder}: GitHub URL returned status ${response.status}`);
}
} catch (error) {
console.warn(`Warning: Could not verify GitHub URL for ${folder}: ${error.message}`);
}
}

// Validate job definition
Expand All @@ -64,8 +85,27 @@ function validateTemplate(folder) {
console.log(`✓ ${folder} template is valid!`);
}

// Helper function to validate URL format
function isValidURL(url) {
try {
new URL(url);
return true;
} catch (_) {
return false;
}
}

// Process all template directories
const templateDirs = fs.readdirSync('./templates');
templateDirs.forEach(validateTemplate);
async function validateAllTemplates() {
const templateDirs = fs.readdirSync('./templates');

try {
await Promise.all(templateDirs.map(validateTemplate));
console.log('\n✓ All templates validated successfully!');
} catch (error) {
console.error('\n❌ Validation failed:', error.message);
process.exit(1);
}
}

console.log('\n✓ All templates validated successfully!');
validateAllTemplates();
3 changes: 2 additions & 1 deletion templates/AUTOMATIC1111-stable-diffusion-1.5/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Stable Diffusion is a latent text-to-image diffusion model",
"category": ["Web UI"],
"subcategory": ["Image Generation"],
"icon": "https://user-images.githubusercontent.com/36368048/196056941-aace0837-473a-4aa5-9067-505b17797aa1.png"
"icon": "https://user-images.githubusercontent.com/36368048/196056941-aace0837-473a-4aa5-9067-505b17797aa1.png",
"github_url": "https://github.com/AUTOMATIC1111/stable-diffusion-webui"
}
3 changes: 2 additions & 1 deletion templates/Axolotl/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Axolotl streamlines the fine-tuning of various AI models, supporting multiple configurations and architectures for efficient and flexible model training.",
"category": ["Web UI"],
"subcategory": ["LLM Fine-tuning"],
"icon": "https://raw.githubusercontent.com/nosana-ci/templates/refs/heads/main/templates/Axolotl/axolotl-nobackground.png"
"icon": "https://raw.githubusercontent.com/nosana-ci/templates/refs/heads/main/templates/Axolotl/axolotl-nobackground.png",
"github_url": "https://github.com/OpenAccess-AI-Collective/axolotl"
}
3 changes: 2 additions & 1 deletion templates/ComfyUI/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "comfyui",
"name": "ComfyUI",
"description": "A powerful and modular image generation interface with a node-based workflow editor",
"category": ["Web UI", "Image Generation"],
"category": ["Web UI"],
"subcategory": ["Image Generation"],
"icon": "https://raw.githubusercontent.com/nosana-ci/templates/refs/heads/main/templates/ComfyUI/comfyui.png"
}
3 changes: 2 additions & 1 deletion templates/Forge-stable-diffusion-1.5/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "A fork of AUTOMATIC1111's Stable Diffusion web UI with additional features and optimizations",
"category": ["Web UI"],
"subcategory": ["Image Generation"],
"icon": "https://raw.githubusercontent.com/nosana-ci/templates/refs/heads/main/templates/Forge-stable-diffusion-1.5/forge.png"
"icon": "https://raw.githubusercontent.com/nosana-ci/templates/refs/heads/main/templates/Forge-stable-diffusion-1.5/forge.png",
"github_url": "https://github.com/lllyasviel/stable-diffusion-webui-forge "
}
10 changes: 6 additions & 4 deletions templates/InvokeAI/info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"id": "invoke-ai",
"name": "Invoke AI",
"description": "Invoke is a leading creative engine built to empower professionals and enthusiasts alike. Generate and create stunning visual media using the latest AI-driven technologies.",
"category": ["Web UI", "Image Generation"],
"icon": "https://d4.alternativeto.net/xsSoWnh09YOroqDfDTYx-QcFdoXjOMcxLtDc7FZleA0/rs:fit:280:280:0/g:ce:0:0/exar:1/YWJzOi8vZGlzdC9pY29ucy9pbnZva2VhaV8yMjc0ODEucG5n.png"
"name": "InvokeAI",
"description": "Invoke is a leading creative engine for Stable Diffusion models, empowering professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies.",
"category": ["Web UI"],
"subcategory": ["Image Generation"],
"icon": "https://d4.alternativeto.net/xsSoWnh09YOroqDfDTYx-QcFdoXjOMcxLtDc7FZleA0/rs:fit:280:280:0/g:ce:0:0/exar:1/YWJzOi8vZGlzdC9pY29ucy9pbnZva2VhaV8yMjc0ODEucG5n.png",
"github_url": "https://github.com/invoke-ai/InvokeAI"
}
3 changes: 2 additions & 1 deletion templates/Kohya-SS/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "A user-friendly web interface for training and fine-tuning Stable Diffusion models using Kohya SS scripts.",
"category": ["Web UI"],
"subcategory": ["LLM Fine-tuning"],
"icon": "https://avatars.githubusercontent.com/u/7474674?v=4"
"icon": "https://avatars.githubusercontent.com/u/7474674?v=4",
"github_url": "https://github.com/bmaltais/kohya_ss"
}
3 changes: 2 additions & 1 deletion templates/LMDeploy-API/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "A high-performance inference engine for LLMs with quantization and optimization features",
"category": ["API Only"],
"subcategory": ["LLM"],
"icon": "https://avatars.githubusercontent.com/u/135356492?s=280&v=4"
"icon": "https://avatars.githubusercontent.com/u/135356492?s=280&v=4",
"github_url": "https://github.com/InternLM/LMDeploy"
}
3 changes: 2 additions & 1 deletion templates/Llama-Factory/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "A unified framework for fine-tuning LLMs, supporting various architectures and training methods",
"category": ["Web UI"],
"subcategory": ["LLM Fine-tuning"],
"icon": "https://devocean.sk.com/thumnail/2024/6/10/3922058082f048e98d3a63eaa4ab1053020d501b48a69ab8ba4c2fda8883086a.png"
"icon": "https://devocean.sk.com/thumnail/2024/6/10/3922058082f048e98d3a63eaa4ab1053020d501b48a69ab8ba4c2fda8883086a.png",
"github_url": "https://github.com/hiyouga/LLaMA-Factory"
}
7 changes: 4 additions & 3 deletions templates/Nosana-RAG-bot-webui/info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"id": "nosana-llm-rag-webui",
"name": "Nosana LLM RAG WebUI",
"description": "A powerful LLM RAG WebUI running on the LMDeploy framework with LLama3.1 70B quantized, optimized for high-end GPUs.",
"category": ["Web UI", "Featured"],
"name": "Nosana RAG Bot WebUI",
"description": "A web UI for Nosana's Retrieval-Augmented Generation (RAG) bot.",
"category": ["Web UI"],
"subcategory": ["Featured"],
"icon": "https://nosana.io/img/Nosana_Logomark_color.png"
}
3 changes: 2 additions & 1 deletion templates/Ollama-API/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Run large language models locally with a simple API interface",
"category": ["API Only"],
"subcategory": ["LLM"],
"icon": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTCnTSM4MHExKgIkfUheyQ04byO32OaUXmQVg&s"
"icon": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTCnTSM4MHExKgIkfUheyQ04byO32OaUXmQVg&s",
"github_url": "https://github.com/jmorganca/ollama"
}
3 changes: 2 additions & 1 deletion templates/Onetrainer-jupyter-notebook/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "A comprehensive Jupyter environment for AI model training with Onetrainer framework",
"category": ["Web UI"],
"subcategory": ["Image Generation Fine-tuning"],
"icon": "https://avatars.githubusercontent.com/u/3390934?v=4"
"icon": "https://avatars.githubusercontent.com/u/3390934?v=4",
"github_url": "https://github.com/Nerogar/OneTrainer"
}
3 changes: 2 additions & 1 deletion templates/Oobabooga/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Oobabooga is a versatile text generation web UI supporting multiple backends, offering rich features for generating and managing AI-driven text models.",
"category": ["Web UI"],
"subcategory": ["LLM"],
"icon": "https://raw.githubusercontent.com/nosana-ci/templates/refs/heads/main/templates/Oobabooga/oobabooga.png"
"icon": "https://raw.githubusercontent.com/nosana-ci/templates/refs/heads/main/templates/Oobabooga/oobabooga.png",
"github_url": "https://github.com/oobabooga/text-generation-webui"
}
3 changes: 2 additions & 1 deletion templates/Pytorch-jupyter-notebook/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Jupyter Notebook Service",
"category": ["Web UI"],
"subcategory": ["Featured"],
"icon": "https://seeklogo.com/images/J/jupyter-logo-A91705F539-seeklogo.com.png"
"icon": "https://seeklogo.com/images/J/jupyter-logo-A91705F539-seeklogo.com.png",
"github_url": "https://github.com/pytorch/pytorch"
}
10 changes: 6 additions & 4 deletions templates/Rstudio/info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"id": "rstudio",
"name": "RStudio",
"description": "Run RStudio Server in a Docker container, providing a powerful and consistent R development environment accessible through your browser.",
"category": ["Web UI", "Featured"],
"icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/R_logo.svg/1200px-R_logo.svg.png"
"name": "RStudio Server",
"description": "Run RStudio Server on a remote server accessible through your browser, enabling a consistent and powerful development environment for R.",
"category": ["Web UI"],
"subcategory": ["Featured"],
"icon": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/R_logo.svg/1200px-R_logo.svg.png",
"github_url": "https://github.com/rocker-org/rocker"
}
3 changes: 2 additions & 1 deletion templates/TGI-API/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Hugging Face's Text Generation Inference (TGI) service for optimized text generation",
"category": ["API Only"],
"subcategory": ["LLM"],
"icon": "https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
"icon": "https://huggingface.co/front/assets/huggingface_logo-noborder.svg",
"github_url": "https://github.com/huggingface/text-generation-inference"
}
3 changes: 2 additions & 1 deletion templates/Tensorflow-jupyter-notebook/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Jupyter Notebook Service",
"category": ["Web UI"],
"subcategory": ["Featured"],
"icon": "https://seeklogo.com/images/J/jupyter-logo-A91705F539-seeklogo.com.png"
"icon": "https://seeklogo.com/images/J/jupyter-logo-A91705F539-seeklogo.com.png",
"github_url": "https://github.com/tensorflow/tensorflow"
}
3 changes: 2 additions & 1 deletion templates/Text-To-Speech-UI/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "A web interface for generating speech from text using various TTS models",
"category": ["Web UI"],
"subcategory": ["Featured"],
"icon": "https://cdn-icons-png.flaticon.com/512/8984/8984813.png"
"icon": "https://cdn-icons-png.flaticon.com/512/8984/8984813.png",
"github_url": "https://github.com/coqui-ai/TTS"
}
3 changes: 2 additions & 1 deletion templates/VLLM-API/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "High-throughput and memory-efficient inference engine for LLMs",
"category": ["API Only"],
"subcategory": ["LLM"],
"icon": "https://avatars.githubusercontent.com/u/136984999?v=4"
"icon": "https://avatars.githubusercontent.com/u/136984999?v=4",
"github_url": "https://github.com/vllm-project/vllm"
}
3 changes: 2 additions & 1 deletion templates/VScode-server/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Run Visual Studio Code on a remote server accessible through your browser, enabling a consistent and powerful development environment.",
"category": ["Web UI"],
"subcategory": ["Featured"],
"icon": "https://avatars.githubusercontent.com/u/12324908?s=280&v=4"
"icon": "https://avatars.githubusercontent.com/u/12324908?s=280&v=4",
"github_url": "https://github.com/coder/code-server"
}
3 changes: 2 additions & 1 deletion templates/Whisper-ASR-API/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "A robust speech recognition service powered by OpenAI's Whisper model, supporting multilingual transcription, translation, and language identification.",
"category": ["API Only"],
"subcategory": ["Featured"],
"icon": "https://www.datocms-assets.com/96965/1685731715-open-ai-stars-2x.png"
"icon": "https://www.datocms-assets.com/96965/1685731715-open-ai-stars-2x.png",
"github_url": "https://github.com/openai/whisper"
}
3 changes: 0 additions & 3 deletions templates/hello-world/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions templates/hello-world/info.json

This file was deleted.

18 changes: 0 additions & 18 deletions templates/hello-world/job-definition.json

This file was deleted.

3 changes: 2 additions & 1 deletion templates/open-webui-ollama/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"description": "Open WebUI supports various LLM models",
"category": ["Web UI"],
"subcategory": ["LLM"],
"icon": "https://openwebui.com/user.png"
"icon": "https://openwebui.com/user.png",
"github_url": "https://github.com/open-webui/open-webui"
}

0 comments on commit 9d37953

Please sign in to comment.