Hello there! I’m working with Cog and specifying a requirement like transformers[torch]==0.49.0. However, I’ve noticed that the extra package (i.e., torch) is currently being ignored.
Expected Behavior
Transformers should be installed with the specified extra packages.
Description
After some research, I found this pull request:
#2160
In versions prior to this PR, using transformers[torch]==0.49.0 would raise an error in SplitPinnedPythonRequirement:
|
func SplitPinnedPythonRequirement(requirement string) (name string, version string, findLinks []string, extraIndexURLs []string, err error) { |
|
pinnedPackageRe := regexp.MustCompile(`(?:([a-zA-Z0-9\-_]+)==([^ ]+)|--find-links=([^\s]+)|-f\s+([^\s]+)|--extra-index-url=([^\s]+))`) |
|
|
|
matches := pinnedPackageRe.FindAllStringSubmatch(requirement, -1) |
|
if matches == nil { |
|
return "", "", nil, nil, fmt.Errorf("Package %s is not in the expected format", requirement) |
|
} |
Meanwhile, pythonPackageForArch treated it as an unpinned dependency, which unintentionally but worked:
|
name, version, findLinksList, extraIndexURLs, err := SplitPinnedPythonRequirement(pkg) |
|
if err != nil { |
|
// It's not pinned, so just return the line verbatim |
|
return pkg, []string{}, []string{}, nil |
|
} |
After version 0.14.0, SplitPinnedPythonRequirement no longer raises an error, but the extra package is completely ignored:
|
// SplitPinnedPythonRequirement returns the name, version, findLinks, and extraIndexURLs from a requirements.txt line |
|
// in the form name[extras]==version [--find-links=<findLink>] [-f <findLink>] [--extra-index-url=<extraIndexURL>] |
|
func SplitPinnedPythonRequirement(requirement string) (name string, version string, findLinks []string, extraIndexURLs []string, err error) { |
|
pinnedPackageRe := regexp.MustCompile(`(?:([a-zA-Z0-9\-_]+)(\[[a-zA-Z0-9\-_,]+])?==([^ ]+)|--find-links=([^\s]+)|-f\s+([^\s]+)|--extra-index-url=([^\s]+))`) |
|
|
|
matches := pinnedPackageRe.FindAllStringSubmatch(requirement, -1) |
|
if matches == nil { |
|
return "", "", nil, nil, fmt.Errorf("Package %s is not in the expected format", requirement) |
|
} |
|
|
|
nameFound := false |
|
versionFound := false |
|
|
|
for _, match := range matches { |
|
if match[1] != "" { |
|
name = match[1] |
|
nameFound = true |
|
} |
|
|
|
if match[3] != "" { |
|
version = match[3] |
|
versionFound = true |
|
} |
|
|
|
if match[4] != "" { |
|
findLinks = append(findLinks, match[4]) |
|
} |
|
|
|
if match[5] != "" { |
|
findLinks = append(findLinks, match[5]) |
|
} |
|
|
|
if match[6] != "" { |
|
extraIndexURLs = append(extraIndexURLs, match[6]) |
|
} |
|
} |
|
|
|
if !nameFound || !versionFound { |
|
return "", "", nil, nil, fmt.Errorf("Package name or version is missing in %s", requirement) |
|
} |
|
|
|
return name, version, findLinks, extraIndexURLs, nil |
|
} |
Hello there! I’m working with Cog and specifying a requirement like transformers[torch]==0.49.0. However, I’ve noticed that the extra package (i.e., torch) is currently being ignored.
Expected Behavior
Transformers should be installed with the specified extra packages.
Description
After some research, I found this pull request:
#2160
In versions prior to this PR, using
transformers[torch]==0.49.0would raise an error inSplitPinnedPythonRequirement:cog/pkg/config/requirements.go
Lines 85 to 91 in 60017a9
Meanwhile,
pythonPackageForArchtreated it as an unpinned dependency, which unintentionally but worked:cog/pkg/config/config.go
Lines 397 to 401 in 2a0763a
After version 0.14.0,
SplitPinnedPythonRequirementno longer raises an error, but the extra package is completely ignored:cog/pkg/config/requirements.go
Lines 8 to 50 in 2a0763a