Source code for magpie.data.testdata

import importlib.resources

from magpie.datamodel import Folder, Twig, Url
from magpie.tools import dataimport

bm_resources_anchor = 'data'
brave_export_path = '2025-05-06_chrome_bookmarks.html'
firefox_export_path = '2025-06-10_firefox_bookmarks.html'
bm_path = 'bookmarks.json'
bm_fetch_path = 'bookmarks_fetch.json'
bm_fetch_clean_path = 'bookmarks_fetch_clean.json'
bm_summary_path = 'bookmarks_summary.json'


# FIXME this really is a path for the local machine only
# Qwen3-0.6B-Q4_K_M.gguf
llm_model_path = '/home/amaury/sata/models/Qwen2.5-14B-Instruct-IQ4_XS.gguf'
embed_model_name = 'all-MiniLM-L6-v2'


[docs] def data_file_path(rel_filename): """Return a full path to the given resource filename.""" return importlib.resources.files(f'magpie.{bm_resources_anchor}').joinpath(rel_filename)
[docs] def simple_folder() -> Folder: """Return a simple Folder with a couple of twigs and nested folders.""" return Folder(name='root', items=[ Folder(name='Python', items=[ Folder(name='Project structure', items=[ Twig(title='UV: An extremely fast Python package and project manager', url=Url('https://docs.astral.sh/uv/')), Twig(title=('A modern cookiecutter template for Python projects ' 'that use uv for dependency management'), url=Url('https://github.com/fpgmaas/cookiecutter-uv')), ]), Folder(name='Best practices', items=[ Twig(title='Summary of major Python changes between versions', url=Url('https://www.nicholashairs.com/posts/major-changes-between-python-versions/'), related=[Url('https://www.reddit.com/r/Python/comments/1ah05vt/summary_of_major_python_changes_between_versions/')]), ]), ]), Folder(name='Rust', items=[ Folder(name='Error handling', items=[ Twig(title='Designing error types in Rust', url=Url('https://mmapped.blog/posts/12-rust-error-handling.html'), related=[Url('https://www.reddit.com/r/rust/comments/yvdz6l/blog_post_designing_error_types_in_rust/')]), ]), Twig(title='Develop/deploy complete workflow', url=Url('https://fasterthanli.me/articles/my-ideal-rust-workflow'), related=[Url('https://news.ycombinator.com/item?id=29010327')]), ]), ])
[docs] def chrome_bookmarks() -> Folder: bookmarks = dataimport.process_bookmarks_file(data_file_path(brave_export_path), origin='chrome', root_path=['roots', 'bookmark_bar']) return bookmarks
[docs] def firefox_bookmarks() -> Folder: bookmarks = dataimport.process_bookmarks_file(data_file_path(firefox_export_path), origin='firefox', root_path=['roots', 'other']) return bookmarks