Skip to content

Commit 7fafdc1

Browse files
committed
fix: update references from Cypher to OpenCypher in documentation and examples
1 parent 1d8d9b6 commit 7fafdc1

7 files changed

Lines changed: 78 additions & 12 deletions

File tree

bindings/python/docs/api/async_executor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Execute async query.
332332

333333
**Parameters:**
334334

335-
- `language` (str): Query language ("sql", "cypher", etc.)
335+
- `language` (str): Query language ("sql", "opencypher", etc.)
336336
- `query` (str): Query string
337337
- `callback` (Callable): Callback for query results
338338
- `**params`: Query parameters

bindings/python/docs/api/results.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,14 +658,14 @@ import arcadedb_embedded as arcadedb
658658

659659
db = arcadedb.open_database("./graph_db")
660660

661-
# Cypher queries also return ResultSet
661+
# OpenCypher queries also return ResultSet
662662
cypher_query = """
663663
MATCH (p:Person)-[:WORKS_AT]->(c:Company)
664664
WHERE c.name = 'TechCorp'
665665
RETURN p.name AS employee, p.role AS position
666666
"""
667667

668-
result_set = db.query("cypher", cypher_query)
668+
result_set = db.query("opencypher", cypher_query)
669669

670670
print("TechCorp Employees:")
671671
for result in result_set:

bindings/python/docs/examples/21_server_mode_http_access.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ python3 21_server_mode_http_access.py --http-port 2491 --server-root ./my_test_d
4444
remote client wrapper or a new dependency.
4545
- Database creation still happens through the existing server-managed Java API,
4646
because that is the supported path already used in the test suite.
47-
- The example binds to `127.0.0.1:2481` by default to reduce clashes with any
48-
separately running local ArcadeDB server on the usual `2480` port.
47+
- The example prefers `127.0.0.1:2481` by default to reduce clashes with any
48+
separately running local ArcadeDB server on the usual `2480` port. If that
49+
port is already in use, the script automatically falls back to a free local
50+
port and prints the chosen value.
4951
- By default the example exits as soon as the scripted verification steps finish,
5052
which shuts the server down immediately. Use `--wait-for-enter` if you want time
5153
to open Studio and inspect the database before shutdown.

bindings/python/docs/java-api-coverage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ This approach is actually **cleaner and more maintainable** than direct API expo
198198
```python
199199
# Python way (clean):
200200
db.command("sql", "CREATE INDEX ON User (email) UNIQUE")
201-
db.query("cypher", "MATCH (a)-[:FOLLOWS]->(b) RETURN b")
201+
db.query("opencypher", "MATCH (a)-[:FOLLOWS]->(b) RETURN b")
202202

203203
# vs. hypothetical direct API (complex):
204204
schema = db.getSchema()

bindings/python/examples/21_server_mode_http_access.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import base64
2828
import json
2929
import shutil
30+
import socket
3031
import time
3132
from pathlib import Path
3233
from urllib.error import HTTPError, URLError
@@ -110,6 +111,32 @@ def reset_server_root(server_root: Path) -> None:
110111
server_root.parent.mkdir(parents=True, exist_ok=True)
111112

112113

114+
def choose_http_port(host: str, requested_port: int) -> tuple[int, bool]:
115+
"""Return a usable HTTP port for the example.
116+
117+
Tries the requested port first. If it is unavailable, fall back to an
118+
ephemeral free port chosen by the OS.
119+
"""
120+
121+
def _can_bind(port: int) -> bool:
122+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
123+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
124+
try:
125+
sock.bind((host, port))
126+
except OSError:
127+
return False
128+
return True
129+
130+
if requested_port > 0 and _can_bind(requested_port):
131+
return requested_port, False
132+
133+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
134+
sock.bind((host, 0))
135+
fallback_port = int(sock.getsockname()[1])
136+
137+
return fallback_port, True
138+
139+
113140
def basic_auth_header(username: str, password: str) -> dict[str, str]:
114141
token = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("ascii")
115142
return {"Authorization": f"Basic {token}"}
@@ -186,7 +213,9 @@ def main() -> int:
186213
server_root = Path(args.server_root)
187214
reset_server_root(server_root)
188215

189-
base_url = f"http://{args.host}:{args.http_port}"
216+
http_port, used_fallback_port = choose_http_port(args.host, args.http_port)
217+
218+
base_url = f"http://{args.host}:{http_port}"
190219
basic_headers = basic_auth_header("root", ROOT_PASSWORD)
191220

192221
print("=" * 72)
@@ -197,14 +226,19 @@ def main() -> int:
197226
print(f"Server root: {server_root}")
198227
print(f"Database name: {args.db_name}")
199228
print(f"Base URL: {base_url}")
229+
if used_fallback_port:
230+
print(
231+
f"Requested HTTP port {args.http_port} was unavailable; "
232+
f"using {http_port} instead."
233+
)
200234
print()
201235

202236
with arcadedb.create_server(
203237
str(server_root),
204238
root_password=ROOT_PASSWORD,
205239
config={
206240
"host": args.host,
207-
"http_port": args.http_port,
241+
"http_port": http_port,
208242
"mode": "development",
209243
},
210244
) as server:

bindings/python/examples/scripts/internal_vector_http_latency_probe.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import json
2929
import os
3030
import random
31+
import socket
3132
import tempfile
3233
import time
3334
from contextlib import contextmanager
@@ -140,6 +141,32 @@ def require(condition: bool, message: str) -> None:
140141
raise SystemExit(message)
141142

142143

144+
def choose_http_port(host: str, requested_port: int) -> tuple[int, bool]:
145+
"""Return a usable HTTP port for the probe.
146+
147+
Tries the requested port first. If it is unavailable, fall back to an
148+
ephemeral free port chosen by the OS.
149+
"""
150+
151+
def _can_bind(port: int) -> bool:
152+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
153+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
154+
try:
155+
sock.bind((host, port))
156+
except OSError:
157+
return False
158+
return True
159+
160+
if requested_port > 0 and _can_bind(requested_port):
161+
return requested_port, False
162+
163+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
164+
sock.bind((host, 0))
165+
fallback_port = int(sock.getsockname()[1])
166+
167+
return fallback_port, True
168+
169+
143170
@contextmanager
144171
def prepare_server_root(
145172
db_path: Path,
@@ -442,7 +469,8 @@ def main() -> int:
442469
db_path = Path(args.db_path).resolve()
443470
require(db_path.is_dir(), f"Database path not found or not a directory: {db_path}")
444471
index_name = f"{args.type_name}[{args.vector_field}]"
445-
base_url = f"http://{args.host}:{args.http_port}"
472+
http_port, used_fallback_port = choose_http_port(args.host, args.http_port)
473+
base_url = f"http://{args.host}:{http_port}"
446474

447475
sql_forms = [args.sql_form] if args.sql_form != "both" else ["raw", "expand"]
448476

@@ -456,7 +484,7 @@ def main() -> int:
456484
"root_password": args.root_password,
457485
"config": {
458486
"host": args.host,
459-
"http_port": args.http_port,
487+
"http_port": http_port,
460488
"mode": "development",
461489
},
462490
}
@@ -472,6 +500,8 @@ def main() -> int:
472500
print(f"wrapper_root: {using_wrapper_root}")
473501
print(f"index_name: {index_name}")
474502
print(f"base_url: {base_url}")
503+
if used_fallback_port:
504+
print(f"requested_port:{args.http_port} unavailable, using {http_port}")
475505
print(f"k: {args.k}")
476506
print(f"ef_search: {args.ef_search}")
477507
print(f"warmup_runs: {args.warmup_runs}")

bindings/python/src/arcadedb_embedded/async_executor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def query(
376376
Execute async query with callback for each result.
377377
378378
Args:
379-
language: Query language ("sql", "cypher", etc.)
379+
language: Query language ("sql", "opencypher", etc.)
380380
query_text: Query string
381381
callback: Result callback, receives each ResultSet row
382382
**params: Query parameters
@@ -425,7 +425,7 @@ def command(
425425
Execute async command with optional callback.
426426
427427
Args:
428-
language: Command language ("sql", "cypher", etc.)
428+
language: Command language ("sql", "opencypher", etc.)
429429
command_text: Command string
430430
callback: Optional result callback
431431
**params: Command parameters

0 commit comments

Comments
 (0)