MCPcopy Index your code
hub / github.com/modelscope/modelscope / parse_args_info

Method parse_args_info

modelscope/utils/plugins.py:974–1031  ·  view source on GitHub ↗

parse arguments input info Args: args: the list of args from pip command output options: the options that parsed from system args by pip command method Returns: installed_package: generate installed package info in order to store in the f

(self, args: List[str], options)

Source from the content-addressed store, hash-verified

972 return status_code, install_args
973
974 def parse_args_info(self, args: List[str], options):
975 """
976 parse arguments input info
977 Args:
978 args: the list of args from pip command output
979 options: the options that parsed from system args by pip command method
980
981 Returns:
982 installed_package: generate installed package info in order to store in the file
983 the info includes: name, url and desc of the package
984 """
985 installed_package = []
986
987 # the case of install with requirements
988 if len(args) == 0:
989 src_dir = options.src_dir
990 requirements = options.requirements
991 for requirement in requirements:
992 package_info = {
993 'name': requirement,
994 'url': os.path.join(src_dir, requirement),
995 'desc': '',
996 'version': ''
997 }
998
999 installed_package.append(package_info)
1000
1001 def get_package_info(package_name):
1002 from pathlib import Path
1003 package_info = {
1004 'name': package_name,
1005 'url': options.index_url,
1006 'desc': ''
1007 }
1008
1009 # the case with git + http
1010 if package_name.split('.')[-1] == 'git':
1011 package_name = Path(package_name).stem
1012
1013 plugin_installed, version = self.check_plugin_installed(
1014 package_name)
1015 if plugin_installed:
1016 package_info['version'] = version
1017 package_info['name'] = package_name
1018 else:
1019 logger.warning(
1020 f'The package {package_name} is not in the lib, this might be happened'
1021 f' when installing the package with git+https method, should be ignored'
1022 )
1023 package_info['version'] = ''
1024
1025 return package_info
1026
1027 for package in args:
1028 package_info = get_package_info(package)
1029 installed_package.append(package_info)
1030
1031 return installed_package

Callers 1

install_pluginsMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected