The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Deny creating files as a result of test runs. (#10253)
Predrag Gruevski82d5d4d0ae53
diff --git a/.github/workflows/_pydantic_compatibility.yml b/.github/workflows/_pydantic_compatibility.ymlindex 7d8fe26d92..94d362f327 100644--- a/.github/workflows/_pydantic_compatibility.yml+++ b/.github/workflows/_pydantic_compatibility.yml@@ -79,3 +79,15 @@ jobs:- name: Run pydantic compatibility testsshell: bashrun: make test++ - name: Ensure the tests did not create any additional files+ shell: bash+ run: |+ set -eu++ STATUS="$(git status)"+ echo "$STATUS"++ # grep will exit non-zero if the target message isn't found,+ # and `set -e` above will cause the step to fail.+ echo "$STATUS" | grep 'nothing to commit, working tree clean'diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.ymlindex 76d86a2862..04be6a2c39 100644--- a/.github/workflows/_test.yml+++ b/.github/workflows/_test.yml@@ -43,3 +43,15 @@ jobs:- name: Run core testsshell: bashrun: make test++ - name: Ensure the tests did not create any additional files+ shell: bash+ run: |+ set -eu++ STATUS="$(git status)"+ echo "$STATUS"++ # grep will exit non-zero if the target message isn't found,+ # and `set -e` above will cause the step to fail.+ echo "$STATUS" | grep 'nothing to commit, working tree clean'diff --git a/.github/workflows/langchain_ci.yml b/.github/workflows/langchain_ci.ymlindex 125f4b3147..f184af9772 100644--- a/.github/workflows/langchain_ci.yml+++ b/.github/workflows/langchain_ci.yml@@ -83,3 +83,15 @@ jobs:- name: Run extended testsrun: make extended_tests++ - name: Ensure the tests did not create any additional files+ shell: bash+ run: |+ set -eu++ STATUS="$(git status)"+ echo "$STATUS"++ # grep will exit non-zero if the target message isn't found,+ # and `set -e` above will cause the step to fail.+ echo "$STATUS" | grep 'nothing to commit, working tree clean'diff --git a/.github/workflows/langchain_experimental_ci.yml b/.github/workflows/langchain_experimental_ci.ymlindex 6e07a5ae1b..c4c4a039c1 100644--- a/.github/workflows/langchain_experimental_ci.yml+++ b/.github/workflows/langchain_experimental_ci.yml@@ -115,3 +115,15 @@ jobs:- name: Run extended testsrun: make extended_tests++ - name: Ensure the tests did not create any additional files+ shell: bash+ run: |+ set -eu++ STATUS="$(git status)"+ echo "$STATUS"++ # grep will exit non-zero if the target message isn't found,+ # and `set -e` above will cause the step to fail.+ echo "$STATUS" | grep 'nothing to commit, working tree clean'diff --git a/.github/workflows/scheduled_test.yml b/.github/workflows/scheduled_test.ymlindex b71eee0592..7ce59d5b69 100644--- a/.github/workflows/scheduled_test.yml+++ b/.github/workflows/scheduled_test.yml@@ -47,3 +47,15 @@ jobs:OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}run: |make scheduled_tests++ - name: Ensure the tests did not create any additional files+ shell: bash+ run: |+ set -eu++ STATUS="$(git status)"+ echo "$STATUS"++ # grep will exit non-zero if the target message isn't found,+ # and `set -e` above will cause the step to fail.+ echo "$STATUS" | grep 'nothing to commit, working tree clean'diff --git a/libs/langchain/langchain/chat_loaders/telegram.py b/libs/langchain/langchain/chat_loaders/telegram.pyindex 786dad7278..f55fd71476 100644--- a/libs/langchain/langchain/chat_loaders/telegram.py+++ b/libs/langchain/langchain/chat_loaders/telegram.py@@ -1,6 +1,7 @@import jsonimport loggingimport os+import tempfileimport zipfilefrom pathlib import Pathfrom typing import Iterator, List, Union@@ -136,7 +137,8 @@ class TelegramChatLoader(chat_loaders.BaseChatLoader):with zipfile.ZipFile(path) as zip_file:for file in zip_file.namelist():if file.endswith((".html", ".json")):- yield zip_file.extract(file)+ with tempfile.TemporaryDirectory() as temp_dir:+ yield zip_file.extract(file, path=temp_dir)def lazy_load(self) -> Iterator[chat_loaders.ChatSession]:"""Lazy load the messages from the chat file and yield them