py: remove license_content from metadata heuristics and add additional license file checks

This commit is contained in:
brian khuu 2024-08-06 07:26:09 +10:00
parent d79e8e12ff
commit 928aa66a92

View File

@ -381,7 +381,6 @@ class Metadata:
use_model_card_metadata("license", "license") use_model_card_metadata("license", "license")
use_model_card_metadata("license_name", "license_name") use_model_card_metadata("license_name", "license_name")
use_model_card_metadata("license_link", "license_link") use_model_card_metadata("license_link", "license_link")
use_model_card_metadata("license_content", "license_content")
use_array_model_card_metadata("tags", "tags") use_array_model_card_metadata("tags", "tags")
use_array_model_card_metadata("tags", "pipeline_tag") use_array_model_card_metadata("tags", "pipeline_tag")
@ -436,11 +435,12 @@ class Metadata:
# Detect LICENSE file and include a copy # Detect LICENSE file and include a copy
######################################### #########################################
if metadata.license_content is None: if isinstance(metadata.license_link, str) and not (metadata.license_link.startswith("http://") or metadata.license_link.startswith("https://")):
standard_license_file_path = Path("LICENSE") if metadata.license_content is None:
if standard_license_file_path.is_file(): standard_license_file_path = Path("LICENSE")
with open(standard_license_file_path, 'r') as file: if standard_license_file_path.is_file():
metadata.license_content = file.read() with open(standard_license_file_path, 'r') as file:
metadata.license_content = file.read()
return metadata return metadata