|
120 | 120 | "sign up for a free account at https://console.cratedb.cloud and \n",
|
121 | 121 | "[deploy a cluster].\n",
|
122 | 122 | "\n",
|
| 123 | + "[deploy a cluster]: https://cratedb.com/docs/cloud/en/latest/tutorials/deploy/stripe.html#deploy-cluster\n" |
| 124 | + ] |
| 125 | + }, |
| 126 | + { |
| 127 | + "cell_type": "markdown", |
| 128 | + "metadata": {}, |
| 129 | + "source": [ |
123 | 130 | "To populate your environment with corresponding database access credentials,\n",
|
124 | 131 | "create an `.env` file with the following content:\n",
|
125 | 132 | "\n",
|
126 | 133 | "```env\n",
|
127 |
| - "CRATE_HOST=<your-crate-host> # set this to localhost if you're running crate locally\n", |
128 |
| - "CRATE_USER=<your-crate-user> # set this to crate if you're running crate locally\n", |
129 |
| - "CRATE_PASSWORD=<your-crate-password> # set this to \"\" if you're running crate locally\n", |
130 |
| - "CRATE_SSL=true # set this to false if you're running crate locally\n", |
| 134 | + "# use this string for a connection to CrateDB Cloud\n", |
| 135 | + "CONNECTION_STRING=crate://username:password@hostname/?ssl=true \n", |
| 136 | + "\n", |
| 137 | + "# use this string for a local connection to CrateDB\n", |
| 138 | + "# CONNECTION_STRING=crate://crate@localhost/?ssl=false \n", |
131 | 139 | "```\n",
|
132 | 140 | "\n",
|
133 | 141 | "You can find your CrateDB credentials in the [CrateDB Cloud Console].\n",
|
134 | 142 | "\n",
|
135 |
| - "[CrateDB Cloud Console]: https://cratedb.com/docs/cloud/en/latest/reference/overview.html#cluster\n", |
136 |
| - "[deploy a cluster]: https://cratedb.com/docs/cloud/en/latest/tutorials/deploy/stripe.html#deploy-cluster\n" |
| 143 | + "[CrateDB Cloud Console]: https://cratedb.com/docs/cloud/en/latest/reference/overview.html#cluster" |
| 144 | + ] |
| 145 | + }, |
| 146 | + { |
| 147 | + "cell_type": "code", |
| 148 | + "execution_count": null, |
| 149 | + "metadata": {}, |
| 150 | + "outputs": [], |
| 151 | + "source": [ |
| 152 | + "import os\n", |
| 153 | + "\n", |
| 154 | + "# For CrateDB Cloud, use:\n", |
| 155 | + "CONNECTION_STRING = os.environ.get(\n", |
| 156 | + " \"CRATEDB_CONNECTION_STRING\",\n", |
| 157 | + " \"crate://username:password@hostname/?ssl=true\",\n", |
| 158 | + ")\n", |
| 159 | + "\n", |
| 160 | + "# For an self-deployed CrateDB, e.g. via Docker, please use:\n", |
| 161 | + "# CONNECTION_STRING = os.environ.get(\n", |
| 162 | + "# \"CRATEDB_CONNECTION_STRING\",\n", |
| 163 | + "# \"crate://crate@localhost/?ssl=false\",\n", |
| 164 | + "# )" |
137 | 165 | ]
|
138 | 166 | },
|
139 | 167 | {
|
|
203 | 231 | "data[\"date\"] = pd.to_datetime(data[\"date\"])\n",
|
204 | 232 | "\n",
|
205 | 233 | "# Insert the data into CrateDB\n",
|
206 |
| - "dburi = f\"crate://{os.environ['CRATE_USER']}:{os.environ['CRATE_PASSWORD']}@{os.environ['CRATE_HOST']}:4200?ssl={os.environ['CRATE_SSL']}\"\n", |
207 |
| - "engine = sa.create_engine(dburi, echo=os.environ.get(\"DEBUG\"))\n", |
| 234 | + "engine = sa.create_engine(CONNECTION_STRING, echo=os.environ.get(\"DEBUG\"))\n", |
208 | 235 | "\n",
|
209 | 236 | "with engine.connect() as conn:\n",
|
210 | 237 | " data.to_sql(\n",
|
|
253 | 280 | "data[\"month\"] = pd.to_datetime(data['month'], unit='ms')\n",
|
254 | 281 | "\n",
|
255 | 282 | "# We set the MLFLOW_TRACKING_URI to our CrateDB instance. We'll see later why\n",
|
256 |
| - "os.environ[\"MLFLOW_TRACKING_URI\"] = f\"{dburi}&schema=mlflow\"" |
| 283 | + "os.environ[\"MLFLOW_TRACKING_URI\"] = f\"{CONNECTION_STRING}&schema=mlflow\"" |
257 | 284 | ]
|
258 | 285 | },
|
259 | 286 | {
|
|
1277 | 1304 | "output_type": "display_data"
|
1278 | 1305 | },
|
1279 | 1306 | {
|
1280 |
| - "name": "stdout", |
1281 | 1307 | "metadata": {
|
1282 | 1308 | "nbreg": {
|
1283 | 1309 | "diff_ignore": [
|
1284 | 1310 | "/outputs"
|
1285 | 1311 | ]
|
1286 | 1312 | }
|
1287 | 1313 | },
|
| 1314 | + "name": "stdout", |
1288 | 1315 | "output_type": "stream",
|
1289 | 1316 | "text": [
|
1290 | 1317 | "Fitting 3 folds for each of 10 candidates, totalling 30 fits\n"
|
1291 | 1318 | ]
|
1292 | 1319 | },
|
1293 | 1320 | {
|
1294 |
| - "name": "stderr", |
1295 | 1321 | "metadata": {
|
1296 | 1322 | "nbreg": {
|
1297 | 1323 | "diff_ignore": [
|
1298 | 1324 | "/outputs"
|
1299 | 1325 | ]
|
1300 | 1326 | }
|
1301 | 1327 | },
|
| 1328 | + "name": "stderr", |
1302 | 1329 | "output_type": "stream",
|
1303 | 1330 | "text": [
|
1304 | 1331 | "[Parallel(n_jobs=-1)]: Using backend LokyBackend with 24 concurrent workers.\n",
|
|
1433 | 1460 | "output_type": "display_data"
|
1434 | 1461 | },
|
1435 | 1462 | {
|
1436 |
| - "name": "stdout", |
1437 | 1463 | "metadata": {
|
1438 | 1464 | "nbreg": {
|
1439 | 1465 | "diff_ignore": [
|
1440 | 1466 | "/outputs"
|
1441 | 1467 | ]
|
1442 | 1468 | }
|
1443 | 1469 | },
|
| 1470 | + "name": "stdout", |
1444 | 1471 | "output_type": "stream",
|
1445 | 1472 | "text": [
|
1446 | 1473 | "Fitting 3 folds for each of 10 candidates, totalling 30 fits\n"
|
1447 | 1474 | ]
|
1448 | 1475 | },
|
1449 | 1476 | {
|
1450 |
| - "name": "stderr", |
1451 | 1477 | "metadata": {
|
1452 | 1478 | "nbreg": {
|
1453 | 1479 | "diff_ignore": [
|
1454 | 1480 | "/outputs"
|
1455 | 1481 | ]
|
1456 | 1482 | }
|
1457 | 1483 | },
|
| 1484 | + "name": "stderr", |
1458 | 1485 | "output_type": "stream",
|
1459 | 1486 | "text": [
|
1460 | 1487 | "[Parallel(n_jobs=-1)]: Using backend LokyBackend with 24 concurrent workers.\n",
|
|
1583 | 1610 | "output_type": "display_data"
|
1584 | 1611 | },
|
1585 | 1612 | {
|
1586 |
| - "name": "stdout", |
1587 |
| - "output_type": "stream", |
1588 | 1613 | "metadata": {
|
1589 | 1614 | "nbreg": {
|
1590 | 1615 | "diff_ignore": [
|
1591 | 1616 | "/outputs"
|
1592 | 1617 | ]
|
1593 | 1618 | }
|
1594 | 1619 | },
|
| 1620 | + "name": "stdout", |
| 1621 | + "output_type": "stream", |
1595 | 1622 | "text": [
|
1596 | 1623 | "Fitting 3 folds for each of 10 candidates, totalling 30 fits\n"
|
1597 | 1624 | ]
|
1598 | 1625 | },
|
1599 | 1626 | {
|
1600 |
| - "name": "stderr", |
1601 | 1627 | "metadata": {
|
1602 | 1628 | "nbreg": {
|
1603 | 1629 | "diff_ignore": [
|
1604 | 1630 | "/outputs"
|
1605 | 1631 | ]
|
1606 | 1632 | }
|
1607 | 1633 | },
|
| 1634 | + "name": "stderr", |
1608 | 1635 | "output_type": "stream",
|
1609 | 1636 | "text": [
|
1610 | 1637 | "[Parallel(n_jobs=-1)]: Using backend LokyBackend with 24 concurrent workers.\n",
|
|
2086 | 2113 | "source": [
|
2087 | 2114 | "os.environ[\n",
|
2088 | 2115 | " \"MLFLOW_TRACKING_URI\"\n",
|
2089 |
| - "] = f\"crate://{os.environ['CRATE_USER']}:{os.environ['CRATE_PASSWORD']}@{os.environ['CRATE_HOST']}:4200?ssl={os.environ['CRATE_SSL']}&schema=mlflow\"" |
| 2116 | + "] = f\"{CONNECTION_STRING}&schema=mlflow\"" |
2090 | 2117 | ]
|
2091 | 2118 | },
|
2092 | 2119 | {
|
|
2182 | 2209 | ],
|
2183 | 2210 | "metadata": {
|
2184 | 2211 | "kernelspec": {
|
2185 |
| - "display_name": "crate", |
| 2212 | + "display_name": "Python 3 (ipykernel)", |
2186 | 2213 | "language": "python",
|
2187 | 2214 | "name": "python3"
|
2188 | 2215 | },
|
|
2196 | 2223 | "name": "python",
|
2197 | 2224 | "nbconvert_exporter": "python",
|
2198 | 2225 | "pygments_lexer": "ipython3",
|
2199 |
| - "version": "3.10.0" |
| 2226 | + "version": "3.11.4" |
2200 | 2227 | }
|
2201 | 2228 | },
|
2202 | 2229 | "nbformat": 4,
|
|
0 commit comments