Skip to main content

Import plugins for converting external data sources to Rhylthyme programs

Project description

Rhylthyme Importers

Import plugins for converting external data sources into Rhylthyme programs.

Installation

pip install -e ./rhylthyme-importers

Available Importers

TheMealDB Importer

Import recipes from TheMealDB free recipe API.

# Search for recipes
rhylthyme-import search "chicken curry" -i themealdb

# Import by URL or meal ID
rhylthyme-import import "https://www.themealdb.com/meal/52772" -o curry.json --pretty

# Import a random meal
rhylthyme-import mealdb random -o random_meal.json --pretty

# List available categories
rhylthyme-import mealdb categories

Protocols.io Importer

Import laboratory protocols from protocols.io.

Requires API token: Set the PROTOCOLS_IO_TOKEN environment variable with your protocols.io API token (get one from https://www.protocols.io/developers).

export PROTOCOLS_IO_TOKEN="your_token_here"

# Search for protocols
rhylthyme-import search "western blot" -i protocolsio

# Import a protocol
rhylthyme-import import "https://www.protocols.io/view/western-blot-..." -o protocol.json --pretty

CLI Commands

# List all available importers
rhylthyme-import list

# Import from any supported URL (auto-detects importer)
rhylthyme-import import <url> [-o output.json] [--pretty]

# Search using a specific importer
rhylthyme-import search <query> -i <importer>

Python API

from rhylthyme_importers import TheMealDBImporter, ProtocolsIOImporter, ImporterRegistry

# TheMealDB
mealdb = TheMealDBImporter()
results = mealdb.search("pasta")
result = mealdb.import_from_url("52771")

if result.success:
    program = result.program
    print(f"Imported: {program['name']}")

# Protocols.io
protocolsio = ProtocolsIOImporter(access_token="your_token")
result = protocolsio.import_from_url("https://www.protocols.io/view/...")

# Auto-detect importer from URL
importer = ImporterRegistry.find_for_url("https://www.themealdb.com/meal/52771")
if importer:
    result = importer.import_from_url("https://www.themealdb.com/meal/52771")

Creating Custom Importers

Extend the BaseImporter class to create new importers:

from rhylthyme_importers import BaseImporter, ImportResult, ImporterRegistry

class MyCustomImporter(BaseImporter):
    name = "myimporter"
    description = "Import from my custom source"
    supported_domains = ["example.com"]

    def can_import(self, url_or_query: str) -> bool:
        return "example.com" in url_or_query

    def search(self, query: str) -> list:
        # Return list of {name, url, description}
        return []

    def import_from_url(self, url: str) -> ImportResult:
        # Fetch data and convert to Rhylthyme program
        program = self.create_base_program(
            name="My Program",
            description="Description",
            environment_type="kitchen",
            source_url=url,
            source_type="myimporter"
        )
        # Add tracks, steps, etc.
        return ImportResult(success=True, program=program)

# Register the importer
ImporterRegistry.register(MyCustomImporter())

Publishing to PyPI

To publish this package to PyPI:

# Install build tools
pip install build twine

# Build the package
cd rhylthyme-importers
python -m build

# Upload to TestPyPI first (optional)
python -m twine upload --repository testpypi dist/*

# Upload to PyPI
python -m twine upload dist/*

You'll need PyPI credentials configured in ~/.pypirc or use environment variables:

  • TWINE_USERNAME / TWINE_PASSWORD or
  • TWINE_API_TOKEN (recommended)

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rhylthyme_importers-0.3.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rhylthyme_importers-0.3.0-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file rhylthyme_importers-0.3.0.tar.gz.

File metadata

  • Download URL: rhylthyme_importers-0.3.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for rhylthyme_importers-0.3.0.tar.gz
Algorithm Hash digest
SHA256 492ca724a8ad8e21f7900e2c1b926c110778aa2927b01e6bdf9327f5c5ccaa57
MD5 23cc923514d23bbf6f079e930db2c5e6
BLAKE2b-256 fffd0098a2034d1ef298315f9d9c38d8de9f122c7541dee74756d2d915c0e028

See more details on using hashes here.

File details

Details for the file rhylthyme_importers-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rhylthyme_importers-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cf55fa872bced4e33ea5ccbe74de007859b733cdc5aed567c7f2f83a679d2bc
MD5 0bb779eb1073ce9d63ecbb21e34bce2d
BLAKE2b-256 2a948ee6cdd3abbcc55fda16b2d9d5b395376a7c6abf2a68654496c98777bfd5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page