@@ -1608,15 +1608,13 @@ def convert_data_role(data_role: Union[str, int]) -> Union[str, int]:
16081608 conversion = 1
16091609
16101610 return conversion
1611-
1612-
16131611
16141612 @classmethod
16151613 def create_requirements_json (
16161614 cls ,
16171615 model_path : Union [str , Path , None ] = Path .cwd (),
16181616 output_path : Union [str , Path , None ] = None ,
1619- create_requirements_txt : bool = False
1617+ create_requirements_txt : bool = False ,
16201618 ) -> Union [dict , None ]:
16211619 """
16221620 Searches the model directory for Python scripts and pickle files and
@@ -1669,37 +1667,33 @@ def create_requirements_json(
16691667 missing_package_versions = [
16701668 item [0 ] for item in package_and_version if not item [1 ]
16711669 ]
1672-
1670+
16731671 IMPORT_TO_INSTALL_MAPPING = {
16741672 # Data Science & ML Core
1675- 'sklearn' : 'scikit-learn' ,
1676- 'skimage' : 'scikit-image' ,
1677- 'cv2' : 'opencv-python' ,
1678- 'PIL' : 'Pillow' ,
1679-
1673+ "sklearn" : "scikit-learn" ,
1674+ "skimage" : "scikit-image" ,
1675+ "cv2" : "opencv-python" ,
1676+ "PIL" : "Pillow" ,
16801677 # Data Formats & Parsing
1681- 'yaml' : 'PyYAML' ,
1682- 'bs4' : 'beautifulsoup4' ,
1683- 'docx' : 'python-docx' ,
1684- 'pptx' : 'python-pptx' ,
1685-
1686- # Date & Time Utilities
1687- 'dateutil' : 'python-dateutil' ,
1688-
1678+ "yaml" : "PyYAML" ,
1679+ "bs4" : "beautifulsoup4" ,
1680+ "docx" : "python-docx" ,
1681+ "pptx" : "python-pptx" ,
1682+ # Date & Time Utilities
1683+ "dateutil" : "python-dateutil" ,
16891684 # Database Connectors
1690- 'MySQLdb' : 'MySQL-python' ,
1691- 'psycopg2' : 'psycopg2-binary' ,
1692-
1685+ "MySQLdb" : "MySQL-python" ,
1686+ "psycopg2" : "psycopg2-binary" ,
16931687 # System & Platform
1694- 'win32api' : 'pywin32' ,
1695- 'win32com' : 'pywin32' ,
1696-
1688+ "win32api" : "pywin32" ,
1689+ "win32com" : "pywin32" ,
16971690 # Scientific Libraries
1698- ' Bio' : ' biopython' ,
1691+ " Bio" : " biopython" ,
16991692 }
17001693
1701- package_list = [IMPORT_TO_INSTALL_MAPPING .get (name , name ) for name in package_list ]
1702-
1694+ package_list = [
1695+ IMPORT_TO_INSTALL_MAPPING .get (name , name ) for name in package_list
1696+ ]
17031697
17041698 if create_requirements_txt :
17051699 requirements_txt = ""
@@ -1710,7 +1704,7 @@ def create_requirements_json(
17101704 for package , version in package_and_version :
17111705 if version :
17121706 requirements_txt += f"{ package } =={ version } \n "
1713-
1707+
17141708 if output_path :
17151709 with open ( # skipcq: PTC-W6004
17161710 Path (output_path ) / "requirements.txt" , "w"
@@ -1856,10 +1850,10 @@ def find_imports(file_path: Union[str, Path]) -> List[str]:
18561850 for node in ast .walk (tree ):
18571851 # Determine parent module for `from * import *` calls
18581852 if isinstance (node , ast .ImportFrom ):
1859- modules .add (node .module .split ('.' )[0 ])
1853+ modules .add (node .module .split ("." )[0 ])
18601854 elif isinstance (node , ast .Import ):
18611855 for name in node .names :
1862- modules .add (name .name .split ('.' )[0 ])
1856+ modules .add (name .name .split ("." )[0 ])
18631857
18641858 modules = list (set (modules ))
18651859 try :
0 commit comments