From 449c8ed83b6bad8ce33ea8c14d5f1e7184b6ed2c Mon Sep 17 00:00:00 2001 From: Hamza Tahir Date: Sat, 24 Aug 2024 13:30:14 +0200 Subject: [PATCH] Added github and scripts --- .github/workflows/update-tutorials.yml | 12 ++- tutorials/starter-guide-2/introduction.ipynb | 80 ++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-tutorials.yml b/.github/workflows/update-tutorials.yml index 1bfca6b436a..7b0b0b7619b 100644 --- a/.github/workflows/update-tutorials.yml +++ b/.github/workflows/update-tutorials.yml @@ -86,7 +86,17 @@ jobs: changedFiles.forEach(file => { commentBody += `- \`${file}\`\n`; }); - commentBody += '\nPlease review these changes.'; + commentBody += '\nPlease review these changes.\n\n'; + + // Add suggested TOC for each guide type + const guideTypes = ['starter_guide', 'advanced_guide']; // Add all your guide types here + guideTypes.forEach(guideType => { + const suggestedToc = process.env[`suggested_toc_${guideType}`]; + if (suggestedToc) { + commentBody += `### Suggested TOC for ${guideType.replace('_', ' ').replace(/\b\w/g, l => l.toUpperCase())}:\n\n`; + commentBody += '```\n' + suggestedToc + '\n```\n\n'; + } + }); try { await github.rest.issues.createComment({ diff --git a/tutorials/starter-guide-2/introduction.ipynb b/tutorials/starter-guide-2/introduction.ipynb index 29d0912e664..56fc655aedd 100644 --- a/tutorials/starter-guide-2/introduction.ipynb +++ b/tutorials/starter-guide-2/introduction.ipynb @@ -135,6 +135,86 @@ " # You can now use the `run` object to see steps, outputs, etc." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from zenml import pipeline, step\n", + "\n", + "@step\n", + "def load_data() -> dict:\n", + " \"\"\"Simulates loading of training data and labels.\"\"\"\n", + "\n", + " training_data = [[1, 2], [3, 4], [5, 6]]\n", + " labels = [0, 1, 0]\n", + " \n", + " return {'features': training_data, 'labels': labels}\n", + "\n", + "@step\n", + "def train_model(data: dict) -> None:\n", + " \"\"\"\n", + " A mock 'training' process that also demonstrates using the input data.\n", + " In a real-world scenario, this would be replaced with actual model fitting logic.\n", + " \"\"\"\n", + " total_features = sum(map(sum, data['features']))\n", + " total_labels = sum(data['labels'])\n", + " \n", + " print(f\"Trained model using {len(data['features'])} data points. \"\n", + " f\"Feature sum is {total_features}, label sum is {total_labels}\")\n", + "\n", + "@pipeline\n", + "def simple_ml_pipeline():\n", + " \"\"\"Define a pipeline that connects the steps.\"\"\"\n", + " dataset = load_data()\n", + " train_model(dataset)\n", + "\n", + "if __name__ == \"__main__\":\n", + " run = simple_ml_pipeline()\n", + " # You can now use the `run` object to see steps, outputs, etc." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from zenml import pipeline, step\n", + "\n", + "@step\n", + "def load_data() -> dict:\n", + " \"\"\"Simulates loading of training data and labels.\"\"\"\n", + "\n", + " training_data = [[1, 2], [3, 4], [5, 6]]\n", + " labels = [0, 1, 0]\n", + " \n", + " return {'features': training_data, 'labels': labels}\n", + "\n", + "@step\n", + "def train_model(data: dict) -> None:\n", + " \"\"\"\n", + " A mock 'training' process that also demonstrates using the input data.\n", + " In a real-world scenario, this would be replaced with actual model fitting logic.\n", + " \"\"\"\n", + " total_features = sum(map(sum, data['features']))\n", + " total_labels = sum(data['labels'])\n", + " \n", + " print(f\"Trained model using {len(data['features'])} data points. \"\n", + " f\"Feature sum is {total_features}, label sum is {total_labels}\")\n", + "\n", + "@pipeline\n", + "def simple_ml_pipeline():\n", + " \"\"\"Define a pipeline that connects the steps.\"\"\"\n", + " dataset = load_data()\n", + " train_model(dataset)\n", + "\n", + "if __name__ == \"__main__\":\n", + " run = simple_ml_pipeline()\n", + " # You can now use the `run` object to see steps, outputs, etc." + ] + }, { "cell_type": "markdown", "metadata": {},