Add civit model pull ability

This commit is contained in:
2025-09-20 12:21:31 +07:00
parent 991d655756
commit 88d40c0d99

View File

@@ -340,7 +340,7 @@ class ModelPackageSubRepository:
image_name, image_extension = str(file).rsplit('.', maxsplit=1)
ckpt = candidate['filename']
ckpt_name, ckpt_extension = str(ckpt).rsplit('.', maxsplit=1)
client.download_file(url=preview, path=package_path / 'files' / (ckpt_name + image_extension))
client.download_file(url=preview, path=package_path / 'files' / (ckpt_name + '.' + image_extension))
os.makedirs(package_path / 'images')
print('Pulling thumbnails...')
@@ -349,12 +349,6 @@ class ModelPackageSubRepository:
client.download_file(url=image, path=package_path / 'images' / file)
package = ModelPackage(package_path, [], package_info)
print('Collections for package:')
print(f' {'N':<{2}} {'version':<{10}} {'type':<{10}} {'release_date':<{25}}'
f' {'lineage':<{10}} {'quant':<{5}} {'size':<{10}} ')
print(
f' {'N':<{2}} {candidate['version']:<{10}} {candidate['package_type']:<{10}} {candidate['release_date']:<{25}}'
f' {candidate['lineage']:<{10}} {candidate['quantisation']:<{5}} {format_bytes(candidate['size_bytes']):<{10}} ')
self.packages[package.uuid] = package
@@ -362,5 +356,14 @@ class ModelPackageSubRepository:
if collection: self.add_package_to_collection(package.name, collection, category, internal=internal)
pulled.append(package)
for package in pulled: self._add_package_to_collections_interactive(package)
for package in pulled:
print('Collections for package:')
print(f' {'N':<{2}} {'version':<{10}} {'type':<{10}} {'release_date':<{25}}'
f' {'lineage':<{10}} {'quant':<{5}} {'size':<{10}} ')
# TODO fix it
print(
f' {'N':<{2}} {candidate['version']:<{10}} {candidate['package_type']:<{10}} {candidate['release_date']:<{25}}'
f' {candidate['lineage']:<{10}} {candidate['quantisation']:<{5}} {format_bytes(candidate['size_bytes']):<{10}} ')
self._add_package_to_collections_interactive(package)