Learn how to approach your first ticket in the Labs project and understand the development workflow.
View your first ticket details and requirements on GitHub:
First Ticket DocumentationLearn how to implement database operations and data generation for your first Data Science Labs ticket.
# Example Database Interface Implementation from os import getenv from typing import Dict, Optional import pandas as pd from pymongo import MongoClient from dotenv import load_dotenv from certifi import where from monster_lab import generate_monster # Hypothetical monster generation library class MonsterDatabase: """Interface for monster database operations.""" def __init__(self): """Initialize database connection using environment variables.""" load_dotenv() self.client = MongoClient(getenv("DB_URL"), tlsCAFile=where()) self.db = self.client["monster_database"] self.collection = self.db["monsters"] def seed(self, num_monsters: int) -> bool: """Seed the database with specified number of monsters.""" try: monsters = [generate_monster() for _ in range(num_monsters)] self.collection.insert_many(monsters) return True except Exception as e: print(f"Error seeding database: {e}") return False def reset(self) -> bool: """Delete all monsters from the collection.""" try: self.collection.delete_many({}) return True except Exception as e: print(f"Error resetting database: {e}") return False def count(self) -> int: """Return the number of monsters in the collection.""" return self.collection.count_documents({}) def dataframe(self) -> Optional[pd.DataFrame]: """Return a DataFrame of all monsters in the collection.""" data = list(self.collection.find({}, {'_id': 0})) return pd.DataFrame(data) if data else None def html_table(self) -> Optional[str]: """Return HTML table representation of monster data.""" df = self.dataframe() return df.to_html() if df is not None else None
Understand how to interact with APIs, handle data fetching, and manage state in your React application.
// Example of fetching data from an API using axios import axios from 'axios'; import { useState, useEffect } from 'react'; function DataFetching() { const [data, setData] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchData = async () => { try { const response = await axios.get('https://api.example.com/data'); setData(response.data); setLoading(false); } catch (error) { setError(error.message); setLoading(false); } }; fetchData(); }, []); if (loading) return <div>Loading...</div>; if (error) return <div>Error: {error}</div>; return ( <div> {data.map(item => ( <div key={item.id}>{item.name}</div> ))} </div> ); }
Learn how to create well-designed, reusable components for your React application.
// Example of a reusable button component import React from 'react'; import PropTypes from 'prop-types'; import './Button.css'; const Button = ({ variant = 'primary', size = 'medium', disabled = false, children, onClick, ...props }) => { const classNames = `btn btn-${variant} btn-${size} ${disabled ? 'btn-disabled' : ''}`; return ( <button className={classNames} disabled={disabled} onClick={onClick} {...props} > {children} </button> ); }; Button.propTypes = { variant: PropTypes.oneOf(['primary', 'secondary', 'danger', 'success']), size: PropTypes.oneOf(['small', 'medium', 'large']), disabled: PropTypes.bool, children: PropTypes.node.isRequired, onClick: PropTypes.func }; export default Button;