From 6c9f892ea9c964cdf0d79fedcf1352eb6faa2279 Mon Sep 17 00:00:00 2001 From: Howard Gil Date: Wed, 18 Sep 2024 16:04:59 -0700 Subject: [PATCH 1/2] Removing dateutil from previous commit (#404) * adding pip install * porting from dateutil to datetime --- agentops/session.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/agentops/session.py b/agentops/session.py index a82eeb35..f5722af4 100644 --- a/agentops/session.py +++ b/agentops/session.py @@ -7,7 +7,7 @@ from termcolor import colored from typing import Optional, List, Union from uuid import UUID, uuid4 -from dateutil import parser +from datetime import datetime from .exceptions import ApiServerException from .enums import EndState @@ -106,7 +106,10 @@ def end_session( self._flush_queue() def format_duration(start_time, end_time): - duration = parser.parse(end_time) - parser.parse(start_time) + start = datetime.fromisoformat(start_time.replace("Z", "+00:00")) + end = datetime.fromisoformat(end_time.replace("Z", "+00:00")) + duration = end - start + hours, remainder = divmod(duration.total_seconds(), 3600) minutes, seconds = divmod(remainder, 60) From 3eeb2819dea72fda43c9d9b4bc4c988483e6a68b Mon Sep 17 00:00:00 2001 From: Howard Gil Date: Wed, 18 Sep 2024 16:05:32 -0700 Subject: [PATCH 2/2] Touching up automation for prod (#402) * adding pip install * Action runs when I modify this file Action now pushes to main Action now avoids appending file contents forever --- .../add-markdown-examples-to-docs.yml | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/add-markdown-examples-to-docs.yml b/.github/workflows/add-markdown-examples-to-docs.yml index fc26fb8b..768a1577 100644 --- a/.github/workflows/add-markdown-examples-to-docs.yml +++ b/.github/workflows/add-markdown-examples-to-docs.yml @@ -7,6 +7,7 @@ on: paths: - 'examples/**' - 'docs/v1/examples/**' + - '.github/workflows/add-markdown-examples-to-docs.yml' permissions: contents: write @@ -43,8 +44,10 @@ jobs: echo "Converting notebook to markdown" jupyter nbconvert --to markdown "$source_file" || { echo "Error: Failed to convert $source_file" >&2; continue; } markdown_file="${source_file%.ipynb}.md" + echo "Removing existing content after {/* SOURCE_FILE: ... */}" + sed -i '/\{\/\* SOURCE_FILE:/,$d' "$file" echo "Appending markdown to $file" - echo -e "\n\n" >> "$file" + echo -e "\n{/* SOURCE_FILE: $source_file */}\n" >> "$file" cat "$markdown_file" >> "$file" || { echo "Error: Failed to append markdown to $file" >&2; continue; } rm "$markdown_file" || { echo "Error: Failed to remove $markdown_file" >&2; continue; } else @@ -59,19 +62,8 @@ jobs: git add docs/v1/examples/*.mdx git diff --quiet && git diff --staged --quiet || git commit -m "GitHub Action: Update examples in docs from notebooks" - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 + - name: Push changes + uses: ad-m/github-push-action@master with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update examples in docs from notebooks - title: 'Update examples in docs from notebooks' - body: | - This PR updates the examples in the docs from the corresponding notebooks. - Please review the changes before merging. - branch: update-docs-examples - base: main -# - name: Push changes -# uses: ad-m/github-push-action@master -# with: -# github_token: ${{ secrets.GITHUB_TOKEN }} -# branch: main \ No newline at end of file + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: main \ No newline at end of file