Skip to content

Commit ff30240

Browse files
committed
Fixed pzmm_generate_requirements_json example, and updated write_json_file to fix some formatting errors
1 parent 5871f0b commit ff30240

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

examples/pzmm_generate_requirements_json.ipynb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
{
5959
"cell_type": "code",
60-
"execution_count": 2,
60+
"execution_count": null,
6161
"id": "1df8e5d3-c62e-4c35-993c-765a48d25444",
6262
"metadata": {},
6363
"outputs": [],
@@ -86,16 +86,16 @@
8686
"text": [
8787
"[\n",
8888
" {\n",
89-
" \"command\": \"pip install sklearn\",\n",
89+
" \"command\": \"pip install pandas==1.5.3\",\n",
90+
" \"step\": \"install pandas\"\n",
91+
" },\n",
92+
" {\n",
93+
" \"command\": \"pip install sklearn==0.23.1\",\n",
9094
" \"step\": \"install sklearn\"\n",
9195
" },\n",
9296
" {\n",
9397
" \"command\": \"pip install numpy==1.23.5\",\n",
9498
" \"step\": \"install numpy\"\n",
95-
" },\n",
96-
" {\n",
97-
" \"command\": \"pip install pandas==1.5.3\",\n",
98-
" \"step\": \"install pandas\"\n",
9999
" }\n",
100100
"]\n"
101101
]
@@ -118,7 +118,7 @@
118118
},
119119
{
120120
"cell_type": "code",
121-
"execution_count": 4,
121+
"execution_count": 6,
122122
"id": "49721dc9-38e2-4d63-86e1-6555b364f4d6",
123123
"metadata": {},
124124
"outputs": [
@@ -128,27 +128,27 @@
128128
"text": [
129129
"[\n",
130130
" {\n",
131-
" \"command\": \"pip install scikit-learn==1.2.0\",\n",
131+
" \"command\": \"pip install pandas==1.5.3\",\n",
132+
" \"step\": \"install pandas\"\n",
133+
" },\n",
134+
" {\n",
135+
" \"command\": \"pip install scikit-learn==0.23.1\",\n",
132136
" \"step\": \"install scikit-learn\"\n",
133137
" },\n",
134138
" {\n",
135139
" \"command\": \"pip install numpy==1.23.5\",\n",
136140
" \"step\": \"install numpy\"\n",
137-
" },\n",
138-
" {\n",
139-
" \"command\": \"pip install pandas==1.5.3\",\n",
140-
" \"step\": \"install pandas\"\n",
141141
" }\n",
142142
"]\n"
143143
]
144144
}
145145
],
146146
"source": [
147-
"scikit_learn_install = {\n",
148-
" \"command\": \"pip install scikit-learn==1.2.0\",\n",
149-
" \"step\": \"install scikit-learn\"\n",
150-
"}\n",
151-
"requirements_json[0].update(scikit_learn_install)\n",
147+
"for requirement in requirements_json:\n",
148+
" if 'sklearn' in requirement['step']:\n",
149+
" requirement['command'] = requirement[\"command\"].replace('sklearn', 'scikit-learn')\n",
150+
" requirement['step'] = requirement['step'].replace('sklearn', 'scikit-learn')\n",
151+
"\n",
152152
"print(json.dumps(requirements_json, sort_keys=True, indent=4))"
153153
]
154154
},
@@ -174,9 +174,9 @@
174174
],
175175
"metadata": {
176176
"kernelspec": {
177-
"display_name": "dev-py38",
177+
"display_name": "yeehaw",
178178
"language": "python",
179-
"name": "dev-py38"
179+
"name": "python3"
180180
},
181181
"language_info": {
182182
"codemirror_mode": {

src/sasctl/pzmm/write_json_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ def create_requirements_json(
16321632
) as file:
16331633
file.write(json.dumps(json_dicts, indent=4))
16341634
else:
1635-
return {"requirements.json": json.dumps(json_dicts)}
1635+
return json_dicts
16361636

16371637
@staticmethod
16381638
def get_local_package_version(package_list: List[str]) -> List[List[str]]:

0 commit comments

Comments
 (0)