Skip to content

Commit

Permalink
fix: fix test data simulator, add Discord message to on_ready event
Browse files Browse the repository at this point in the history
  • Loading branch information
peterxcli committed Jan 30, 2024
1 parent d158ab2 commit be9e6bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 6 additions & 3 deletions bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ async def update_active_threads():
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
channel = client.get_channel(DISCORD_DST_CHANNEL_ID)
await channel.send("開始模擬即時資料")
# channel = client.get_channel(DISCORD_DST_CHANNEL_ID)
# client.loop.create_task(update_active_threads())
# if channel:
Expand Down Expand Up @@ -159,9 +161,10 @@ def run_bot():

# @client.event
# async def on_ready():
# print(f'{client.user} has connected to Discord!')
# print("TSMC System Bot is Online!")
# client.loop.create_task(warning_task())
# # print(f'{client.user} has connected to Discord!')
# # print("TSMC System Bot is Online!")
# channel = client.get_channel(DISCORD_DST_CHANNEL_ID)
# await channel.send("開始模擬即時資料")


# client.run(DISCORD_BOT_TOKEN)
2 changes: 1 addition & 1 deletion monitor/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cloud Run Monitor System
# Cloud Run Monitor Controller

## Setup `gcloud` environment

Expand Down
7 changes: 6 additions & 1 deletion simulate_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ def is_end(self):


async def main(data_directory: str):
# channel_id = os.getenv("DISCORD_DST_CHANNEL_ID")
simulate_data: pd.DataFrame = preprocess_metric_data(data_directory)
data_simulator = RealTimeDataSimulator(simulate_data)
bot_thread = threading.Thread(target=run_bot)
bot_thread.start()
while not client.is_ready():
await asyncio.sleep(1)
# channel = await client.get_channel(channel_id)
# await channel.send(f"開始模擬 {data_directory} 資料")
while not data_simulator.is_end():
chunk = data_simulator.get_next_chunk(50)
chunk = data_simulator.get_next_chunk(10)
result = analyze_by_llm(chunk)
print(result)
result["timestamp"] = datetime.datetime.now()
Expand Down

0 comments on commit be9e6bf

Please sign in to comment.