Skip to content

Commit efd0654

Browse files
committed
Increase page size for listing files in pull implementation from 10 to 100
1 parent b1fb94f commit efd0654

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/humanloop/sync/sync_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def _save_serialized_file(
203203
logger.error(f"Failed to write {file_type} {file_path} to disk: {str(e)}")
204204
raise
205205

206-
def _pull_file(self, path: str | None = None, environment: str | None = None) -> bool:
206+
def _pull_file(self, path: str, environment: str | None = None) -> bool:
207207
"""Pull a specific file from Humanloop to local filesystem.
208208
209209
Returns:
@@ -262,6 +262,7 @@ def _pull_directory(
262262
response = self.client.files.list_files(
263263
type=list(self.SERIALIZABLE_FILE_TYPES),
264264
page=page,
265+
size=100,
265266
include_raw_file_content=True,
266267
environment=environment,
267268
path=path,

tests/custom/sync/test_client.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_init(sync_client: SyncClient, tmp_path: Path):
2828
# THEN it should be initialized with correct base directory, cache size and file types
2929
assert sync_client.base_dir == tmp_path
3030
assert sync_client._cache_size == 10
31-
assert sync_client.SERIALIZABLE_FILE_TYPES == ["prompt", "agent"]
31+
assert sync_client.SERIALIZABLE_FILE_TYPES == frozenset(["prompt", "agent"])
3232

3333

3434
def test_normalize_path(sync_client: SyncClient):
@@ -37,7 +37,6 @@ def test_normalize_path(sync_client: SyncClient):
3737
test_cases = [
3838
("path/to/file.prompt", "path/to/file"),
3939
("path\\to\\file.agent", "path/to/file"),
40-
("/leading/slashes/file.prompt", "leading/slashes/file"),
4140
("trailing/slashes/file.agent/", "trailing/slashes/file"),
4241
("multiple//slashes//file.prompt", "multiple/slashes/file"),
4342
]
@@ -48,6 +47,10 @@ def test_normalize_path(sync_client: SyncClient):
4847
# THEN they should be converted to the expected format
4948
assert normalized == expected
5049

50+
# Test absolute path raises error
51+
with pytest.raises(HumanloopRuntimeError, match="Absolute paths are not supported"):
52+
sync_client._normalize_path("/leading/slashes/file.prompt")
53+
5154

5255
def test_is_file(sync_client: SyncClient):
5356
"""Test file type detection."""
@@ -65,7 +68,7 @@ def test_save_and_read_file(sync_client: SyncClient):
6568
# GIVEN a file content and path
6669
content = "test content"
6770
path = "test/path"
68-
file_type: SerializableFileType = "prompt"
71+
file_type: SerializableFileType = "prompt"
6972

7073
# WHEN saving the file
7174
sync_client._save_serialized_file(content, path, "prompt")
@@ -90,12 +93,6 @@ def test_error_handling(sync_client: SyncClient):
9093
with pytest.raises(HumanloopRuntimeError, match="Local file not found"):
9194
sync_client.get_file_content("nonexistent", "prompt")
9295

93-
# GIVEN an invalid file type
94-
# WHEN trying to pull the file
95-
# THEN a ValueError should be raised
96-
with pytest.raises(ValueError, match="Unsupported file type"):
97-
sync_client._pull_file("test.txt")
98-
9996
# GIVEN an API error
10097
# WHEN trying to pull a file
10198
# THEN it should return False

0 commit comments

Comments
 (0)