Skip to content

Commit 6fc4160

Browse files
committed
Proper function classification (static vs class) #143
1 parent b0be540 commit 6fc4160

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/sasctl/pzmm/write_json_files.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def flatten(nestedList):
4242

4343

4444
class JSONFiles:
45-
@classmethod
46-
def writeVarJSON(cls, inputData, isInput=True, jPath=Path.cwd()):
45+
@staticmethod
46+
def writeVarJSON(inputData, isInput=True, jPath=Path.cwd()):
4747
"""
4848
Writes a variable descriptor JSON file for input or output variables, based on input data containing predictor
4949
and prediction columns.
@@ -142,9 +142,8 @@ def writeVarJSON(cls, inputData, isInput=True, jPath=Path.cwd()):
142142
)
143143
)
144144

145-
@classmethod
145+
@staticmethod
146146
def writeModelPropertiesJSON(
147-
cls,
148147
modelName,
149148
modelDesc,
150149
targetVariable,
@@ -260,8 +259,8 @@ def writeModelPropertiesJSON(
260259
)
261260
)
262261

263-
@classmethod
264-
def writeFileMetadataJSON(cls, modelPrefix, jPath=Path.cwd(), isH2OModel=False):
262+
@staticmethod
263+
def writeFileMetadataJSON(modelPrefix, jPath=Path.cwd(), isH2OModel=False):
265264
"""
266265
Writes a file metadata JSON file pointing to all relevant files.
267266
@@ -855,7 +854,8 @@ def generateROCLiftStat(
855854
)
856855
)
857856

858-
def readJSONFile(self, path):
857+
@staticmethod
858+
def readJSONFile(path):
859859
"""
860860
Reads a JSON file from a given path.
861861
@@ -873,7 +873,8 @@ def readJSONFile(self, path):
873873
with open(path) as jFile:
874874
return json.load(jFile)
875875

876-
def formatParameter(self, paramName):
876+
@staticmethod
877+
def formatParameter(paramName):
877878
"""
878879
Formats the parameter name to the JSON standard.
879880
@@ -898,7 +899,8 @@ def formatParameter(self, paramName):
898899

899900
return paramName
900901

901-
def convertDataRole(self, dataRole):
902+
@staticmethod
903+
def convertDataRole(dataRole):
902904
"""
903905
Converts the data role identifier from string to int or int to string.
904906
@@ -1010,8 +1012,8 @@ def create_requirements_json(cls, model_path=Path.cwd()):
10101012

10111013
return json_dicts
10121014

1013-
@classmethod
1014-
def get_local_package_version(cls, package_list):
1015+
@staticmethod
1016+
def get_local_package_version(package_list):
10151017
"""
10161018
Get package_name versions from the local environment.
10171019
@@ -1086,8 +1088,8 @@ def get_code_dependencies(cls, model_path=Path.cwd()):
10861088
import_info = list(set(flatten(import_info)))
10871089
return import_info
10881090

1089-
@classmethod
1090-
def find_imports(cls, file_path):
1091+
@staticmethod
1092+
def find_imports(file_path):
10911093
"""
10921094
Find import calls in provided Python code path.
10931095
@@ -1133,8 +1135,8 @@ def find_imports(cls, file_path):
11331135
except ValueError:
11341136
return modules
11351137

1136-
@classmethod
1137-
def get_pickle_file(cls, pickle_folder=Path.cwd()):
1138+
@staticmethod
1139+
def get_pickle_file(pickle_folder=Path.cwd()):
11381140
"""
11391141
Given a file path, retrieve the pickle file(s).
11401142
@@ -1177,8 +1179,8 @@ def get_pickle_dependencies(cls, pickle_file):
11771179
modules = cls.get_package_names(dumps)
11781180
return modules
11791181

1180-
@classmethod
1181-
def get_package_names(cls, stream):
1182+
@staticmethod
1183+
def get_package_names(stream):
11821184
"""
11831185
Generates a list of found `package` names from a pickle stream.
11841186
@@ -1237,8 +1239,8 @@ def get_package_names(cls, stream):
12371239
# Return the package list without any None values
12381240
return [x for x in packages if x]
12391241

1240-
@classmethod
1241-
def remove_standard_library_packages(cls, package_list):
1242+
@staticmethod
1243+
def remove_standard_library_packages(package_list):
12421244
"""
12431245
Remove any packages from the required list of installed packages that are part of the Python Standard Library.
12441246

0 commit comments

Comments
 (0)