Skip to content

Commit 95f31dc

Browse files
committed
Add file level comments - better logging
1 parent 01471b7 commit 95f31dc

File tree

9 files changed

+95
-64
lines changed

9 files changed

+95
-64
lines changed

libs/oracledb/langchain_oracledb/document_loaders/oracleadb_loader.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
# Copyright (c) 2025 Oracle and/or its affiliates.
1+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
"""
4+
oracleadb_loader.py
5+
6+
Contains OracleAutonomousDatabaseLoader for connecting to
7+
Oracle Autonomous Database (ADB).
8+
"""
39

410
from typing import Any, Dict, List, Optional, Union
511

libs/oracledb/langchain_oracledb/document_loaders/oracleai.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
# Copyright (c) 2025 Oracle and/or its affiliates.
1+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
"""
4+
oracleai.py
35
4-
# Authors:
5-
# Harichandan Roy (hroy)
6-
# David Jiang (ddjiang)
7-
#
8-
# -----------------------------------------------------------------------------
9-
# oracleai.py
10-
# -----------------------------------------------------------------------------
6+
Defines OracleDocLoader and OracleTextSplitter for loading
7+
and splitting documents using Oracle AI Vector Search.
8+
9+
Authors:
10+
- Harichandan Roy (hroy)
11+
- David Jiang (ddjiang)
12+
"""
1113

1214
from __future__ import annotations
1315

libs/oracledb/langchain_oracledb/embeddings/oracleai.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
# Copyright (c) 2025 Oracle and/or its affiliates.
1+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
"""
4+
oracleai.py
35
4-
# Authors:
5-
# Harichandan Roy (hroy)
6-
# David Jiang (ddjiang)
7-
#
8-
# -----------------------------------------------------------------------------
9-
# oracleai.py
10-
# -----------------------------------------------------------------------------
6+
Implements OracleEmbeddings for generating and handling
7+
vector embeddings with Oracle AI Vector Search.
118
9+
Authors:
10+
- Harichandan Roy (hroy)
11+
- David Jiang (ddjiang)
12+
"""
1213
from __future__ import annotations
1314

1415
import json

libs/oracledb/langchain_oracledb/utilities/oracleai.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Copyright (c) 2025 Oracle and/or its affiliates.
1+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
"""
4+
oracleai.py
35
4-
# Authors:
5-
# Harichandan Roy (hroy)
6-
# David Jiang (ddjiang)
7-
#
8-
# -----------------------------------------------------------------------------
9-
# oracleai.py
10-
# -----------------------------------------------------------------------------
6+
Implements OracleSummary with Oracle AI Vector Search support.
117
8+
Authors:
9+
- Harichandan Roy (hroy)
10+
- David Jiang (ddjiang)
11+
"""
1212
from __future__ import annotations
1313

1414
import json

libs/oracledb/langchain_oracledb/vectorstores/oraclevs.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# Copyright (c) 2025 Oracle and/or its affiliates.
1+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
"""
4+
oraclevs.py
35
6+
Provides integration between Oracle Vector Database and
7+
LangChain for vector storage and search.
8+
"""
49
from __future__ import annotations
510

611
import array
@@ -328,9 +333,9 @@ def _create_table(connection: Connection, table_name: str, embedding_dim: int) -
328333
)
329334
ddl = f"CREATE TABLE {table_name} ({ddl_body})"
330335
cursor.execute(ddl)
331-
logger.info("Table created successfully...")
336+
logger.info(f"Table {table_name} created successfully...")
332337
else:
333-
logger.info("Table already exists...")
338+
logger.info(f"Table {table_name} already exists...")
334339

335340

336341
async def _acreate_table(
@@ -345,9 +350,9 @@ async def _acreate_table(
345350
)
346351
ddl = f"CREATE TABLE {table_name} ({ddl_body})"
347352
await cursor.execute(ddl)
348-
logger.info("Table created successfully...")
353+
logger.info(f"Table {table_name} created successfully...")
349354
else:
350-
logger.info("Table already exists...")
355+
logger.info(f"Table {table_name} already exists...")
351356

352357

353358
@_handle_exceptions
@@ -477,9 +482,9 @@ def _create_hnsw_index(
477482
if not _index_exists(connection, idx_name, table_name):
478483
with connection.cursor() as cursor:
479484
cursor.execute(ddl)
480-
logger.info("Index created successfully...")
485+
logger.info(f"Index {idx_name} created successfully...")
481486
else:
482-
logger.info("Index already exists...")
487+
logger.info(f"Index {idx_name} already exists...")
483488

484489

485490
def _get_ivf_index_ddl(
@@ -559,9 +564,9 @@ def _create_ivf_index(
559564
if not _index_exists(connection, idx_name, table_name):
560565
with connection.cursor() as cursor:
561566
cursor.execute(ddl)
562-
logger.info("Index created successfully...")
567+
logger.info(f"Index {idx_name} created successfully...")
563568
else:
564-
logger.info("Index already exists...")
569+
logger.info(f"Index {idx_name} already exists...")
565570

566571

567572
@_ahandle_exceptions
@@ -618,9 +623,9 @@ async def _acreate_hnsw_index(
618623
if not await _aindex_exists(connection, idx_name, table_name):
619624
with connection.cursor() as cursor:
620625
await cursor.execute(ddl)
621-
logger.info("Index created successfully...")
626+
logger.info(f"Index {idx_name} created successfully...")
622627
else:
623-
logger.info("Index already exists...")
628+
logger.info(f"Index {idx_name} already exists...")
624629

625630

626631
async def _acreate_ivf_index(
@@ -635,9 +640,9 @@ async def _acreate_ivf_index(
635640
if not await _aindex_exists(connection, idx_name, table_name):
636641
with connection.cursor() as cursor:
637642
await cursor.execute(ddl)
638-
logger.info("Index created successfully...")
643+
logger.info(f"Index {idx_name} created successfully...")
639644
else:
640-
logger.info("Index already exists...")
645+
logger.info(f"Index {idx_name} already exists...")
641646

642647

643648
@_handle_exceptions
@@ -658,9 +663,9 @@ def drop_table_purge(client: Any, table_name: str) -> None:
658663
with connection.cursor() as cursor:
659664
ddl = f"DROP TABLE {table_name} PURGE"
660665
cursor.execute(ddl)
661-
logger.info("Table dropped successfully...")
666+
logger.info(f"Table {table_name} dropped successfully...")
662667
else:
663-
logger.info("Table not found...")
668+
logger.info(f"Table {table_name} not found...")
664669
return
665670

666671

@@ -681,9 +686,9 @@ async def context(connection: Any) -> None:
681686
with connection.cursor() as cursor:
682687
ddl = f"DROP TABLE {table_name} PURGE"
683688
await cursor.execute(ddl)
684-
logger.info("Table dropped successfully...")
689+
logger.info(f"Table {table_name} dropped successfully...")
685690
else:
686-
logger.info("Table not found...")
691+
logger.info(f"Table {table_name} not found...")
687692

688693
await _handle_context(client, context)
689694
return

libs/oracledb/tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Copyright (c) 2023 Oracle and/or its affiliates.
1+
# Copyright (c) 2025 Oracle and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

libs/oracledb/tests/integration_tests/document_loaders/test_oracleds.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# Authors:
2-
# Sudhir Kumar (sudhirkk)
3-
#
4-
# -----------------------------------------------------------------------------
5-
# test_oracleds.py
6-
# -----------------------------------------------------------------------------
1+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
"""
4+
test_oracleds.py
5+
6+
Unit tests for OracleDocLoader and OracleTextSplitter.
7+
8+
Authors:
9+
- Sudhir Kumar (sudhirkk)
10+
"""
711
import sys
812

913
from langchain_oracledb.document_loaders.oracleai import (

libs/oracledb/tests/integration_tests/vectorstores/test_oraclevs.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
"""Test Oracle AI Vector Search functionality."""
1+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
"""
4+
test_oraclevs.py
5+
6+
Test Oracle AI Vector Search functionality integration
7+
with OracleVS.
8+
"""
29

310
# import required modules
411
import asyncio
512
import logging
6-
import os
713
import sys
814
import threading
915

@@ -2321,19 +2327,19 @@ def test_index_table_case(caplog: pytest.LogCaptureFixture) -> None:
23212327
with caplog.at_level(logging.INFO):
23222328
vs_obj = OracleVS(connection, model, "TB1", DistanceStrategy.EUCLIDEAN_DISTANCE)
23232329

2324-
assert "Table created successfully..." in caplog.text
2330+
assert "Table TB1 created successfully..." in caplog.text
23252331

23262332
with caplog.at_level(logging.INFO):
23272333
OracleVS(connection, model, "Tb1", DistanceStrategy.EUCLIDEAN_DISTANCE)
23282334

2329-
assert "Table already exists..." in caplog.text
2335+
assert "Table Tb1 already exists..." in caplog.text
23302336

23312337
with caplog.at_level(logging.INFO):
23322338
vs_obj2 = OracleVS(
23332339
connection, model, "TB2", DistanceStrategy.EUCLIDEAN_DISTANCE
23342340
)
23352341

2336-
assert "Table created successfully..." in caplog.text
2342+
assert "Table TB2 created successfully..." in caplog.text
23372343

23382344
vs_obj.add_texts(texts, metadata)
23392345

@@ -2342,14 +2348,14 @@ def test_index_table_case(caplog: pytest.LogCaptureFixture) -> None:
23422348
connection, vs_obj, params={"idx_name": "hnsw_idx2", "idx_type": "HNSW"}
23432349
)
23442350

2345-
assert "Index created successfully..." in caplog.text
2351+
assert "Index hnsw_idx2 created successfully..." in caplog.text
23462352

23472353
with caplog.at_level(logging.INFO):
23482354
create_index(
23492355
connection, vs_obj, params={"idx_name": "HNSW_idx2", "idx_type": "HNSW"}
23502356
)
23512357

2352-
assert "Index already exists..." in caplog.text
2358+
assert "Index HNSW_idx2 already exists..." in caplog.text
23532359

23542360
with pytest.raises(
23552361
RuntimeError, match="name is already used by an existing object"
@@ -2365,7 +2371,7 @@ def test_index_table_case(caplog: pytest.LogCaptureFixture) -> None:
23652371
connection, vs_obj, params={"idx_name": '"hnsw_idx2"', "idx_type": "HNSW"}
23662372
)
23672373

2368-
assert "Index created successfully..." in caplog.text
2374+
assert 'Index "hnsw_idx2" created successfully...' in caplog.text
23692375

23702376
with pytest.raises(RuntimeError, match="such column list already indexed"):
23712377
create_index(
@@ -2377,7 +2383,7 @@ def test_index_table_case(caplog: pytest.LogCaptureFixture) -> None:
23772383

23782384

23792385
@pytest.mark.asyncio
2380-
async def test_insdex_table_case_async(caplog: pytest.LogCaptureFixture) -> None:
2386+
async def test_index_table_case_async(caplog: pytest.LogCaptureFixture) -> None:
23812387
try:
23822388
connection = await oracledb.connect_async(
23832389
user=username, password=password, dsn=dsn
@@ -2402,21 +2408,21 @@ async def test_insdex_table_case_async(caplog: pytest.LogCaptureFixture) -> None
24022408
connection, model, "TB1", DistanceStrategy.EUCLIDEAN_DISTANCE
24032409
)
24042410

2405-
assert "Table created successfully..." in caplog.text
2411+
assert "Table TB1 created successfully..." in caplog.text
24062412

24072413
with caplog.at_level(logging.INFO):
24082414
await OracleVS.acreate(
24092415
connection, model, "Tb1", DistanceStrategy.EUCLIDEAN_DISTANCE
24102416
)
24112417

2412-
assert "Table already exists..." in caplog.text
2418+
assert "Table Tb1 already exists..." in caplog.text
24132419

24142420
with caplog.at_level(logging.INFO):
24152421
vs_obj2 = await OracleVS.acreate(
24162422
connection, model, "TB2", DistanceStrategy.EUCLIDEAN_DISTANCE
24172423
)
24182424

2419-
assert "Table created successfully..." in caplog.text
2425+
assert "Table TB2 created successfully..." in caplog.text
24202426

24212427
await vs_obj.aadd_texts(texts, metadata)
24222428

@@ -2425,14 +2431,14 @@ async def test_insdex_table_case_async(caplog: pytest.LogCaptureFixture) -> None
24252431
connection, vs_obj, params={"idx_name": "hnsw_idx2", "idx_type": "HNSW"}
24262432
)
24272433

2428-
assert "Index created successfully..." in caplog.text
2434+
assert "Index hnsw_idx2 created successfully..." in caplog.text
24292435

24302436
with caplog.at_level(logging.INFO):
24312437
await acreate_index(
24322438
connection, vs_obj, params={"idx_name": "HNSW_idx2", "idx_type": "HNSW"}
24332439
)
24342440

2435-
assert "Index already exists..." in caplog.text
2441+
assert "Index HNSW_idx2 already exists..." in caplog.text
24362442

24372443
with pytest.raises(
24382444
RuntimeError, match="name is already used by an existing object"
@@ -2448,7 +2454,7 @@ async def test_insdex_table_case_async(caplog: pytest.LogCaptureFixture) -> None
24482454
connection, vs_obj, params={"idx_name": '"hnsw_idx2"', "idx_type": "HNSW"}
24492455
)
24502456

2451-
assert "Index created successfully..." in caplog.text
2457+
assert 'Index "hnsw_idx2" created successfully...' in caplog.text
24522458

24532459
with pytest.raises(RuntimeError, match="such column list already indexed"):
24542460
await acreate_index(

libs/oracledb/tests/unit_tests/document_loaders/test_oracleadb.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
"""
4+
test_oracleadb.py
5+
6+
Unit tests for OracleAutonomousDatabaseLoader.
7+
"""
18
from typing import Dict, List
29
from unittest.mock import MagicMock, patch
310

0 commit comments

Comments
 (0)