Skip to content

Commit

Permalink
Merge pull request #32 from KeesGeerligs/kees-dev-templates
Browse files Browse the repository at this point in the history
256 length check
  • Loading branch information
laurensV authored Dec 6, 2024
2 parents 8b848e1 + c5eb249 commit e9a569b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
15 changes: 15 additions & 0 deletions scripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ const allIds = new Set();
// Required fields that must be present in info.json
const REQUIRED_FIELDS = ['id', 'name', 'description', 'category', 'subcategory'];

const MAX_FIELD_LENGTHS = {
id: 256,
name: 256,
icon: 256
};

// Validate a single template directory
async function validateTemplate(folder) {
const templatePath = path.join('./templates', folder);
Expand Down Expand Up @@ -82,6 +88,15 @@ async function validateTemplate(folder) {
throw new Error(`${folder}: ${error.path} - expected ${error.expected}, but found ${JSON.stringify(error.value)}`);
}

// Check field lengths
for (const [field, maxLength] of Object.entries(MAX_FIELD_LENGTHS)) {
if (info[field] && info[field].length > maxLength) {
throw new Error(
`${folder}: Field '${field}' exceeds maximum length of ${maxLength} characters in info.json`
);
}
}

console.log(`✓ ${folder} template is valid!`);
}

Expand Down
6 changes: 3 additions & 3 deletions templates/Pytorch-jupyter-notebook/info.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "jupyter-notebook-pytorch",
"name": "Jupyter Notebook with pytorch:2.4.0-cuda12.1-cudnn9-runtime",
"id": "pytorch-jupyter-notebook",
"name": "Pytorch:2.4.0-cuda12.1-cudnn9-runtime Jupyter Notebook",
"description": "Jupyter Notebook Service",
"category": ["Web UI"],
"subcategory": ["Other"],
"icon": "https://www.google.com/imgres?q=pytorch%20logo&imgurl=https%3A%2F%2Fwww.clipartmax.com%2Fpng%2Fmiddle%2F476-4769276_pytorch-logo-png.png&imgrefurl=https%3A%2F%2Fwww.clipartmax.com%2Fmiddle%2Fm2H7m2i8H7A0A0G6_pytorch-logo-png%2F&docid=AWv1vZ_1ftQU9M&tbnid=6aaNrsdmoeEDjM&vet=12ahUKEwjT3cHsupCKAxVZgP0HHbcpHagQM3oECH0QAA..i&w=840&h=848&hcb=2&ved=2ahUKEwjT3cHsupCKAxVZgP0HHbcpHagQM3oECH0QAA",
"icon": "https://static-00.iconduck.com/assets.00/pytorch-icon-1694x2048-jgwjy3ne.png",
"github_url": "https://github.com/pytorch/pytorch"
}
4 changes: 2 additions & 2 deletions templates/Tensorflow-jupyter-notebook/info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "jupyter-notebook-tensorflow",
"name": "Jupyter Notebook with Tensorflow",
"id": "tensorflow-jupyter-notebook",
"name": "Tensorflow Jupyter Notebook",
"description": "Jupyter Notebook Service",
"category": ["Web UI"],
"subcategory": ["Other"],
Expand Down

0 comments on commit e9a569b

Please sign in to comment.