Spaces:
Runtime error
Runtime error
import boto3 | |
import os | |
import re | |
import json | |
from pathlib import Path | |
import sqlite3 | |
from huggingface_hub import Repository, HfFolder | |
import tqdm | |
import subprocess | |
from fastapi import FastAPI | |
from fastapi_utils.tasks import repeat_every | |
paginator = s3.get_paginator('list_objects_v2') | |
repo.git_pull() | |
def get_datasetdata(dataset_path): | |
def sync_rooms_to_dataset(): | |
for room_data_db in get_db(ROOMS_DATA_DB): | |
except Exception as e: | |
print(e) | |
continue | |
objects += results | |
room_data_db.commit() | |
all_rows = [dict(row) for row in room_data_db.execute( | |
"SELECT * FROM rooms_data WHERE room_id = ?", (room_id,)).fetchall()] | |
data_path = S3_DATA_FOLDER / f"{room_id}.json" | |
with open(data_path, 'w') as f: | |
json.dump(all_rows, f, separators=(',', ':')) | |
print("Updating repository") | |
subprocess.Popen( | |
"git add . && git commit --amend -m 'update' && git push --force", cwd=S3_DATA_FOLDER, shell=True) | |
app = FastAPI() | |
def read_root(): | |
return "Just a bot to sync data to huggingface datasets and tweet tha latest data" | |
def sync(): | |
sync_rooms_to_dataset() | |
return "Synced data to huggingface datasets" | |
def repeat_sync(): | |
sync_rooms_to_dataset() | |
return "Synced data to huggingface datasets" | |