Skip to content

Commit 4a7abfd

Browse files
BugFix: Fix permissions for downloaded files
1 parent cf029e2 commit 4a7abfd

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/Commands/DownloadModelCommand.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
use Codewithkyrian\Transformers\Models\Auto\AutoModelForCausalLM;
1010
use Codewithkyrian\Transformers\Models\Auto\AutoModelForSeq2SeqLM;
1111
use Codewithkyrian\Transformers\Models\Auto\AutoModelForSequenceClassification;
12+
use Codewithkyrian\Transformers\Pipelines\Task;
1213
use Codewithkyrian\Transformers\Transformers;
1314
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputArgument;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Input\InputOption;
1819
use Symfony\Component\Console\Output\OutputInterface;
20+
use function Codewithkyrian\Transformers\Pipelines\pipeline;
1921

2022
#[AsCommand(
2123
name: 'download-model',
@@ -63,13 +65,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6365

6466
// Download the model
6567
try {
66-
// TODO: Verify the tasks and corresponding AutoModel classes
67-
$model = match ($task) {
68-
'text-generation' => AutoModelForCausalLM::fromPretrained($model, $quantized, cacheDir: $cacheDir),
69-
'text-classification', 'sentiment-analysis' => AutoModelForSequenceClassification::fromPretrained($model, $quantized, cacheDir: $cacheDir),
70-
'translation' => AutoModelForSeq2SeqLM::fromPretrained($model, $quantized, cacheDir: $cacheDir),
71-
default => AutoModel::fromPretrained($model, $quantized, cacheDir: $cacheDir),
72-
};
68+
$task = Task::tryFrom($task);
69+
70+
if ($task != null) {
71+
pipeline($task, $model);
72+
} else {
73+
AutoModel::fromPretrained($model, $quantized, cacheDir: $cacheDir);
74+
}
75+
7376

7477
$output->writeln('✔ Model downloaded successfully.');
7578

src/Utils/Hub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public static function getFile(
120120
rename($partPath, $filePath);
121121
}
122122

123+
chmod($filePath, 0644);
124+
123125
return $filePath;
124126
} catch (GuzzleException $e) {
125127
self::handleException($e->getCode(), $remoteURL, $fatal);

0 commit comments

Comments
 (0)