Spaces:
Running
Running
Download app/Services/MdSimulationService.php from Ailixir-AI-Team/ailixir-api: direct link, hf CLI and curl.
- Browser
- Download file 1.99 kB
-
https://huggingface.co/spaces/Ailixir-AI-Team/ailixir-api/resolve/main/app/Services/MdSimulationService.php
- Command line
-
hf download hf://spaces/Ailixir-AI-Team/ailixir-api/app/Services/MdSimulationService.php
-
curl -L -o MdSimulationService.php https://huggingface.co/spaces/Ailixir-AI-Team/ailixir-api/resolve/main/app/Services/MdSimulationService.php
1.99 kB
| namespace App\Services; | |
| use Illuminate\Http\Client\Response; | |
| use Illuminate\Support\Facades\Http; | |
| class MdSimulationService | |
| { | |
| private string $baseUrl; | |
| private int $timeout; | |
| public function __construct() | |
| { | |
| $this->baseUrl = rtrim(config('services.md_simulation.url', 'http://protein-ligand-md:5005'), '/'); | |
| $this->timeout = (int) config('services.md_simulation.timeout', 3600); | |
| } | |
| public function submitJob(string $proteinPath, string $proteinName, string $ligandPath, string $ligandName, array $params): Response | |
| { | |
| $http = Http::timeout(120); | |
| $http = $http->attach( | |
| 'protein', | |
| fopen($proteinPath, 'r'), | |
| $proteinName | |
| ); | |
| $http = $http->attach( | |
| 'ligand', | |
| fopen($ligandPath, 'r'), | |
| $ligandName | |
| ); | |
| return $http->post($this->baseUrl.'/process', $params); | |
| } | |
| public function getJobStatus(string $remoteJobId): Response | |
| { | |
| return Http::timeout(30) | |
| ->retry(3, 1000) | |
| ->get($this->baseUrl."/status/{$remoteJobId}"); | |
| } | |
| public function runAnalysis(string $remoteJobId, array $params = []): Response | |
| { | |
| return Http::timeout($this->timeout) | |
| ->retry(3, 2000) | |
| ->post($this->baseUrl.'/analyze', array_merge($params, [ | |
| 'job_id' => $remoteJobId, | |
| ])); | |
| } | |
| public function downloadResults(string $remoteJobId): Response | |
| { | |
| return Http::timeout($this->timeout) | |
| ->retry(2, 5000) | |
| ->get($this->baseUrl."/download/{$remoteJobId}"); | |
| } | |
| public function downloadAnalysis(string $remoteJobId): Response | |
| { | |
| return Http::timeout($this->timeout) | |
| ->retry(2, 5000) | |
| ->get($this->baseUrl."/download_analysis/{$remoteJobId}"); | |
| } | |
| public function healthCheck(): Response | |
| { | |
| return Http::timeout(10)->get($this->baseUrl.'/health'); | |
| } | |
| } | |