2828from opentelemetry ._logs import LogRecord
2929from opentelemetry .test .test_base import TestBase
3030from opentelemetry .util .genai import types
31- from opentelemetry .util .genai ._fsspec_upload .completion_hook import (
32- FsspecUploadCompletionHook ,
31+ from opentelemetry .util .genai ._upload .completion_hook import (
32+ UploadCompletionHook ,
3333)
3434from opentelemetry .util .genai .completion_hook import (
3535 _NoOpCompletionHook ,
4444@patch .dict (
4545 "os.environ" ,
4646 {
47- "OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK" : "fsspec_upload " ,
47+ "OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK" : "upload " ,
4848 "OTEL_INSTRUMENTATION_GENAI_UPLOAD_BASE_PATH" : BASE_PATH ,
4949 },
5050 clear = True ,
5151)
52- class TestFsspecEntryPoint (TestCase ):
53- def test_fsspec_entry_point (self ):
54- self .assertIsInstance (
55- load_completion_hook (), FsspecUploadCompletionHook
56- )
52+ class TestUploadEntryPoint (TestCase ):
53+ def test_upload_entry_point (self ):
54+ self .assertIsInstance (load_completion_hook (), UploadCompletionHook )
5755
58- def test_fsspec_entry_point_no_fsspec (self ):
56+ def test_upload_entry_point_no_fsspec (self ):
5957 """Tests that the a no-op uploader is used when fsspec is not installed"""
6058
61- from opentelemetry .util .genai import _fsspec_upload
59+ from opentelemetry .util .genai import _upload
6260
6361 # Simulate fsspec imports failing
6462 with patch .dict (
6563 sys .modules ,
66- {"opentelemetry.util.genai._fsspec_upload .completion_hook" : None },
64+ {"opentelemetry.util.genai._upload .completion_hook" : None },
6765 ):
68- importlib .reload (_fsspec_upload )
66+ importlib .reload (_upload )
6967 self .assertIsInstance (load_completion_hook (), _NoOpCompletionHook )
7068
7169
@@ -114,15 +112,15 @@ def _increment_mock_call(self, /, *args, **kwargs):
114112 super ()._increment_mock_call (* args , ** kwargs )
115113
116114
117- class TestFsspecUploadCompletionHook (TestCase ):
115+ class TestUploadCompletionHook (TestCase ):
118116 def setUp (self ):
119117 self ._fsspec_patcher = patch (
120- "opentelemetry.util.genai._fsspec_upload .completion_hook.fsspec"
118+ "opentelemetry.util.genai._upload .completion_hook.fsspec"
121119 )
122120 self .mock_fsspec = self ._fsspec_patcher .start ()
123121 self .mock_fsspec .open = ThreadSafeMagicMock ()
124122
125- self .hook = FsspecUploadCompletionHook (
123+ self .hook = UploadCompletionHook (
126124 base_path = BASE_PATH ,
127125 max_size = MAXSIZE ,
128126 )
@@ -187,7 +185,7 @@ def test_upload_blocked(self):
187185 )
188186
189187 self .assertIn (
190- "fsspec upload queue is full, dropping upload" , logs .output [0 ]
188+ "upload queue is full, dropping upload" , logs .output [0 ]
191189 )
192190
193191 def test_shutdown_timeout (self ):
@@ -212,13 +210,11 @@ def test_failed_upload_logs(self):
212210 )
213211 self .hook .shutdown ()
214212
215- self .assertIn ("fsspec uploader failed" , logs .output [0 ])
213+ self .assertIn ("uploader failed" , logs .output [0 ])
216214
217215 def test_invalid_upload_format (self ):
218216 with self .assertRaisesRegex (ValueError , "Invalid upload_format" ):
219- FsspecUploadCompletionHook (
220- base_path = BASE_PATH , upload_format = "invalid"
221- )
217+ UploadCompletionHook (base_path = BASE_PATH , upload_format = "invalid" )
222218
223219 def test_parse_upload_format_envvar (self ):
224220 for envvar_value , expect in (
@@ -233,7 +229,7 @@ def test_parse_upload_format_envvar(self):
233229 {"OTEL_INSTRUMENTATION_GENAI_UPLOAD_FORMAT" : envvar_value },
234230 clear = True ,
235231 ):
236- hook = FsspecUploadCompletionHook (base_path = BASE_PATH )
232+ hook = UploadCompletionHook (base_path = BASE_PATH )
237233 self .addCleanup (hook .shutdown )
238234 self .assertEqual (
239235 hook ._format ,
@@ -246,7 +242,7 @@ def test_parse_upload_format_envvar(self):
246242 {"OTEL_INSTRUMENTATION_GENAI_UPLOAD_FORMAT" : "json" },
247243 clear = True ,
248244 ):
249- hook = FsspecUploadCompletionHook (
245+ hook = UploadCompletionHook (
250246 base_path = BASE_PATH , upload_format = "jsonl"
251247 )
252248 self .addCleanup (hook .shutdown )
@@ -262,18 +258,18 @@ def test_upload_after_shutdown_logs(self):
262258 )
263259 self .assertEqual (len (logs .output ), 3 )
264260 self .assertIn (
265- "attempting to upload file after FsspecUploadCompletionHook .shutdown() was already called" ,
261+ "attempting to upload file after UploadCompletionHook .shutdown() was already called" ,
266262 logs .output [0 ],
267263 )
268264
269265
270- class TestFsspecUploadCompletionHookIntegration (TestBase ):
266+ class TestUploadCompletionHookIntegration (TestBase ):
271267 def setUp (self ):
272268 super ().setUp ()
273- self .hook = FsspecUploadCompletionHook (base_path = BASE_PATH )
269+ self .hook = UploadCompletionHook (base_path = BASE_PATH )
274270
275- def create_hook (self ) -> FsspecUploadCompletionHook :
276- self .hook = FsspecUploadCompletionHook (base_path = BASE_PATH )
271+ def create_hook (self ) -> UploadCompletionHook :
272+ self .hook = UploadCompletionHook (base_path = BASE_PATH )
277273 return self .hook
278274
279275 def tearDown (self ):
@@ -365,9 +361,7 @@ def test_upload_bytes(self) -> None:
365361 )
366362
367363 def test_upload_json (self ) -> None :
368- hook = FsspecUploadCompletionHook (
369- base_path = BASE_PATH , upload_format = "json"
370- )
364+ hook = UploadCompletionHook (base_path = BASE_PATH , upload_format = "json" )
371365 self .addCleanup (hook .shutdown )
372366 log_record = LogRecord ()
373367
@@ -390,9 +384,7 @@ def test_upload_json(self) -> None:
390384 )
391385
392386 def test_upload_jsonlines (self ) -> None :
393- hook = FsspecUploadCompletionHook (
394- base_path = BASE_PATH , upload_format = "jsonl"
395- )
387+ hook = UploadCompletionHook (base_path = BASE_PATH , upload_format = "jsonl" )
396388 self .addCleanup (hook .shutdown )
397389 log_record = LogRecord ()
398390
0 commit comments