Skip to content

Commit

Permalink
Added github and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
htahir1 committed Aug 24, 2024
1 parent b25a492 commit 449c8ed
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/update-tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
80 changes: 80 additions & 0 deletions tutorials/starter-guide-2/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down

0 comments on commit 449c8ed

Please sign in to comment.