Skip to content

Commit bb843e3

Browse files
committed
Add metadata and metadata checker
1 parent 5be2a78 commit bb843e3

File tree

11 files changed

+102
-17
lines changed

11 files changed

+102
-17
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ repos:
1616
rev: 5.0.4
1717
hooks:
1818
- id: flake8
19-
exclude: singlestoredb/clients/pymysqlsv/
2019
additional_dependencies: [flake8-typing-imports==1.12.0]
2120
- repo: https://github.com/pre-commit/mirrors-autopep8
2221
rev: v1.6.0
@@ -49,3 +48,9 @@ repos:
4948
language: system
5049
files: \.ipynb$
5150
exclude: notebooks/notebook-style-guide/notebook.ipynb
51+
- id: toml-check
52+
name: toml-check
53+
entry: resources/toml-check.py
54+
language: system
55+
files: \.toml$
56+
exclude: ^meta.toml

notebooks/atlas-and-kai/meta.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[meta]
22
title="Mongo Atlas & SingleStore Kai"
3-
description=""
3+
description="""\
4+
Run your MongoDB queries on SingleStore Kai with no code change. \
5+
"""
6+
icon="database"
47
tags=["mongodb", "kai"]
8+
destinations=["spaces"]
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
[meta]
22
title="Getting Started with Notebooks"
3-
description=""
4-
tags=[]
3+
description="""\
4+
SingleStore Notebooks with an AI Copilot (SQrL) for data prototyping, \
5+
visualization and analysis. \
6+
"""
7+
icon="notes"
8+
tags=["beginner", "sqrl"]
9+
destinations=["spaces"]
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[meta]
22
title="Image Matching with SQL"
3-
description=""
4-
tags=[]
3+
description="""\
4+
Facial recognition using dot_product function on vectors stored in SingleStoreDB. \
5+
"""
6+
icon="face-viewfinder"
7+
tags=["vectordb", "genai", "facenet"]
8+
destinations=["spaces"]
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[meta]
22
title="Launch Open-Source Apps with LangChain"
3-
description=""
4-
tags=[]
3+
description="""\
4+
LangChain connector to use SingleStoreDB as your vector database for your apps. \
5+
"""
6+
icon=""
7+
tags=["vectordb", "genai", "langchain"]
8+
destinations=[]
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[meta]
22
title="Movie Recommendation"
3-
description=""
4-
tags=[]
3+
description="""\
4+
Movie recommendation engine using vectors stored in SingleStore to find your next watch. \
5+
"""
6+
icon="camera-movie"
7+
tags=["vectordb", "genai", "openai"]
8+
destinations=["spaces"]

notebooks/notebook-basics/meta.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[meta]
22
title="SingleStoreDB Notebook Basics"
3-
description=""
4-
tags=[]
3+
description="""\
4+
Foundational guide to notebooks with essential tips and tricks. \
5+
"""
6+
icon="notes"
7+
tags=["beginner"]
8+
destinations=["spaces"]
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[meta]
22
title="Notebook Style Guide"
3-
description="Sample notebook template for writing Spaces notebooks"
3+
description="Become a pro at formatting and organizing your notebooks."
4+
icon="link"
45
tags=[]
6+
destinations=[]
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[meta]
22
title="Semantic Search with OpenAI Embedding Creation"
3-
description=""
4-
tags=["openai"]
3+
description="""\
4+
Generate embeddings and run semantic search in your database in SQL. \
5+
"""
6+
icon="chart-network"
7+
tags=["openai", "vectordb", "genai"]
8+
destinations=["spaces"]
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
[meta]
22
title="Semantic Search with OpenAI QA"
3-
description=""
4-
tags=["openai"]
3+
description="""\
4+
Provide context to chatGPT using data stored in SingleStoreDB. \
5+
"""
6+
icon="crystal-ball"
7+
tags=["openai", "vectordb", "openai"]
8+
destinations=["spaces"]

resources/toml-check.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
import re
3+
import sys
4+
import tomllib
5+
6+
7+
def error(msg):
8+
print('ERROR:', msg, file=sys.stderr)
9+
sys.exit(1)
10+
11+
12+
for f in sys.argv[1:]:
13+
14+
with open(f, 'r') as infile:
15+
info = tomllib.loads(infile.read())
16+
17+
if 'meta' not in info:
18+
error(f'No `meta` section in `{f}`')
19+
20+
# The meta section requires, title, description, and icon
21+
meta = info['meta']
22+
23+
if 'title' not in meta:
24+
error(f'No `title` in `meta` section of {f}')
25+
26+
if 'description' not in meta:
27+
error(f'No `description` in `meta` section of {f}')
28+
29+
if 'icon' not in meta:
30+
error(f'No `icon` in `meta` section of {f}')
31+
32+
# Tags must be all lower-case, ascii letters
33+
tags = meta.get('tags', [])
34+
35+
if [x.lower() for x in tags] != tags:
36+
error(f'Tags must be in all lower-case ({tags}) in {f}')
37+
38+
if [re.sub(r'[^a-z]', r'', x) for x in tags] != tags:
39+
error(f'Tags can only contain letters ({tags}) in {f}')
40+
41+
# Currently only "spaces" is allowed in destinations
42+
destinations = meta.get('destinations', [])
43+
44+
if destinations and [x for x in destinations if x != 'spaces']:
45+
error(f'Only "spaces" is allowed in `destinations` in {f}')

0 commit comments

Comments
 (0)