AILIXIR Bot commited on
Commit
0ad5edd
·
1 Parent(s): 158e6ba

Auto-sync: 8b4452f837d121e610ec0474181890e00d7f1bd2

Browse files
.env CHANGED
@@ -126,3 +126,19 @@ CLOUDINARY_CLOUD_NAME=dummy_cloud
126
  CLOUDINARY_API_KEY=dummy_key
127
  CLOUDINARY_API_SECRET=dummy_secret
128
  QUEUE_CONNECTION=sync
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  CLOUDINARY_API_KEY=dummy_key
127
  CLOUDINARY_API_SECRET=dummy_secret
128
  QUEUE_CONNECTION=sync
129
+ RUN_MODE=hf
130
+ APP_KEY=base64:T/MgQZht16genNJN3aZ5flCuvfe7Zfs4yFhuAFO2itU=
131
+ AI_INTEGRATION_ROUTES_ENABLED=true
132
+ APP_URL=https://RottenShadow-ailixir-api.hf.space
133
+ APP_DEBUG=true
134
+ ADMET_AI_URL=https://shdwRow-ailixir-admet.hf.space
135
+ CHEMICAL_AI_URL=https://RottenShadow-ailixir-chemical-rag.hf.space
136
+ DRUG_REPURPOSING_URL=https://RottenShadow-ailixir-drug-repurposing.hf.space
137
+ GENERATION_SERVICE_URL=https://shdwRow-ailixir-generation.hf.space
138
+ GOOGLE_CLIENT_ID=1057187818132-kbb9b483o5j3aoibk7oibo19q7nge01l.apps.googleusercontent.com
139
+ GOOGLE_CLIENT_SECRET=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
140
+ GOOGLE_REDIRECT_URI=https://RottenShadow-ailixir-api.hf.space/api/user/auth/google
141
+ CLOUDINARY_CLOUD_NAME=dummy_cloud
142
+ CLOUDINARY_API_KEY=dummy_key
143
+ CLOUDINARY_API_SECRET=dummy_secret
144
+ QUEUE_CONNECTION=sync
.github/workflows/hf-integration-test.yml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: HF Deployment Tests
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ schedule:
6
+ - cron: "0 6 * * *"
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ timeout-minutes: 30
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.11"
21
+ cache: pip
22
+
23
+ - name: Install dependencies
24
+ run: |
25
+ pip install -r requirements.txt
26
+
27
+ - name: Run Python tests against HF deployment
28
+ env:
29
+ BASE_URL: https://RottenShadow-ailixir-api.hf.space/api
30
+ TEST_EMAIL: salehyasmeen080@gmail.com
31
+ TEST_PASSWORD: "123456789"
32
+ TEST_NAME: yasmeen564
33
+ REDIS_HOST: localhost
34
+ REDIS_PORT: 6379
35
+ run: |
36
+ python -m pytest tests/ -v --tb=short --junitxml=junit.xml -m "not slow"
37
+
38
+ - name: Upload test results
39
+ uses: actions/upload-artifact@v4
40
+ if: always()
41
+ with:
42
+ name: hf-test-results
43
+ path: junit.xml
44
+
45
+ - name: Test Summary
46
+ uses: test-summary/action@v2
47
+ if: always()
48
+ with:
49
+ paths: "junit.xml"
.github/workflows/sync-hf-all.yml CHANGED
@@ -15,7 +15,7 @@ name: Sync to Hugging Face Spaces
15
 
16
  on:
17
  push:
18
- branches: [main]
19
  workflow_dispatch:
20
 
21
  jobs:
@@ -103,7 +103,6 @@ jobs:
103
  - uses: actions/checkout@v4
104
  with:
105
  fetch-depth: 0
106
- lfs: true
107
  - name: Install git-xet for binary file support
108
  run: |
109
  curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/huggingface/xet-core/refs/heads/main/git_xet/install.sh | sh
@@ -160,7 +159,24 @@ jobs:
160
  - uses: actions/checkout@v4
161
  with:
162
  fetch-depth: 0
163
- lfs: true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  - name: Install git-xet for binary file support
165
  run: |
166
  curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/huggingface/xet-core/refs/heads/main/git_xet/install.sh | sh
 
15
 
16
  on:
17
  push:
18
+ branches: [main, feature/hugging-face-deploy]
19
  workflow_dispatch:
20
 
21
  jobs:
 
103
  - uses: actions/checkout@v4
104
  with:
105
  fetch-depth: 0
 
106
  - name: Install git-xet for binary file support
107
  run: |
108
  curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/huggingface/xet-core/refs/heads/main/git_xet/install.sh | sh
 
159
  - uses: actions/checkout@v4
160
  with:
161
  fetch-depth: 0
162
+ lfs: false
163
+ - uses: actions/cache@v4
164
+ id: lfs-cache
165
+ with:
166
+ path: .lfs-cache
167
+ key: lfs-generation-${{ hashFiles('ai_apps/generation/bundle/models/**') }}
168
+ restore-keys: lfs-generation-
169
+ - name: Pull LFS objects (cached)
170
+ run: |
171
+ git lfs install
172
+ if [ -d .lfs-cache ]; then
173
+ mkdir -p .git/lfs/objects
174
+ rsync -a .lfs-cache/ .git/lfs/objects/
175
+ fi
176
+ git lfs pull
177
+ mkdir -p .lfs-cache
178
+ rsync -a .git/lfs/objects/ .lfs-cache/
179
+ git lfs checkout
180
  - name: Install git-xet for binary file support
181
  run: |
182
  curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/huggingface/xet-core/refs/heads/main/git_xet/install.sh | sh
app/Http/Controllers/Api/AiServicesIntegrationController.php CHANGED
@@ -21,6 +21,7 @@ class AiServicesIntegrationController extends Controller
21
 
22
  foreach ($checks as $name => $baseUrl) {
23
  $results[$name] = $this->probeHealth($baseUrl);
 
24
  }
25
 
26
  $allHealthy = collect($results)->every(
@@ -63,8 +64,9 @@ class AiServicesIntegrationController extends Controller
63
  {
64
  $baseUrl = rtrim((string) config('services.drug_repurposing.url'), '/');
65
 
66
- $health = Http::timeout(60)->get("{$baseUrl}/health");
67
- $modelStatus = Http::timeout(60)->get("{$baseUrl}/api/v1/model-status");
 
68
 
69
  $success = $health->successful() && $modelStatus->successful();
70
 
@@ -92,7 +94,7 @@ class AiServicesIntegrationController extends Controller
92
  }
93
 
94
  try {
95
- $response = Http::timeout(60)->get(rtrim($baseUrl, '/').'/health');
96
 
97
  return [
98
  'status' => $response->successful() ? 'healthy' : 'unhealthy',
 
21
 
22
  foreach ($checks as $name => $baseUrl) {
23
  $results[$name] = $this->probeHealth($baseUrl);
24
+ usleep(200_000);
25
  }
26
 
27
  $allHealthy = collect($results)->every(
 
64
  {
65
  $baseUrl = rtrim((string) config('services.drug_repurposing.url'), '/');
66
 
67
+ $health = Http::timeout(60)->retry(3, 500)->withUserAgent('AILIXIR-Internal/1.0')->get("{$baseUrl}/health");
68
+ usleep(200_000);
69
+ $modelStatus = Http::timeout(60)->retry(3, 500)->withUserAgent('AILIXIR-Internal/1.0')->get("{$baseUrl}/api/v1/model-status");
70
 
71
  $success = $health->successful() && $modelStatus->successful();
72
 
 
94
  }
95
 
96
  try {
97
+ $response = Http::timeout(60)->retry(3, 500)->withUserAgent('AILIXIR-Internal/1.0')->get(rtrim($baseUrl, '/').'/health');
98
 
99
  return [
100
  'status' => $response->successful() ? 'healthy' : 'unhealthy',
app/Http/Controllers/ApiDocsController.php CHANGED
@@ -29,6 +29,24 @@ class ApiDocsController extends Controller
29
  $markdown = file_get_contents($path);
30
  $content = Str::markdown($markdown);
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  return view('api-docs', compact('content'));
33
  }
34
  }
 
29
  $markdown = file_get_contents($path);
30
  $content = Str::markdown($markdown);
31
 
32
+ $tocMap = [];
33
+ preg_match_all('/-\s+\[(.+?)\]\(#(.+?)\)/', $markdown, $matches, PREG_SET_ORDER);
34
+ foreach ($matches as $m) {
35
+ $tocMap[trim($m[1])] = $m[2];
36
+ }
37
+
38
+ $content = preg_replace_callback(
39
+ '/<h([2-6])>(.*?)<\/h\1>/i',
40
+ function ($m) use ($tocMap) {
41
+ $level = $m[1];
42
+ $inner = $m[2];
43
+ $text = trim(strip_tags(html_entity_decode($inner)));
44
+ $id = $tocMap[$text] ?? Str::slug($text);
45
+ return sprintf('<h%s id="%s">%s</h%s>', $level, $id, $inner, $level);
46
+ },
47
+ $content
48
+ );
49
+
50
  return view('api-docs', compact('content'));
51
  }
52
  }
resources/views/api-docs.blade.php CHANGED
@@ -82,11 +82,26 @@
82
  .toc ul { list-style: none; padding-left: 0; }
83
  .toc li { margin-bottom: 4px; }
84
  .toc a { color: #2563eb; font-weight: 500; }
 
85
  </style>
86
  </head>
87
  <body>
88
  <div class="container">
89
  {!! $content !!}
90
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  </body>
92
  </html>
 
82
  .toc ul { list-style: none; padding-left: 0; }
83
  .toc li { margin-bottom: 4px; }
84
  .toc a { color: #2563eb; font-weight: 500; }
85
+ h2, h3, h4 { scroll-margin-top: 24px; }
86
  </style>
87
  </head>
88
  <body>
89
  <div class="container">
90
  {!! $content !!}
91
  </div>
92
+ <script>
93
+ document.addEventListener('DOMContentLoaded', function () {
94
+ document.querySelectorAll('.toc a[href^="#"]').forEach(function (link) {
95
+ link.addEventListener('click', function (e) {
96
+ e.preventDefault();
97
+ var target = document.getElementById(this.getAttribute('href').substring(1));
98
+ if (target) {
99
+ target.scrollIntoView({ behavior: 'smooth', block: 'start' });
100
+ history.pushState(null, null, this.href);
101
+ }
102
+ });
103
+ });
104
+ });
105
+ </script>
106
  </body>
107
  </html>
tests/Feature/DrugRepurposingIntegrationTest.php CHANGED
@@ -157,6 +157,7 @@ class DrugRepurposingIntegrationTest extends TestCase
157
 
158
  try {
159
  $healthy = Http::timeout(30)
 
160
  ->get("{$baseUrl}/health")
161
  ->successful();
162
  } catch (\Throwable $e) {
 
157
 
158
  try {
159
  $healthy = Http::timeout(30)
160
+ ->retry(3, 500)
161
  ->get("{$baseUrl}/health")
162
  ->successful();
163
  } catch (\Throwable $e) {
tests/test_admet.py CHANGED
@@ -3,6 +3,7 @@ Integration Tests for ADMET Service with Laravel Sanctum Authentication
3
  اختبارات التكامل لخدمة ADMET مع توثيق Laravel Sanctum
4
  """
5
 
 
6
  import pytest
7
  import requests
8
  import redis
@@ -17,21 +18,21 @@ from datetime import datetime
17
  class TestConfig:
18
  """إعدادات بيئة الاختبار"""
19
  def __init__(self):
20
- self.base_url: str = "http://127.0.0.1:8000"
21
  self.api_endpoint: str = "/api/admet/predict"
22
  self.login_endpoint: str = "/api/user/login"
23
  self.register_endpoint: str = "/api/user/register"
24
- self.redis_host: str = "localhost"
25
- self.redis_port: int = 6379
26
  self.timeout: int = 30
27
 
28
  config = TestConfig()
29
 
30
  # بيانات مستخدم اختبار
31
  TEST_USER = {
32
- "name": "Hazem Hatem",
33
- "email": "hhazm6745@gmail.com",
34
- "password": "Hazem@2005"
35
  }
36
 
37
  # تجاهل التحذير الخاص بـ PytestCollectionWarning
 
3
  اختبارات التكامل لخدمة ADMET مع توثيق Laravel Sanctum
4
  """
5
 
6
+ import os
7
  import pytest
8
  import requests
9
  import redis
 
18
  class TestConfig:
19
  """إعدادات بيئة الاختبار"""
20
  def __init__(self):
21
+ self.base_url: str = os.environ.get("BASE_URL", "http://127.0.0.1:8000")
22
  self.api_endpoint: str = "/api/admet/predict"
23
  self.login_endpoint: str = "/api/user/login"
24
  self.register_endpoint: str = "/api/user/register"
25
+ self.redis_host: str = os.environ.get("REDIS_HOST", "localhost")
26
+ self.redis_port: int = int(os.environ.get("REDIS_PORT", "6379"))
27
  self.timeout: int = 30
28
 
29
  config = TestConfig()
30
 
31
  # بيانات مستخدم اختبار
32
  TEST_USER = {
33
+ "name": os.environ.get("TEST_NAME", "Hazem Hatem"),
34
+ "email": os.environ.get("TEST_EMAIL", "hhazm6745@gmail.com"),
35
+ "password": os.environ.get("TEST_PASSWORD", "Hazem@2005")
36
  }
37
 
38
  # تجاهل التحذير الخاص بـ PytestCollectionWarning