Skip to content

Commit b581806

Browse files
committed
fix: improve Docker build scripts and clean up example code
1 parent 2a747a3 commit b581806

3 files changed

Lines changed: 8 additions & 186 deletions

File tree

bindings/python/Dockerfile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ RUN echo "🗑️ Removing excluded JARs..." && \
8080
RUN echo "🔍 Analyzing JARs with jdeps..." && \
8181
JMODS_DIR="${JAVA_HOME}/jmods" && \
8282
if [ ! -d "$JMODS_DIR" ]; then JMODS_DIR="${JAVA_HOME}/lib/jmods"; fi && \
83-
DETECTED_MODULES=$(find /build/jars -name "*.jar" | grep -v "jboss" | grep -v "wildfly" | grep -v "smallrye" | xargs jdeps --print-module-deps --ignore-missing-deps --multi-release 25 | tr ',' '\n' | sed 's/^ *//;s/ *$//' | grep -E '^[a-zA-Z0-9_.]+$' | sort -u | paste -sd "," -) && \
83+
DETECTED_MODULES=$(find /build/jars -name "*.jar" | grep -v "jboss" | grep -v "wildfly" | grep -v "smallrye" | xargs jdeps --print-module-deps --ignore-missing-deps --multi-release 25 2>&1 | tr ',' '\n' | sed 's/^ *//;s/ *$//' | grep -E '^[a-zA-Z0-9_.]+$' | sort -u | paste -sd "," -) && \
8484
if [ -d "$JMODS_DIR" ]; then \
8585
AVAILABLE_MODULES=$(find "$JMODS_DIR" -name "*.jmod" -printf "%f\n" | sed 's/\.jmod$//' | sort -u | paste -sd "|" -) ; \
8686
FILTERED_MODULES=$(echo "${DETECTED_MODULES}" | tr ',' '\n' | sed '/^$/d' | grep -E "^(${AVAILABLE_MODULES})$" | sort -u | paste -sd "," -) ; \

bindings/python/build.sh

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,6 @@ print_usage() {
5454
echo " Directory containing ArcadeDB JARs to embed"
5555
echo " If omitted, JARs are pulled from arcadedata/arcadedb:<version>"
5656
echo ""
57-
echo "PYTHON_VERSION:"
58-
echo " Python version for wheel (default: 3.12)"
59-
echo " Examples: 3.10, 3.11, 3.12, 3.13, 3.14"
60-
echo ""
61-
echo "JAR_LIB_DIR (optional):"
62-
echo " Directory containing ArcadeDB JARs to embed"
63-
echo " If omitted, JARs are pulled from arcadedata/arcadedb:<version>"
64-
echo ""
65-
echo "PYTHON_VERSION:"
66-
echo " Python version for wheel (default: 3.12)"
67-
echo " Examples: 3.10, 3.11, 3.12, 3.13, 3.14"
68-
echo ""
69-
echo "JAR_LIB_DIR (optional):"
70-
echo " Directory containing ArcadeDB JARs to embed"
71-
echo " If omitted, JARs are pulled from arcadedata/arcadedb:<version>"
72-
echo ""
7357
echo "Build Methods:"
7458
echo " Native: macOS builds natively on its platform"
7559
echo " Docker: Linux uses Docker for manylinux compliance"
@@ -149,7 +133,6 @@ echo ""
149133
LOCAL_JARS_DIR="$SCRIPT_DIR/local-jars/lib"
150134
USE_LOCAL_JARS_ARG=""
151135
LOCAL_JARS_HASH_ARG=""
152-
DOCKER_CACHE_ARGS=""
153136
JAR_SOURCE_DESC="ArcadeDB image"
154137
mkdir -p "$LOCAL_JARS_DIR"
155138

@@ -181,7 +164,6 @@ if [[ -n "$JAR_LIB_DIR" ]]; then
181164
USE_LOCAL_JARS_ARG="--build-arg USE_LOCAL_JARS=1"
182165
LOCAL_JARS_HASH=$(find "$LOCAL_JARS_DIR" -maxdepth 1 -name "*.jar" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | awk '{print $1}')
183166
LOCAL_JARS_HASH_ARG="--build-arg LOCAL_JARS_HASH=${LOCAL_JARS_HASH}"
184-
DOCKER_CACHE_ARGS="--no-cache"
185167
else
186168
echo -e "${CYAN}📦 Using JARs from ArcadeDB image (no JAR_LIB_DIR provided)${NC}"
187169
fi
@@ -283,7 +265,6 @@ else
283265
echo -e "${CYAN}📦 Building Docker image...${NC}"
284266

285267
docker build \
286-
$DOCKER_CACHE_ARGS \
287268
--pull \
288269
--platform "$DOCKER_PLATFORM" \
289270
--build-arg PYTHON_VERSION="$PYTHON_VERSION" \
@@ -302,7 +283,6 @@ else
302283
# Run tests
303284
echo -e "${CYAN}🧪 Running tests in Docker...${NC}"
304285
docker build \
305-
$DOCKER_CACHE_ARGS \
306286
--platform "$DOCKER_PLATFORM" \
307287
--build-arg PYTHON_VERSION="$PYTHON_VERSION" \
308288
--build-arg PACKAGE_NAME="$PACKAGE_NAME" \
@@ -336,23 +316,26 @@ else
336316

337317
if [[ -n "$JAR_LIB_DIR" ]]; then
338318
echo -e "${CYAN}🔎 Verifying embedded local integration JAR...${NC}"
339-
python3 - << 'PY'
319+
ARCADEDB_VERSION="$DOCKER_TAG" python3 - << 'PY'
340320
import hashlib
321+
import os
341322
import sys
342323
import zipfile
343324
from pathlib import Path
344325
326+
ARCADEDB_VERSION = os.environ["ARCADEDB_VERSION"]
345327
wheel = sorted(Path("dist").glob("arcadedb_embedded-*.whl"))[-1]
346-
local_jar = Path("local-jars/lib/arcadedb-integration-26.4.1-SNAPSHOT.jar")
328+
local_jar_name = f"arcadedb-integration-{ARCADEDB_VERSION}.jar"
329+
local_jar = Path(f"local-jars/lib/{local_jar_name}")
347330
348331
if not local_jar.exists():
349332
print(f"❌ Local integration JAR not found: {local_jar}", file=sys.stderr)
350333
sys.exit(1)
351334
352335
with zipfile.ZipFile(wheel) as zf:
353-
matches = [name for name in zf.namelist() if name.endswith("arcadedb-integration-26.4.1-SNAPSHOT.jar")]
336+
matches = [name for name in zf.namelist() if name.endswith(local_jar_name)]
354337
if not matches:
355-
print("❌ Embedded integration JAR not found in wheel", file=sys.stderr)
338+
print(f"❌ Embedded integration JAR ({local_jar_name}) not found in wheel", file=sys.stderr)
356339
sys.exit(1)
357340
wheel_bytes = zf.read(matches[0])
358341

bindings/python/examples/02_social_network_graph.py

Lines changed: 0 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -828,167 +828,6 @@ def demonstrate_gremlin_queries(db):
828828
print(f" 🌐 {name} from {city}")
829829
print(f" ⏱️ Time: {time.time() - query_start:.3f}s")
830830

831-
print(f" ⏱️ OpenCypher section: {time.time() - section_start:.3f}s")
832-
print("\n 💡 OpenCypher features demonstrated:")
833-
print(" • Pattern matching with MATCH")
834-
print(" • Filtering with WHERE")
835-
print(" • DISTINCT for deduplication")
836-
print(" • Aggregations with count()")
837-
print(" • Variable-length paths with repeat()")
838-
print(" • Sorting with order()")
839-
840-
except Exception as e:
841-
print(f" ❌ Error in Gremlin queries: {e}")
842-
print(" 💡 Note: Gremlin support depends on your ArcadeDB build")
843-
import traceback
844-
845-
traceback.print_exc()
846-
847-
848-
def demonstrate_gremlin_queries(db):
849-
"""Demonstrate graph queries using Gremlin traversal language"""
850-
print("\n 🎯 Gremlin Queries (matching Cypher functionality):")
851-
852-
section_start = time.time()
853-
854-
try:
855-
# 1. Find all friends of Alice using Gremlin
856-
print("\n 1️⃣ Find all friends of Alice (Gremlin):")
857-
query_start = time.time()
858-
result = db.query(
859-
"gremlin",
860-
"""
861-
g.V().hasLabel('Person').has('name', 'Alice Johnson')
862-
.out('FRIEND_OF')
863-
.project('name', 'city')
864-
.by('name')
865-
.by('city')
866-
.order().by(select('name'))
867-
""",
868-
)
869-
870-
for row in result:
871-
name = row.get("name")
872-
city = row.get("city")
873-
print(f" 👥 {name} from {city}")
874-
print(f" ⏱️ Time: {time.time() - query_start:.3f}s")
875-
876-
# 2. Find friends of friends using Gremlin
877-
print("\n 2️⃣ Find friends of friends of Alice (Gremlin):")
878-
query_start = time.time()
879-
result = db.query(
880-
"gremlin",
881-
"""
882-
g.V().hasLabel('Person').has('name', 'Alice Johnson')
883-
.out('FRIEND_OF').as('friend')
884-
.out('FRIEND_OF').as('fof')
885-
.where(values('name').is(neq('Alice Johnson')))
886-
.select('fof', 'friend')
887-
.by('name')
888-
.by('name')
889-
.order().by(select('fof'))
890-
""",
891-
)
892-
893-
for row in result:
894-
name = row.get("fof")
895-
through = row.get("friend")
896-
print(f" 🔗 {name} (through {through})")
897-
print(f" ⏱️ Time: {time.time() - query_start:.3f}s")
898-
899-
# 3. Find mutual friends using Gremlin
900-
print("\n 3️⃣ Find mutual friends between Alice and Bob (Gremlin):")
901-
query_start = time.time()
902-
result = db.query(
903-
"gremlin",
904-
"""
905-
g.V().hasLabel('Person').has('name', 'Alice Johnson')
906-
.out('FRIEND_OF').as('mutual')
907-
.in('FRIEND_OF').has('name', 'Bob Smith')
908-
.select('mutual')
909-
.values('name')
910-
.order()
911-
""",
912-
)
913-
914-
mutual_friends = list(result)
915-
if mutual_friends:
916-
for row in mutual_friends:
917-
print(f" 🤝 {row.get('result')}")
918-
else:
919-
print(" ℹ️ No mutual friends found")
920-
print(f" ⏱️ Time: {time.time() - query_start:.3f}s")
921-
922-
# 4. Find close friendships using Gremlin
923-
print("\n 4️⃣ Find close friendships (Gremlin):")
924-
query_start = time.time()
925-
result = db.query(
926-
"gremlin",
927-
"""
928-
g.V().hasLabel('Person').as('p1')
929-
.outE('FRIEND_OF').has('closeness', 'close').as('edge')
930-
.inV().as('p2')
931-
.select('p1', 'p2', 'edge')
932-
.by('name')
933-
.by('name')
934-
.by('since')
935-
.order().by(select('edge'))
936-
""",
937-
)
938-
939-
for row in result:
940-
person1 = row.get("p1")
941-
person2 = row.get("p2")
942-
since = row.get("edge")
943-
print(f" 💙 {person1}{person2} (since {since})")
944-
print(f" ⏱️ Time: {time.time() - query_start:.3f}s")
945-
946-
# 5. Count friends per person using Gremlin
947-
print("\n 5️⃣ Count friends per person (Gremlin aggregation):")
948-
query_start = time.time()
949-
result = db.query(
950-
"gremlin",
951-
"""
952-
g.V().hasLabel('Person')
953-
.project('name', 'friend_count')
954-
.by('name')
955-
.by(out('FRIEND_OF').count())
956-
.order()
957-
.by(select('friend_count'), desc)
958-
.by(select('name'))
959-
""",
960-
)
961-
962-
for row in result:
963-
name = row.get("name")
964-
count = row.get("friend_count")
965-
print(f" • {name}: {count} friends")
966-
print(f" ⏱️ Time: {time.time() - query_start:.3f}s")
967-
968-
# 6. Find variable length paths using Gremlin
969-
print("\n 6️⃣ Find connections within 3 steps from Alice (Gremlin):")
970-
query_start = time.time()
971-
result = db.query(
972-
"gremlin",
973-
"""
974-
g.V().hasLabel('Person').has('name', 'Alice Johnson')
975-
.repeat(out('FRIEND_OF').simplePath())
976-
.times(3).emit()
977-
.where(values('name').is(neq('Alice Johnson')))
978-
.dedup()
979-
.project('name', 'city')
980-
.by('name')
981-
.by('city')
982-
.order().by(select('name'))
983-
""",
984-
)
985-
986-
for row in result:
987-
name = row.get("name")
988-
city = row.get("city")
989-
print(f" 🌐 {name} from {city}")
990-
print(f" ⏱️ Time: {time.time() - query_start:.3f}s")
991-
992831
print(f" ⏱️ OpenCypher section: {time.time() - section_start:.3f}s")
993832
print("\n 💡 OpenCypher features demonstrated:")
994833
print(" • Pattern matching with MATCH")

0 commit comments

Comments
 (0)