Skip to content

Commit

Permalink
Merge pull request #1 from wizeline/feature-template-files
Browse files Browse the repository at this point in the history
Feature template files
  • Loading branch information
fernanda-meza-wizeline authored Jul 22, 2024
2 parents b416832 + f17e311 commit 9591818
Show file tree
Hide file tree
Showing 37 changed files with 520 additions and 8 deletions.
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

# Dependency directories
node_modules/

# dotenv environment variable files
.env

Expand All @@ -21,4 +17,6 @@ node_modules/
*.mov
*.wmv

# Output files from project
# Input and Output files from project
/output_files
/input_files
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ ___
* **@author:** Fabián Portillo González
* **@github user:** fabianpg95
* **@author:** Narda Ballesteros
* **@github user:**
* **@github user:** NardaBallesterosW
* **@author:** Fernanda Meza
* **@github user:**
* **@github user:** fernanda-meza-wizeline
* **@author:** José Manuel Hidalgo
* **@github user:**
* **@github user:** JoseHidalgoW
___
Empty file added __init__.py
Empty file.
12 changes: 12 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
certifi==2024.7.4
charset-normalizer==3.3.2
idna==3.7
numpy==2.0.0
pandas==2.2.2
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.1
requests==2.32.3
six==1.16.0
tzdata==2024.1
urllib3==2.2.2
11 changes: 11 additions & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Activate the virtual environment
python3 -m venv venv
source venv/bin/activate

# Run tests with pytest
pytest src/tests

# Deactivate the virtual environment
deactivate
36 changes: 36 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from setuptools import setup, find_packages

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name="sports-highlight-genai",
version="0.1.0",
author="Fabián Portillo, Narda Ballesteros, Jose Hialgo, Fernanda Meza",
author_email="[email protected], [email protected], [email protected], [email protected]",
description="Develop a GenAI-powered tool that automatically identifies key moments in sports events to generate highlight reels. This project leverages real-time statistical data, video processing, and image analysis to create engaging sports highlights. Optional features include video editing capabilities and social media integration for sharing highlights.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/wizeline/sports-highlight-genai",
packages=find_packages(where="src"),
package_dir={"": "src"},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.7',
install_requires=[
"boto3==1.24.28",
"requests==2.28.1",
"flask==2.1.3",
"python-dotenv==0.19.2",
"gunicorn==20.1.0",
"pytest==7.1.2",
],
entry_points={
'console_scripts': [
'sports-highlight-genai=src.app:main',
],
},
)
83 changes: 83 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# src/app.py

from services.mlb_api import MLBAPI
from handlers.data_management import (
process_player_data, process_free_agent_data, process_schedule_data,
process_team_data, process_team_history_data, process_team_coaches_data,
process_team_personnel_data, process_team_affiliates_data, process_team_roster_data
)
from config import Config

def run_data_processing():
api = MLBAPI(auth_key=Config.MLB_API_KEY)

# Process player data
person_ids = [660271] # Reemplaza con IDs de jugadores reales como una lista de enteros
print("Fetching and processing player data...")
player_data = api.get_players(person_ids)
processed_player_data = process_player_data(player_data)
print("Processed Player Data:")
print(processed_player_data)

# Process free agent data
season_id = 2024 # Reemplaza con un ID de temporada real
print("Fetching and processing free agent data...")
free_agent_data = api.get_free_agents(season_id)
processed_free_agent_data = process_free_agent_data(free_agent_data)
print("Processed Free Agent Data:")
print(processed_free_agent_data)

# Process schedule data
date = '2024-07-02' # Reemplaza con una fecha real
print("Fetching and processing schedule data...")
schedule_data = api.get_schedule(date)
processed_schedule_data = process_schedule_data(schedule_data)
print("Processed Schedule Data:")
print(processed_schedule_data)

# Process team data
team_id = 119 # Reemplaza con un ID de equipo real
print("Fetching and processing team data...")
team_data = api.get_teams(team_id)
processed_team_data = process_team_data(team_data)
print("Processed Team Data:")
print(processed_team_data)

# Process team history data
team_ids = [119] # Reemplaza con IDs de equipos reales como una lista de enteros
print("Fetching and processing team history data...")
team_history_data = api.get_teams_history(team_ids)
processed_team_history_data = process_team_history_data(team_history_data)
print("Processed Team History Data:")
print(processed_team_history_data)

# Process team coaches data
print("Fetching and processing team coaches data...")
team_coaches_data = api.get_teams_coaches(team_ids)
processed_team_coaches_data = process_team_coaches_data(team_coaches_data)
print("Processed Team Coaches Data:")
print(processed_team_coaches_data)

# Process team personnel data
print("Fetching and processing team personnel data...")
team_personnel_data = api.get_teams_personnel(team_ids)
processed_team_personnel_data = process_team_personnel_data(team_personnel_data)
print("Processed Team Personnel Data:")
print(processed_team_personnel_data)

# Process team affiliates data
print("Fetching and processing team affiliates data...")
team_affiliates_data = api.get_teams_affiliates(team_ids)
processed_team_affiliates_data = process_team_affiliates_data(team_affiliates_data)
print("Processed Team Affiliates Data:")
print(processed_team_affiliates_data)

# Process team roster data
print("Fetching and processing team roster data...")
team_roster_data = api.get_teams_roster(team_ids)
processed_team_roster_data = process_team_roster_data(team_roster_data)
print("Processed Team Roster Data:")
print(processed_team_roster_data)

if __name__ == '__main__':
run_data_processing()
33 changes: 33 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# src/config.py

import os
from dotenv import load_dotenv

# Load environment variables from a .env file
load_dotenv()

class Config:
MLB_API_KEY = os.getenv('MLB_API_KEY')

"""
# AWS credentials
AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY')
# Facebook credentials
FACEBOOK_APP_ID = os.getenv('FACEBOOK_APP_ID')
FACEBOOK_APP_SECRET = os.getenv('FACEBOOK_APP_SECRET')
FACEBOOK_ACCESS_TOKEN = os.getenv('FACEBOOK_ACCESS_TOKEN')
# Instagram credentials
INSTAGRAM_ACCESS_TOKEN = os.getenv('INSTAGRAM_ACCESS_TOKEN')
# YouTube credentials
YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY')
# TikTok credentials
TIKTOK_ACCESS_TOKEN = os.getenv('TIKTOK_ACCESS_TOKEN')
"""

if __name__ == "__main__":
print("MLB_API_KEY:", Config.MLB_API_KEY)
Empty file added src/handlers/__init__ .py
Empty file.
Binary file not shown.
149 changes: 149 additions & 0 deletions src/handlers/data_management.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import pandas as pd

def process_player_data(data):
if 'players' in data:
data = data['players']
if not data or not isinstance(data, list):
print("No player data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

# Convert JSON data to DataFrame
df = pd.DataFrame(data)

if 'status' in df.columns:
# Example of filtering data: select players with a specific attribute
filtered_df = df[df['status'] == 'active']
else:
print("Column 'status' not found in player data.")
filtered_df = pd.DataFrame()

return filtered_df

def process_free_agent_data(data):
if 'free_agents' in data:
data = data['free_agents']
if not data or not isinstance(data, list):
print("No free agent data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

df = pd.DataFrame(data)

# Example of adding a new column
if 'available_since' in df.columns:
df['available_since'] = pd.to_datetime(df['available_since'])

return df

def process_schedule_data(data):
if 'schedule' in data:
data = data['schedule']
if not data or not isinstance(data, list):
print("No schedule data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

df = pd.DataFrame(data)

# Example of sorting data by a specific column
if 'game_date' in df.columns:
df_sorted = df.sort_values(by='game_date')
else:
print("Column 'game_date' not found in schedule data.")
df_sorted = df

return df_sorted

def process_team_data(data):
if 'teams' in data:
data = data['teams']
if not data or not isinstance(data, list):
print("No team data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

df = pd.DataFrame(data)

# Example of handling missing values
df.fillna('Unknown', inplace=True)
return df

def process_team_history_data(data):
if data is None:
print("Received None for team history data.")
return pd.DataFrame() # Retorna un DataFrame vacío

if 'team_history' in data:
data = data['team_history']
if not data or not isinstance(data, list):
print("No team history data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

df = pd.DataFrame(data)

# Example of grouping data
if {'year', 'wins', 'losses'}.issubset(df.columns):
df_grouped = df.groupby('year').agg({'wins': 'sum', 'losses': 'sum'})
else:
print("Columns 'year', 'wins', or 'losses' not found in team history data.")
df_grouped = pd.DataFrame() # Retorna un DataFrame vacío si las columnas no están presentes

return df_grouped

def process_team_coaches_data(data):
if 'team_coaches' in data:
data = data['team_coaches']
if not data or not isinstance(data, list):
print("No team coaches data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

df = pd.DataFrame(data)

# Example of merging with another DataFrame (uncomment and replace 'other_df' with actual DataFrame if needed)
# other_df = pd.DataFrame() # Replace this with actual DataFrame
# df_merged = pd.merge(df, other_df, on='coach_id', how='left')

return df

def process_team_personnel_data(data):
if 'team_personnel' in data:
data = data['team_personnel']
if not data or not isinstance(data, list):
print("No team personnel data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

df = pd.DataFrame(data)

# Example of filtering data by role
if 'role' in df.columns:
filtered_df = df[df['role'] == 'manager']
else:
print("Column 'role' not found in team personnel data.")
filtered_df = pd.DataFrame()

return filtered_df

def process_team_affiliates_data(data):
if 'team_affiliates' in data:
data = data['team_affiliates']
if not data or not isinstance(data, list):
print("No team affiliates data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

df = pd.DataFrame(data)

# Example of renaming columns
df.rename(columns={'affiliation': 'affiliate_name'}, inplace=True)

return df

def process_team_roster_data(data):
if 'team_roster' in data:
data = data['team_roster']
if not data or not isinstance(data, list):
print("No team roster data or data is not in expected format.")
return pd.DataFrame() # Retorna un DataFrame vacío

df = pd.DataFrame(data)

# Example of adding a new column
df['roster_status'] = 'active'

return df
Empty file added src/handlers/facebook_api.py
Empty file.
Empty file added src/handlers/instagram_api.py
Empty file.
Empty file added src/handlers/tiktok_api.py
Empty file.
Empty file.
Empty file added src/handlers/youtube_api.py
Empty file.
Empty file added src/services/__init__.py
Empty file.
Binary file added src/services/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Empty file added src/services/authentication.py
Empty file.
Empty file added src/services/aws_s3.py
Empty file.
Loading

0 comments on commit 9591818

Please sign in to comment.