### GET / Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt The root endpoint serving as the main entry point for the web application. ```APIDOC ## GET / ### Description The root endpoint returns a simple text response. This serves as the main entry point for the web application. ### Method GET ### Endpoint / ### Response #### Success Response (200) - **response** (string) - A simple text greeting. ``` -------------------------------- ### Install Dependencies and Run Migrations Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt Commands to set up the development environment. Use 'uv sync' for recommended dependency management. Apply migrations and create a superuser before running the development server. ```bash # Install dependencies pip install django django-ninja # Or using uv (recommended) uv sync # Apply database migrations python manage.py makemigrations python manage.py migrate # Create a superuser for admin access python manage.py createsuperuser # Run the development server python manage.py runserver # Access the application # Web UI: http://localhost:8000/ # API: http://localhost:8000/api/ # Admin: http://localhost:8000/admin/ ``` -------------------------------- ### GET /api/add Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt A utility endpoint that performs integer addition using two query parameters. ```APIDOC ## GET /api/add ### Description A utility endpoint that performs integer addition. Accepts two query parameters and returns their sum. ### Method GET ### Endpoint /api/add ### Parameters #### Query Parameters - **a** (integer) - Required - The first number to add. - **b** (integer) - Required - The second number to add. ### Response #### Success Response (200) - **result** (integer) - The sum of the two provided numbers. #### Response Example { "result": 8 } ``` -------------------------------- ### GET /api/hello Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt A simple health check endpoint that returns a greeting message to verify API accessibility. ```APIDOC ## GET /api/hello ### Description A simple health check endpoint that returns a greeting message. Use this to verify the API is running and accessible. ### Method GET ### Endpoint /api/hello ### Response #### Success Response (200) - **message** (string) - A greeting message from the server. #### Response Example { "message": "Hello World from Django Ninja!" } ``` -------------------------------- ### Check API Health with Curl Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt Use this curl command to verify if the API is running and accessible. It sends a GET request to the hello endpoint. ```bash # Check if the API is running curl -X GET "http://localhost:8000/api/hello" ``` -------------------------------- ### Perform Integer Addition with Python Requests Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt This Python script uses the requests library to call the addition endpoint with specified parameters and prints the JSON response. It's a client-side example for testing API functionality. ```python import requests response = requests.get("http://localhost:8000/api/add", params={"a": 10, "b": 20}) result = response.json() print(result) # {"result": 30} ``` -------------------------------- ### Configure Django Admin for Models Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt Register custom models with the Django admin interface to enable web-based management. This setup allows for easy viewing, filtering, and searching of model data. ```python # core/admin.py from django.contrib import admin from lbm_training_framework.models import User, Model, RobotType, Dataset, Run, Evaluation @admin.register(Model) class ModelAdmin(admin.ModelAdmin): list_display = ['name', 'version', 'created_by', 'created_at'] list_filter = ['created_at', 'created_by'] search_fields = ['name', 'description'] @admin.register(RobotType) class RobotTypeAdmin(admin.ModelAdmin): list_display = ['name', 'created_at'] search_fields = ['name', 'description'] @admin.register(Dataset) class DatasetAdmin(admin.ModelAdmin): list_display = ['name', 'version', 'size_mb', 'num_samples', 'created_by'] list_filter = ['created_at', 'created_by'] @admin.register(Run) class RunAdmin(admin.ModelAdmin): list_display = ['id', 'model', 'robot_type', 'status', 'started_at', 'completed_at'] list_filter = ['status', 'robot_type', 'created_at'] @admin.register(Evaluation) class EvaluationAdmin(admin.ModelAdmin): list_display = ['run', 'metric_name', 'metric_value', 'evaluated_by'] list_filter = ['metric_name', 'evaluated_by'] ``` -------------------------------- ### Register and Query Dataset Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt This Python code illustrates how to register a new dataset with versioning, file path, metadata, and ownership information, and then query for datasets exceeding a certain size. ```python from lbm_training_framework.models import Dataset, User user = User.objects.get(username='researcher') # Register a dataset dataset = Dataset.objects.create( name='manipulation-demos', version='2.0', description='Real-world robot manipulation demonstrations', file_path='/datasets/manipulation-demos-v2/', size_mb=15360.5, num_samples=50000, created_by=user ) # Query datasets by size large_datasets = Dataset.objects.filter(size_mb__gte=10000) for ds in large_datasets: print(f"{ds.name} v{ds.version}: {ds.num_samples} samples, {ds.size_mb} MB") ``` -------------------------------- ### Create and Manage Training Runs Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt Use this code to create, update, and query training runs. It demonstrates setting status, logging hyperparameters, metrics, and timestamps. Ensure all required model, robot, and dataset objects are fetched first. ```python from lbm_training_framework.models import Run, Model, RobotType, Dataset, User from django.utils import timezone user = User.objects.get(username='researcher') model = Model.objects.get(name='pi0-base', version='1.0.0') robot = RobotType.objects.get(name='Franka Emika Panda') dataset = Dataset.objects.get(name='manipulation-demos', version='2.0') # Create a new training run run = Run.objects.create( model=model, robot_type=robot, dataset=dataset, status='pending', hyperparameters={ 'learning_rate': 1e-4, 'batch_size': 32, 'epochs': 100, 'optimizer': 'adamw', 'weight_decay': 0.01 }, created_by=user ) # Start the run run.status = 'running' run.started_at = timezone.now() run.save() # Complete the run with metrics run.status = 'completed' run.completed_at = timezone.now() run.metrics = { 'train_loss': 0.0234, 'val_loss': 0.0312, 'success_rate': 0.87, 'avg_episode_length': 45.2 } run.logs = "Training completed successfully. Best checkpoint saved at epoch 87." run.save() # Query runs by status completed_runs = Run.objects.filter(status='completed').select_related('model', 'robot_type') for r in completed_runs: print(f"Run {r.id}: {r.model} on {r.robot_type} - Success rate: {r.metrics.get('success_rate')}") ``` -------------------------------- ### Create and List RobotType Configurations Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt This Python snippet demonstrates creating a new robot type configuration, including its specifications stored as JSON, and then listing all defined robot types. ```python from lbm_training_framework.models import RobotType # Create a robot type configuration franka = RobotType.objects.create( name='Franka Emika Panda', description='7-DOF collaborative robot arm', specifications={ 'degrees_of_freedom': 7, 'max_payload_kg': 3, 'reach_mm': 855, 'sensors': ['force_torque', 'joint_encoders'], 'gripper': 'parallel_jaw', 'control_frequency_hz': 1000 } ) # List all robot types for robot in RobotType.objects.all(): print(f"{robot.name}: {robot.specifications.get('degrees_of_freedom')} DOF") ``` -------------------------------- ### Record and Query Evaluation Metrics Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt Use this code to record detailed evaluation metrics for a run using bulk creation for efficiency. It also shows how to query evaluations associated with a specific run. Ensure the Run object exists and the user is authenticated. ```python from lbm_training_framework.models import Evaluation, Run, User user = User.objects.get(username='researcher') run = Run.objects.get(id=1) # Record evaluation metrics evaluations = [ Evaluation( run=run, metric_name='success_rate', metric_value=0.87, details={ 'num_trials': 100, 'num_successes': 87, 'environment': 'real_world', 'task': 'pick_and_place' }, evaluated_by=user ), Evaluation( run=run, metric_name='task_completion_time', metric_value=12.5, details={ 'unit': 'seconds', 'std_dev': 2.3, 'min': 8.1, 'max': 18.7 }, evaluated_by=user ), Evaluation( run=run, metric_name='path_efficiency', metric_value=0.92, details={ 'optimal_path_length': 1.2, 'actual_avg_path_length': 1.3, 'collision_rate': 0.02 }, evaluated_by=user ) ] Evaluation.objects.bulk_create(evaluations) # Query evaluations for a run for eval in run.evaluations.all(): print(f"{eval.metric_name}: {eval.metric_value}") print(f" Details: {eval.details}") ``` -------------------------------- ### Register and Query ML Model Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt This Python code shows how to register a new machine learning model with versioning and parameters, and then query for models by name using the Model model. ```python from lbm_training_framework.models import Model, User user = User.objects.get(username='researcher') # Register a new model model = Model.objects.create( name='pi0-base', version='1.0.0', description='Base policy model for robot manipulation tasks', parameters={ 'architecture': 'transformer', 'hidden_size': 768, 'num_layers': 12, 'num_attention_heads': 12, 'checkpoint_path': '/models/pi0-base-v1.0.0.pt' }, created_by=user ) # Query models by name pi0_models = Model.objects.filter(name='pi0-base') for m in pi0_models: print(f"{m.name} v{m.version}: {m.description}") ``` -------------------------------- ### Perform Integer Addition with Curl Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt This curl command demonstrates how to use the addition endpoint by providing two integer query parameters. It tests API connectivity with parameterized requests. ```bash # Perform addition with query parameters curl -X GET "http://localhost:8000/api/add?a=5&b=3" ``` -------------------------------- ### Create and Access User Model Timestamps Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt This Python snippet demonstrates creating a new user using the extended Django User model and accessing its automatically tracked creation and update timestamps. ```python from lbm_training_framework.models import User # Create a new user user = User.objects.create_user( username='researcher', email='researcher@lab.edu', password='secure_password' ) # Access timestamps print(f"User created at: {user.created_at}") print(f"Last updated: {user.updated_at}") ``` -------------------------------- ### Access Home Page with Curl Source: https://context7.com/lucidrains/lbm-training-framework/llms.txt This curl command accesses the root endpoint of the web application, which serves a simple text response. It's useful for basic connectivity checks. ```bash # Access the home page curl -X GET "http://localhost:8000/" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.