Skip to content

Commit 8da76e6

Browse files
authored
Merge pull request #143 from sassoftware/requirementsJSON
Add in requirements.json creation feature
2 parents 6bc070d + c0526fd commit 8da76e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3683
-2124
lines changed

.github/workflows/build-test-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Black
1313
uses: psf/black@stable
1414
with:
15-
src: "./src"
15+
src: "./src ./tests"
1616

1717
test:
1818
name: "Test"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"step": "install pandas",
4+
"command": "pip install pandas==1.2.4"
5+
},
6+
{
7+
"step": "install numpy",
8+
"command": "pip install numpy==1.20.1"
9+
},
10+
{
11+
"step": "install sklearn",
12+
"command": "pip install sklearn"
13+
}
14+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"step": "install pandas",
4+
"command": "pip install pandas==1.2.4"
5+
},
6+
{
7+
"step": "install numpy",
8+
"command": "pip install numpy==1.20.1"
9+
},
10+
{
11+
"step": "install sklearn",
12+
"command": "pip install sklearn"
13+
}
14+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"step": "install pandas",
4+
"command": "pip install pandas==1.2.4"
5+
},
6+
{
7+
"step": "install numpy",
8+
"command": "pip install numpy==1.20.1"
9+
},
10+
{
11+
"step": "install sklearn",
12+
"command": "pip install sklearn"
13+
}
14+
]

examples/pzmmModelImportExample.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@
635635
},
636636
{
637637
"cell_type": "code",
638-
"execution_count": 20,
638+
"execution_count": 13,
639639
"metadata": {
640640
"Collapsed": "false"
641641
},
@@ -685,6 +685,9 @@
685685
" # Write model metadata to a json file\n",
686686
" J.writeFileMetadataJSON(modelPrefix, jPath=zipFolder)\n",
687687
"\n",
688+
" # Write out requirements.json\n",
689+
" J.createRequirementsJSON(zipFolder)\n",
690+
"\n",
688691
"for (prefix, path) in zip(modelPrefix, zipFolder):\n",
689692
" writeJSONFiles(hmeqData, predictorColumns, targetColumn, path, prefix)"
690693
]

examples/pzmmModelImportExampleReqJSON.ipynb

Lines changed: 815 additions & 0 deletions
Large diffs are not rendered by default.

src/sasctl/pzmm/importModel.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def pzmmImportModel(
121121
inputDF,
122122
targetDF,
123123
predictmethod,
124-
metrics=["EM_EVENTPROBABILITY", "EM_CLASSIFICATION"],
124+
metrics=None,
125125
projectVersion="latest",
126126
modelFileName=None,
127127
pyPath=None,
@@ -171,7 +171,7 @@ def pzmmImportModel(
171171
the format() command.
172172
For example: '{}.predict_proba({})'.
173173
metrics : string list, optional
174-
The scoring metrics for the model. The default is a set of two
174+
The scoring metrics for the model. The default is a list of two
175175
metrics: EM_EVENTPROBABILITY and EM_CLASSIFICATION.
176176
projectVersion : string, optional
177177
The project version to import the model in to on SAS Model Manager. The default value
@@ -201,6 +201,10 @@ def pzmmImportModel(
201201
Model details from an MLFlow model. This dictionary is created by the readMLModelFile function.
202202
By default None.
203203
"""
204+
# Set metrics internal to function call if no value is given
205+
if metrics is None:
206+
metrics = ["EM_EVENTPROBABILITY", "EM_CLASSIFICATION"]
207+
204208
# Initialize no score code or binary H2O model flags
205209
noScoreCode = False
206210
binaryModel = False

src/sasctl/pzmm/writeScoreCode.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def writeScoreCode(
1717
modelPrefix,
1818
predictMethod,
1919
modelFileName,
20-
metrics=["EM_EVENTPROBABILITY", "EM_CLASSIFICATION"],
20+
metrics=None,
2121
pyPath=Path.cwd(),
2222
threshPrediction=None,
2323
otherVariable=False,
@@ -120,6 +120,10 @@ def writeScoreCode(
120120
pickleType : string, optional
121121
Indicator for MLFlow models, which may pickle by non-standard methods. By default 'pickle'.
122122
"""
123+
# Set metrics internal to function call if no value is given
124+
if metrics is None:
125+
metrics = ["EM_EVENTPROBABILITY", "EM_CLASSIFICATION"]
126+
123127
# Check if binary string model
124128
if binaryString is not None:
125129
isBinaryString = True
@@ -147,7 +151,7 @@ def upload_and_copy_score_resources(model, files):
147151

148152
# For SAS Viya 3.5, either return an error or return the model UUID as a string
149153
if isViya35:
150-
if model == None:
154+
if model is None:
151155
raise ValueError(
152156
"The model UUID is required for score code written for"
153157
+ " SAS Model Manager on SAS Viya 3.5."
@@ -596,6 +600,7 @@ def score{modelPrefix}({inputVarList}):
596600
model["scoreCodeType"] = "ds2MultiType"
597601
modelRepo.update_model(model)
598602

603+
@classmethod
599604
def splitStringColumn(cls, inputSeries, otherVariable):
600605
"""
601606
Splits a column of string values into a number of new variables equal

0 commit comments

Comments
 (0)