Skip to content

Commit 52647d9

Browse files
committed
Add comments and disable obsolete functionality
1 parent 2767970 commit 52647d9

File tree

2 files changed

+63
-19
lines changed

2 files changed

+63
-19
lines changed

terminusdb_client/tests/integration_tests/conftest.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def is_local_server_running():
1313
"""Check if local TerminusDB server is running at http://127.0.0.1:6363"""
1414
try:
1515
response = requests.get("http://127.0.0.1:6363", timeout=2)
16-
# Server responds with 404 for root path, which means it's running
16+
# Server responds with 200 (success) or 404 (not found but server is up)
17+
# 401 (unauthorized) also indicates server is running but needs auth
1718
return response.status_code in [200, 404]
1819
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
1920
return False
@@ -73,7 +74,9 @@ def docker_url_jwt(pytestconfig):
7374

7475
# Check if JWT server is already running (port 6367)
7576
if is_jwt_server_running():
76-
print("\n✓ Using existing JWT Docker TerminusDB server at http://127.0.0.1:6367")
77+
print(
78+
"\n✓ Using existing JWT Docker TerminusDB server at http://127.0.0.1:6367"
79+
)
7780
yield ("http://127.0.0.1:6367", jwt_token)
7881
return # Don't clean up - server was already running
7982

@@ -128,7 +131,9 @@ def docker_url_jwt(pytestconfig):
128131

129132
if seconds_waited > MAX_CONTAINER_STARTUP_TIME:
130133
clean_up_container()
131-
raise RuntimeError(f"JWT Container was too slow to startup (waited {MAX_CONTAINER_STARTUP_TIME}s)")
134+
raise RuntimeError(
135+
f"JWT Container was too slow to startup (waited {MAX_CONTAINER_STARTUP_TIME}s)"
136+
)
132137

133138
yield (test_url, jwt_token)
134139
clean_up_container()
@@ -145,9 +150,15 @@ def docker_url(pytestconfig):
145150
"""
146151
# Check if local test server is already running (port 6363)
147152
if is_local_server_running():
148-
print("\n✓ Using existing local TerminusDB test server at http://127.0.0.1:6363")
149-
print("⚠️ WARNING: Local server should be started with TERMINUSDB_AUTOLOGIN=true")
150-
print(" Or use: TERMINUSDB_SERVER_AUTOLOGIN=true ./tests/terminusdb-test-server.sh restart")
153+
print(
154+
"\n✓ Using existing local TerminusDB test server at http://127.0.0.1:6363"
155+
)
156+
print(
157+
"⚠️ WARNING: Local server should be started with TERMINUSDB_AUTOLOGIN=true"
158+
)
159+
print(
160+
" Or use: TERMINUSDB_SERVER_AUTOLOGIN=true ./tests/terminusdb-test-server.sh restart"
161+
)
151162
yield "http://127.0.0.1:6363"
152163
return # Don't clean up - server was already running
153164

@@ -200,7 +211,9 @@ def docker_url(pytestconfig):
200211
response = requests.get(test_url)
201212
# Server responds with 404 for root path, which means it's running
202213
assert response.status_code in [200, 404]
203-
print(f"✓ Docker container started successfully after {seconds_waited}s")
214+
print(
215+
f"✓ Docker container started successfully after {seconds_waited}s"
216+
)
204217
break
205218
except (requests.exceptions.ConnectionError, AssertionError):
206219
pass
@@ -210,7 +223,9 @@ def docker_url(pytestconfig):
210223

211224
if seconds_waited > MAX_CONTAINER_STARTUP_TIME:
212225
clean_up_container()
213-
raise RuntimeError(f"Container was too slow to startup (waited {MAX_CONTAINER_STARTUP_TIME}s)")
226+
raise RuntimeError(
227+
f"Container was too slow to startup (waited {MAX_CONTAINER_STARTUP_TIME}s)"
228+
)
214229

215230
yield test_url
216231
clean_up_container()

terminusdb_client/woqlquery/woql_query.py

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,7 @@ def _clean_object(self, user_obj, target=None):
413413
elts = []
414414
for item in user_obj:
415415
elts.append(self._clean_object(item))
416-
obj["list"] = elts
417-
return obj
416+
return elts
418417
elif isinstance(user_obj, Var):
419418
return self._expand_value_variable(user_obj)
420419
elif isinstance(user_obj, Doc):
@@ -1511,10 +1510,14 @@ def woql_as(self, *args):
15111510
def file(self, fpath, opts=None):
15121511
"""Provides details of a file source in a JSON format that includes a URL property
15131512
1513+
Note: CSV files can no longer be read from the filesystem. Only files submitted
1514+
as part of the request can be processed. Use remote() for URLs or submit files
1515+
via the API.
1516+
15141517
Parameters
15151518
----------
1516-
fpath : dict
1517-
file data source in a JSON format
1519+
fpath : dict or str
1520+
file data source in a JSON format or file path
15181521
opts : input options
15191522
optional
15201523
@@ -1524,7 +1527,7 @@ def file(self, fpath, opts=None):
15241527
query object that can be chained and/or execute
15251528
Example
15261529
-------
1527-
To load a local csv file:
1530+
To reference a file (must be submitted with request):
15281531
>>> WOQLQuery().file("/app/local_files/my.csv")
15291532
See Also
15301533
--------
@@ -1538,8 +1541,10 @@ def file(self, fpath, opts=None):
15381541
if self._cursor.get("@type"):
15391542
self._wrap_cursor_with_and()
15401543
self._cursor["@type"] = "QueryResource"
1541-
fpath["@type"] = "Source"
1542-
self._cursor["source"] = fpath
1544+
if isinstance(fpath, str):
1545+
self._cursor["source"] = {"@type": "Source", "file": fpath}
1546+
else:
1547+
self._cursor["source"] = fpath
15431548
self._cursor["format"] = "csv"
15441549
if opts:
15451550
self._cursor["options"] = opts
@@ -1601,21 +1606,45 @@ def remote(self, uri, opts=None):
16011606
if self._cursor.get("@type"):
16021607
self._wrap_cursor_with_and()
16031608
self._cursor["@type"] = "QueryResource"
1604-
uri["@type"] = "Source"
1605-
self._cursor["source"] = uri
1609+
if isinstance(uri, dict):
1610+
uri["@type"] = "Source"
1611+
self._cursor["source"] = uri
1612+
else:
1613+
self._cursor["source"] = {"@type": "Source", "url": uri}
16061614
self._cursor["format"] = "csv"
16071615
if opts:
16081616
self._cursor["options"] = opts
16091617
return self
16101618

16111619
def post(self, fpath, opts=None):
1620+
"""Specifies a file to be posted as part of the request for processing.
1621+
1622+
Note: CSV files can no longer be read from the filesystem. Only files submitted
1623+
as part of the request can be processed. This method should be used with files
1624+
that are uploaded via the API.
1625+
1626+
Parameters
1627+
----------
1628+
fpath : str or dict
1629+
file path/identifier or dict with file details
1630+
opts : dict, optional
1631+
additional options for file processing
1632+
1633+
Returns
1634+
-------
1635+
WOQLQuery object
1636+
query object that can be chained and/or execute
1637+
"""
16121638
if fpath and fpath == "args":
16131639
return ["source", "format", "options"]
16141640
if self._cursor.get("@type"):
16151641
self._wrap_cursor_with_and()
16161642
self._cursor["@type"] = "QueryResource"
1617-
fpath["@type"] = "Source"
1618-
self._cursor["source"] = fpath
1643+
if isinstance(fpath, dict):
1644+
fpath["@type"] = "Source"
1645+
self._cursor["source"] = fpath
1646+
else:
1647+
self._cursor["source"] = {"@type": "Source", "post": fpath}
16191648
self._cursor["format"] = "csv"
16201649
if opts:
16211650
self._cursor["options"] = opts

0 commit comments

Comments
 (0)