Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
c65f42b
add capability to login with username and password
Deepthi-Chand Nov 20, 2025
7806a5c
add documentation and login example
Deepthi-Chand Nov 20, 2025
5b2235c
fix tests
Deepthi-Chand Nov 20, 2025
b660ae6
update version management
Deepthi-Chand Nov 20, 2025
85cd95a
Bump SDK version to 0.3.1
github-actions[bot] Nov 20, 2025
54e8e31
Remove accidentally committed dummydistrict.csv file
Deepthi-Chand Nov 20, 2025
c3fa829
add tenacity to requirements
Deepthi-Chand Nov 20, 2025
b9b3c3e
add missing requriements
Deepthi-Chand Nov 20, 2025
849934f
resolve dependency conflicts
Deepthi-Chand Nov 20, 2025
0a82bfd
update typing_extensions
Deepthi-Chand Nov 20, 2025
7b0061c
update strawberry version
Deepthi-Chand Nov 20, 2025
5ef6dc2
update pydantic and strawberry to match torch
Deepthi-Chand Nov 20, 2025
898b3f6
update docker install system dependencies without mixing old Debian r…
Deepthi-Chand Nov 21, 2025
2c02851
send user detaisl if introspection fails
Deepthi-Chand Nov 25, 2025
8111795
Fix: Pass token_info dict instead of token string to get_user_roles
Deepthi-Chand Nov 25, 2025
deaa938
Add separate methods for token_info to avoid breaking middleware
Deepthi-Chand Nov 27, 2025
5da0eb6
Add Django JWT authentication support in middleware
Deepthi-Chand Nov 27, 2025
ca39355
Consolidate KeycloakManager to single file in api/utils/keycloak_util…
Deepthi-Chand Nov 27, 2025
18fe616
Fix authentication to handle Django JWT tokens without decoding as Ke…
Deepthi-Chand Nov 27, 2025
b0d2e1b
add ability to login as service account
Deepthi-Chand Nov 27, 2025
682b82b
Fix AI model URL bug and update SDK documentation
Deepthi-Chand Nov 27, 2025
d426277
Bump SDK version to 0.3.2
github-actions[bot] Nov 27, 2025
bacdceb
add few sdk tests
Deepthi-Chand Nov 27, 2025
c5cf62d
dont sync organizations form keycloak
Deepthi-Chand Nov 27, 2025
6c69ce3
return empty org at the time of authentication
Deepthi-Chand Nov 27, 2025
a229a5e
fix tests
Deepthi-Chand Nov 27, 2025
290f13c
fix typo on test
Deepthi-Chand Nov 27, 2025
4d0f09d
Bump SDK version to 0.3.3
github-actions[bot] Nov 27, 2025
145f530
fix aimodels list_all query
Deepthi-Chand Nov 28, 2025
aeb21bb
generate new unique name if name or description not passed
Deepthi-Chand Nov 28, 2025
78a29b4
remove uuid from aimodel urls
Deepthi-Chand Dec 1, 2025
b423650
load env variables on run time
Deepthi-Chand Dec 23, 2025
fa76e4c
update user kc id if user with email already exists
Deepthi-Chand Dec 23, 2025
32c5be6
add updated api model mutations
Deepthi-Chand Dec 23, 2025
c1ccddd
accept list of ids instead of names
Deepthi-Chand Dec 24, 2025
7396f9f
add lifecycle stage to aimodel
Deepthi-Chand Dec 26, 2025
9b32577
update sdk to reflect new aimodel schema
Deepthi-Chand Dec 29, 2025
42c2e97
Bump SDK version to 0.4.0
github-actions[bot] Dec 29, 2025
8dc9449
update ai model elastic document
Deepthi-Chand Dec 30, 2025
df53a0d
add provider specific fields to enable api based access via these pro…
Deepthi-Chand Dec 30, 2025
3512b4c
update aimodel document and search api
Deepthi-Chand Dec 31, 2025
215d685
Bump SDK version to 0.4.1
github-actions[bot] Jan 5, 2026
878847c
use primary version always when calling call_model
Deepthi-Chand Jan 5, 2026
0cb6fc6
add expample template and support model_id replacement
Deepthi-Chand Jan 5, 2026
0767069
check for content type in audit response
Deepthi-Chand Jan 5, 2026
bca505a
change ai model api call to synchronous call
Deepthi-Chand Jan 6, 2026
45315f3
add sector client to sdk
Deepthi-Chand Jan 6, 2026
05ce67e
Bump SDK version to 0.4.2
github-actions[bot] Jan 6, 2026
44e975d
add sectors and geographies to aimodel in sdk
Deepthi-Chand Jan 6, 2026
a5d2440
Bump SDK version to 0.4.3
github-actions[bot] Jan 6, 2026
c123f5a
add aimodel count to sector type
Deepthi-Chand Jan 7, 2026
d32f99f
Bump SDK version to 0.4.4
github-actions[bot] Jan 7, 2026
65707d9
add prompt dataset type as child type of dataset
Deepthi-Chand Jan 12, 2026
451d403
add enums to prompt metadata options
Deepthi-Chand Jan 12, 2026
5013d88
fix prompt dataset update permission check
Deepthi-Chand Jan 12, 2026
fa9abcc
update language enum
Deepthi-Chand Jan 12, 2026
c37dc81
change dataset_type field to keyword field
Deepthi-Chand Jan 13, 2026
c770b7a
move prompt file specific details to separate model
Deepthi-Chand Jan 13, 2026
3757cf7
handle null values in indexing data
Deepthi-Chand Jan 13, 2026
7723dc2
retrun TypePromptResourceDetails instead of json
Deepthi-Chand Jan 13, 2026
b589e8b
move TypePromptResourceDetails to separate file to fix circular depen…
Deepthi-Chand Jan 13, 2026
2cf75d0
add emum query
Deepthi-Chand Jan 13, 2026
afcdf0c
add purpose to prompt metadata
Deepthi-Chand Jan 14, 2026
b4e7d4d
add prompt api to sdk
Deepthi-Chand Jan 14, 2026
8f381b6
Bump SDK version to 0.4.5
github-actions[bot] Jan 14, 2026
144a611
Bump SDK version to 0.4.7
github-actions[bot] Jan 14, 2026
e9b92ef
fix query to fetch prompt datasets
Deepthi-Chand Jan 14, 2026
85f6e5a
fix dataset queries
Deepthi-Chand Jan 14, 2026
8d451c9
Bump SDK version to 0.4.8
github-actions[bot] Jan 14, 2026
25bfa0d
use direct filters and pagination for datasets query
Deepthi-Chand Jan 14, 2026
89c8ea0
revert dataset query changes
Deepthi-Chand Jan 14, 2026
14c27f9
try strawberry.field instead of strawberry_django.field
Deepthi-Chand Jan 14, 2026
a2e26a4
add ability to include published datasets in datasets query
Deepthi-Chand Jan 14, 2026
4d92cea
Include public datasets if requested before filters/pagination
Deepthi-Chand Jan 14, 2026
b44e886
Bump SDK version to 0.4.9
github-actions[bot] Jan 14, 2026
700dc77
fix datasets query ti include variable passed
Deepthi-Chand Jan 14, 2026
b912828
Bump SDK version to 0.4.10
github-actions[bot] Jan 14, 2026
3724fd7
fix dataset query in sdk
Deepthi-Chand Jan 14, 2026
b52f523
Bump SDK version to 0.4.11
github-actions[bot] Jan 14, 2026
4a24cbd
fix dataset query in sdk
Deepthi-Chand Jan 14, 2026
b486be6
Bump SDK version to 0.4.12
github-actions[bot] Jan 14, 2026
fe31075
fix tests
Deepthi-Chand Jan 14, 2026
5e083c3
remove username from queries
Deepthi-Chand Jan 14, 2026
2b86b04
Bump SDK version to 0.4.13
github-actions[bot] Jan 14, 2026
60131ff
add more org details on userinfo api
Deepthi-Chand Jan 19, 2026
7cf48a1
remove invalid attributes
Deepthi-Chand Jan 19, 2026
0065b0c
correct typo in attributes
Deepthi-Chand Jan 19, 2026
3ee95ea
fix org logo field return in user info api
Deepthi-Chand Jan 19, 2026
9bd86a3
add support to call model with a specific version
Deepthi-Chand Jan 19, 2026
4bdffdf
Bump SDK version to 0.4.14
github-actions[bot] Jan 19, 2026
062299f
add auditer management apis and auditor client in sdk
Deepthi-Chand Jan 22, 2026
ebb7104
Bump SDK version to 0.4.15
github-actions[bot] Jan 22, 2026
c88e806
add whitelisting feature for ratelimiting
Deepthi-Chand Jan 30, 2026
b9467ae
make json fields in aimodel nullable
Deepthi-Chand Feb 6, 2026
8d54f97
make json fields in aimodel nullable
Deepthi-Chand Feb 6, 2026
be13c13
make nullable fields optional in type definitions
Deepthi-Chand Feb 9, 2026
6e308d8
dont return public models if user is authenticated
Deepthi-Chand Feb 10, 2026
ebc2b39
add unique number to slug to avoid conflicts
Deepthi-Chand Feb 10, 2026
b36245f
update sdk client to accept headers
Deepthi-Chand Feb 10, 2026
d921332
Bump SDK version to 0.4.16
github-actions[bot] Feb 10, 2026
e7f45a1
add fallback to fetch org by id if slug not present
Deepthi-Chand Feb 10, 2026
3ea4238
add domain to aimodel
Deepthi-Chand Feb 10, 2026
8ff0f43
Bump SDK version to 0.4.17
github-actions[bot] Feb 10, 2026
f593d47
fix aimodel endpoint in sdk
Deepthi-Chand Feb 11, 2026
e06c740
Bump SDK version to 0.4.18
github-actions[bot] Feb 11, 2026
2cf1312
fix sdk test
Deepthi-Chand Feb 11, 2026
e89b46d
Bump SDK version to 0.4.19
github-actions[bot] Feb 11, 2026
34893bd
add slug to user info
Deepthi-Chand Feb 11, 2026
1823c30
fix: agg accessed before initialization
Deepthi-Chand Feb 11, 2026
fdfc078
add aimodel signals to update index
Deepthi-Chand Feb 16, 2026
2394980
add collaborative document, views and update signals
Deepthi-Chand Feb 16, 2026
ffc5b86
add collaborative to unfied search
Deepthi-Chand Feb 16, 2026
a60f427
add collborative specific fields to serializer
Deepthi-Chand Feb 16, 2026
585da03
add dataset count to collaborative document
Deepthi-Chand Feb 16, 2026
1aefe82
add dataset count to collaborative document
Deepthi-Chand Feb 16, 2026
76dd033
proces profile pic before indexing
Deepthi-Chand Feb 16, 2026
0bdfd01
remove base publisher document
Deepthi-Chand Feb 16, 2026
13f101d
use decorators to index publishers
Deepthi-Chand Feb 16, 2026
7d9cab4
update normalization for publisher documents
Deepthi-Chand Feb 16, 2026
6cfbe79
add caching to geography queries
Deepthi-Chand Feb 23, 2026
5c20e6e
add caching to stats query
Deepthi-Chand Feb 23, 2026
4ecef7a
add caching to aimodel detail
Deepthi-Chand Feb 23, 2026
dacb5df
add caching to role query
Deepthi-Chand Feb 23, 2026
bfc2ecb
enable cachin gin elastic queries
Deepthi-Chand Feb 23, 2026
eae7e14
add caching to all search apis
Deepthi-Chand Feb 23, 2026
f402370
cache user by kc token
Deepthi-Chand Feb 23, 2026
c223bc5
add document class to cache key
Deepthi-Chand Mar 12, 2026
a8ee340
Merge branch 'main' into dev
Deepthi-Chand Mar 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions .github/workflows/publish-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -35,13 +36,30 @@ jobs:
pip install build twine
pip install -e ".[dev]"

- name: Update version in setup.py
- name: Update version in __version__.py
run: |
sed -i "s/version=\".*\"/version=\"${{ inputs.version }}\"/" setup.py
echo '"""Version information for DataSpace SDK."""' > dataspace_sdk/__version__.py
echo "" >> dataspace_sdk/__version__.py
echo "__version__ = \"${{ inputs.version }}\"" >> dataspace_sdk/__version__.py

- name: Update version in pyproject.toml
- name: Update version in pyproject.toml (if exists)
run: |
sed -i "s/version = \".*\"/version = \"${{ inputs.version }}\"/" pyproject.toml
if [ -f pyproject.toml ]; then
sed -i "s/version = \".*\"/version = \"${{ inputs.version }}\"/" pyproject.toml
fi

- name: Commit and push version changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add dataspace_sdk/__version__.py
if [ -f pyproject.toml ]; then git add pyproject.toml; fi
git commit -m "Bump SDK version to ${{ inputs.version }}" || echo "No changes to commit"

# Get current branch name
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
echo "Pushing to branch: $BRANCH_NAME"
git push origin $BRANCH_NAME || echo "No changes to push"

- name: Run tests
run: |
Expand All @@ -65,14 +83,6 @@ jobs:
run: |
twine upload dist/*

- name: Commit version changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add setup.py pyproject.toml
git commit -m "Bump version to ${{ inputs.version }}" || echo "No changes to commit"
git push || echo "No changes to push"

- name: Create GitHub Release
uses: actions/create-release@v1
env:
Expand Down
26 changes: 12 additions & 14 deletions DataSpace/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@

from .cache_settings import *

env = environ.Env(DEBUG=(bool, False))
DEBUG = env.bool("DEBUG", default=True)
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Load .env file FIRST, before reading any env variables
env = environ.Env(DEBUG=(bool, False))
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))

DEBUG = env.bool("DEBUG", default=True)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

Expand Down Expand Up @@ -274,6 +277,9 @@
"search.documents.dataset_document": "dataset",
"search.documents.usecase_document": "usecase",
"search.documents.aimodel_document": "aimodel",
"search.documents.collaborative_document": "collaborative",
"search.documents.publisher_document.OrganizationPublisherDocument": "organization_publisher",
"search.documents.publisher_document.UserPublisherDocument": "user_publisher",
}


Expand Down Expand Up @@ -301,9 +307,7 @@

# Swagger Settings
SWAGGER_SETTINGS = {
"SECURITY_DEFINITIONS": {
"Bearer": {"type": "apiKey", "name": "Authorization", "in": "header"}
}
"SECURITY_DEFINITIONS": {"Bearer": {"type": "apiKey", "name": "Authorization", "in": "header"}}
}

# Structured Logging Configuration
Expand Down Expand Up @@ -370,17 +374,11 @@

# OpenTelemetry Sampling Configuration
OTEL_TRACES_SAMPLER = "parentbased_traceidratio"
OTEL_TRACES_SAMPLER_ARG = os.getenv(
"OTEL_TRACES_SAMPLER_ARG", "1.0"
) # Sample 100% in dev
OTEL_TRACES_SAMPLER_ARG = os.getenv("OTEL_TRACES_SAMPLER_ARG", "1.0") # Sample 100% in dev

# OpenTelemetry Metrics Configuration
OTEL_METRIC_EXPORT_INTERVAL_MILLIS = int(
os.getenv("OTEL_METRIC_EXPORT_INTERVAL_MILLIS", "30000")
)
OTEL_METRIC_EXPORT_TIMEOUT_MILLIS = int(
os.getenv("OTEL_METRIC_EXPORT_TIMEOUT_MILLIS", "30000")
)
OTEL_METRIC_EXPORT_INTERVAL_MILLIS = int(os.getenv("OTEL_METRIC_EXPORT_INTERVAL_MILLIS", "30000"))
OTEL_METRIC_EXPORT_TIMEOUT_MILLIS = int(os.getenv("OTEL_METRIC_EXPORT_TIMEOUT_MILLIS", "30000"))

# OpenTelemetry Instrumentation Configuration
OTEL_PYTHON_DJANGO_INSTRUMENT = True
Expand Down
45 changes: 40 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
FROM python:3.10
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN echo 'deb http://archive.debian.org/debian stretch main contrib non-free' >> /etc/apt/sources.list && \
apt-get update && \

# Install system dependencies
RUN apt-get update && \
apt-get autoremove -y && \
apt-get install -y libssl1.0-dev curl git nano wget && \
apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget && \
rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/partial/*
apt-get install -y \
curl \
git \
nano \
wget \
ca-certificates \
fonts-liberation \
libasound2 \
libatk1.0-0 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgdk-pixbuf-2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
lsb-release \
xdg-utils && \
rm -rf /var/lib/apt/lists/*


WORKDIR /code
Expand Down
3 changes: 2 additions & 1 deletion api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AIModelAdmin(admin.ModelAdmin):
list_filter = (
"provider",
"model_type",
"domain",
"status",
"is_public",
"is_active",
Expand All @@ -85,7 +86,7 @@ class AIModelAdmin(admin.ModelAdmin):
"Schema",
{"fields": ("input_schema", "output_schema"), "classes": ("collapse",)},
),
("Metadata", {"fields": ("tags", "metadata"), "classes": ("collapse",)}),
("Metadata", {"fields": ("tags", "domain", "metadata"), "classes": ("collapse",)}),
("Status & Visibility", {"fields": ("status", "is_public", "is_active")}),
(
"Performance Metrics",
Expand Down
34 changes: 32 additions & 2 deletions api/middleware/rate_limit.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
import logging
import os
import time
from typing import Any, Callable, Optional, cast

from django.conf import settings
from django.core.cache import cache
from django.http import HttpRequest, HttpResponse
from redis.exceptions import RedisError

logger = logging.getLogger(__name__)


def get_whitelisted_ips() -> set[str]:
"""Get the set of whitelisted IPs from settings or environment variable.

Can be configured via:
- RATE_LIMIT_WHITELIST_IPS in Django settings (list)
- RATE_LIMIT_WHITELIST_IPS environment variable (comma-separated string)
"""
# First check Django settings
whitelist = getattr(settings, "RATE_LIMIT_WHITELIST_IPS", None)
if whitelist:
return set(whitelist)

# Fall back to environment variable
env_whitelist = os.environ.get("RATE_LIMIT_WHITELIST_IPS", "")
if env_whitelist:
return {ip.strip() for ip in env_whitelist.split(",") if ip.strip()}

return set()


class HttpResponseTooManyRequests(HttpResponse):
status_code = 429


def rate_limit_middleware(
get_response: Callable[[HttpRequest], HttpResponse]
get_response: Callable[[HttpRequest], HttpResponse],
) -> Callable[[HttpRequest], HttpResponse]:
"""Rate limiting middleware that uses a simple cache-based counter."""

Expand Down Expand Up @@ -78,10 +100,18 @@ def check_rate_limit(request: HttpRequest) -> bool:
return True # Allow request on unexpected error

def middleware(request: HttpRequest) -> HttpResponse:
client_ip = get_client_ip(request)
whitelisted_ips = get_whitelisted_ips()

# Skip rate limiting for whitelisted IPs
if client_ip in whitelisted_ips:
logger.debug(f"Skipping rate limit for whitelisted IP: {client_ip}")
return get_response(request)

if not check_rate_limit(request):
logger.warning(
f"Rate limited - Method: {request.method}, "
f"Path: {request.path}, IP: {get_client_ip(request)}"
f"Path: {request.path}, IP: {client_ip}"
)
return HttpResponseTooManyRequests()

Expand Down
22 changes: 18 additions & 4 deletions api/models/AIModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
EndpointAuthType,
EndpointHTTPMethod,
HFModelClass,
PromptDomain,
)

User = get_user_model()
Expand Down Expand Up @@ -82,8 +83,6 @@ class AIModel(models.Model):
blank=True,
related_name="ai_models",
)
# API Configuration
# Endpoints are stored in separate ModelEndpoint table for flexibility

# Model Capabilities
supports_streaming = models.BooleanField(default=False)
Expand All @@ -92,19 +91,34 @@ class AIModel(models.Model):
)
supported_languages = models.JSONField(
default=list,
blank=True,
null=True,
help_text="List of supported language codes (e.g., ['en', 'es', 'fr'])",
)

# Input/Output Schema
input_schema = models.JSONField(default=dict, help_text="Expected input format and parameters")
output_schema = models.JSONField(default=dict, help_text="Expected output format")
input_schema = models.JSONField(
default=dict, blank=True, null=True, help_text="Expected input format and parameters"
)
output_schema = models.JSONField(
default=dict, blank=True, null=True, help_text="Expected output format"
)

# Metadata
tags = models.ManyToManyField("api.Tag", blank=True)
sectors = models.ManyToManyField("api.Sector", blank=True, related_name="ai_models")
geographies = models.ManyToManyField("api.Geography", blank=True, related_name="ai_models")
domain = models.CharField(
max_length=200,
choices=PromptDomain.choices,
blank=True,
null=True,
help_text="Domain or category (e.g., healthcare, education, legal)",
)
metadata = models.JSONField(
default=dict,
blank=True,
null=True,
help_text="Additional metadata (training data info, limitations, etc.)",
)

Expand Down
Loading
Loading