From 2f54a3be60a7b35a429f941f37da27c7f9b7984d Mon Sep 17 00:00:00 2001 From: Christopher Harrison Date: Fri, 29 Sep 2023 15:55:14 -0700 Subject: [PATCH] Initial commit --- README.md | 32 +++++++++++++++++++++++++ content/0-get-started.md | 31 ++++++++++++++++++++++++ content/1-create-model-data.md | 37 +++++++++++++++++++++++++++++ copilot-tips.md | 43 ++++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+) diff --git a/README.md b/README.md index e69de29..323759f 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,32 @@ +# Exploring GitHub Copilot + +[GitHub Copilot](https://github.com/features/copilot) is billed and designed to be an AI pair programmer. Based on the context it sees and the code you write it will generate suggestions for the next line, block, function or even class it believes you're writing. This allows you to offload tedious tasks, obtain obscure syntax, and generate code from comments, allowing you to stay in the zone and focus on the higher level and more difficult challenges. + +This workshop is created to give you the opportunity to explore GitHub Copilot, to see how to use and interact with it while building an application. A loose structure is provided to create a scenario and give you a starting point, with a series of challenges to guide you through various aspects of coding with GitHub Copilot. + +## The scenario + +You have been provided a [dataset with flight information from the FAA](./data/flights.csv). The dataset contains dates, times and carriers for flights in the US which took place in 2013. You want to build an application which will allow someone to select the day of the week and arrival airport to see the chance their flight will be delayed by more than 15 minutes. You'll do so by walking through the following challenges: + +1. Create and export the data and model to support the application +2. Create an API to provide a list of airports and their associated ID in the data, and the model +3. Create a frontend to allow a user to select the day and airport to see the information + +## Building the application + +The goal of the workshop is to create an application which meets the specifications indicated above - a frontend which allows the user to see the chance their flight will be delayed. You will notice there is limited guidance about how to actually build it. This is intentional, as we want you to explore GitHub Copilot using tools you're familiar with or want to explore. The best way to learn GitHub Copilot, after all, is to start using it. + +As a result, you're free to use frameworks and languages of your choosing. If you want to create a backend using Node.js and a frontend with Vue.js, you're welcome to do that! Want a Windows app? A mobile app? To explore the dataset more and discover new insights? Feel free to do so! + +## Getting support + +With the open-ended nature of the workshop the mentors may not be able to help with every possible path. We've provided a couple of solutions which we would consider "official", and the ones the staff are most familiar with. However, as already stated, the primary goal is to explore GitHub Copilot. So while there might not be someone who's an expert on Go, you'll be able to talk about GitHub Copilot and how to get the most out of the tool. So don't be afraid to ask! + +## Getting started + +Let's get started! Here's the list of challenges to help guide you through the workshop: + +0. [Starting the project and installing GitHub Copilot](./content/0-get-started.md) +1. [Create the model and supporting data](./content/1-create-model-data.md) +2. [Create the API](./content/2-create-api.md) +3. [Create the frontend](./content/3-create-frontend.md) diff --git a/content/0-get-started.md b/content/0-get-started.md index e69de29..2a996f5 100644 --- a/content/0-get-started.md +++ b/content/0-get-started.md @@ -0,0 +1,31 @@ +# Getting started with GitHub Copilot + +[GitHub Copilot](https://github.com/features/copilot) is a generative AI pair programmer. As you code, context including open files in the IDE, comments and code are sent to GitHub Copilot. Suggestions are then returned based on what it sees and what it knows for the next line or lines of code you're most likely looking for. To do so an extension is needed for your IDE. + +Let's start this workshop by launching the project using [GitHub Codespaces](https://github.com/features/codespaces), a cloud-based container for development, and installing the extension. + +## Create and start the project + +To start creating code you'll of course need to get the code. This repository is setup as a template with a [devcontainer](https://docs.github.com/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers) already defined. Let's create an instance of the repository in the appropriate organization or individual account, and start the codespace. + +1. Navigate to the [root of the repository on GitHub](../). +2. Select **Use this template** > **Create a new repository**. +3. Enter the appropriate information to configure the name and location of the repository. If a specific organization has been defined for your event, use that as the **owner**. (If you're unsure, ask a mentor). +4. Select **Create repository** to create the repository. +5. Once the repository is created, open it in GitHub Codespaces by selecting **Code** > **Codespaces** > **Create a codespace on main** (indicated by the **+**). +6. The codespace will take a few minutes to setup the first time. It contains everything needed for the workshop, including Python/Anaconda and Node.js. It doesn't yet contain the extension for GitHub Copilot, which you'll install next. + +## Install the extension + +GitHub Copilot has extensions for Visual Studio, Visual Studio Code, NeoVIM and the JetBrains suite of IDEs. Because the browser-based version of Visual Studio Code for Codespaces is, well, Visual Studio Code, you can install the extension! + +1. Open the command pallette by pressing F1. +2. In the command pallette window, type **Install extensions**. +3. Select **Extensions: Install extensions**. +4. Type **GitHub Copilot** in the newly opened extensions window. +5. Select **Install** on **GitHub Copilot** to install the extension. +6. If prompted, reconnect to the codespace. + +## Next steps + +You've now got the development environment created and started! You're all set and ready to start writing code. So, let's [begin working with the dataset](./1-create-model-data.md). \ No newline at end of file diff --git a/content/1-create-model-data.md b/content/1-create-model-data.md index e69de29..0d90bf9 100644 --- a/content/1-create-model-data.md +++ b/content/1-create-model-data.md @@ -0,0 +1,37 @@ +# Working with a dataset and machine learning + +The scenario for this workshop revolves around a [dataset from the FAA](../data/flights.csv) which contains core information about flights in the US in 2013. It contains the carrier, the date and time the flights took off and arrived (and their origin and destination), and information about delays including both the time and a flag if it was more than 15 minutes. For this scenario you will explore and cleanse the data, build an export a model trained to show the percent chance a flight will be delayed for a day of the week and an airport, and create a new CSV file containing the list of all airports and their associated id in the dataset. + +> **NOTE:** The CSV file is in the [data](../data/) folder, and is named **flights.csv**. + +## Defining success + +You will have successfully completed this challenge after: + +- cleansing the data by identifying null values and replacing them with an appropriate value (zero in this case). +- creating a model which provides the chances a flight will be delayed by more than 15 minutes for a given day and airport pair. +- saving the model to a file for use in an external application. +- creating a new file with the names and associated ids from the dataset of all airports. + +## Tips + +If you're new to data science and machine learning, the first step when working with a new dataset is to explore the data. You'll typically start by loading the data into memory, displaying a portion to gain an understanding about how the data is structured, and looking for any issues which need to be cleaned up. (There are always issues which need to be cleaned up.) As these are common tasks, you'll find GitHub Copilot will be able to provide a fair amount of support. + +Two popular libraries for these types of tasks are [pandas](https://pandas.pydata.org/docs/getting_started/intro_tutorials/index.html) and [scikit-learn](https://scikit-learn.org/stable/), with [Jupyter notebooks](https://code.visualstudio.com/docs/datascience/jupyter-notebooks) being the most common tool used to perform these tasks. Fortunately, Visual Studio Code natively supports Jupyter notebooks, so you won't need to install any additional tooling. + +### Jump start + +To get started with this challenge: + +1. Inside of your codespace, in the root of the project, create a new notebook named **manage-flight-data.ipynb**. +2. In the first cell, add a comment describing what you're looking to do. +3. Start by displaying the data to get a sense for the values included. +4. If you're not sure of what to do, start by asking GitHub Copilot in the form of a comment. + +## Sparking imagination + +There's quite a bit of data in this dataset, and numerous directions you could go with it. You could explore delay information by airline, which routes are most likely to be delayed, or what city has the best on-time performance. While the workshop is centered on the one scenario, if you're comfortable with data science and machine learning, you can take some extra time here to play with other aspects of the data. + +## Next steps + +This first scenario is designed to provide a sense of how to work with GitHub Copilot and how to interact with it. You'll likely have seen it was able to suggest libraries to use and the tasks necessary to complete a given scenario. With the data setup, let's turn our attention to [creating the API](./02-create-api.md). \ No newline at end of file diff --git a/copilot-tips.md b/copilot-tips.md index e69de29..cc93448 100644 --- a/copilot-tips.md +++ b/copilot-tips.md @@ -0,0 +1,43 @@ +# Getting the most out of GitHub Copilot + +GitHub Copilot is a generative AI tool which will create code suggestions based both on the context it sees and its training data. Due to its probabilistic nature, there isn't a set way to use the tool. You'll discover new ways to interact with it to best guide it towards what you're looking for. + +Notice the name is *Copilot* rather than Autopilot. A developer is necessary, and the tool isn't able to complete every task a human can. There are certain tasks where GitHub Copilot shines, and others it's not able to complete or needs more assistance for. + +- Boilerplate code +- Repetitive code +- Unit tests +- Obscure syntax like regular expressions or chron jobs + +## Guiding GitHub Copilot + +Consider the following analogy. You ask a stranger, "Bring me some ice cream." While there's enough information provided to technically complete the task successfully, there's a strong chance you won't be satisfied with the results. There's more context which is needed to ensure you get what you want, like what flavor? Serving vessel? Sprinkles? These are important. (And the answer is always sprinkles.) + +The same holds true with GitHub Copilot. A blank page with a 5 word comment likely won't illicit a code suggestion which meets the specifications you had in mind. You can help set GitHub Copilot up for success by giving it good context and background about what you're building. + +## Defining context + +GitHub Copilot uses both the file you're currently working on and the tabs open in your IDE as context. While there are a couple of reasons GitHub Copilot uses open tabs rather than the project structure, the biggest is because it's most likely to be the relevant context. If you think about how you code you likely naturally open files related to the task you're currently focused on. GitHub Copilot is built this same way. + +You can use this functionality to better guide GitHub Copilot towards what you're looking to code and how you're looking to do it. If you have a representative example of a framework you're using, a data model, or an API, you can open that tab for use by GitHub Copilot. + +GitHub Copilot will also look at the entirety of the file you're currently working on, not just what's above your cursor. This means you can introduce new code into the middle of a file with GitHub Copilot's support. + +## Common use cases + + + +## Quick tips + +Here's some quick, actionable tips you can use to help get the most out of GitHub Copilot: + +- Add a header to the top of a file with a short description of what you're building and how you're building it +- Write short but specific requests when using comment driven development +- Be flexible with your wording, realizing you might need to rephrase or reframe to get a better response +- Because GitHub Copilot is probabilistic, you may notice you receive different responses to the same prompt; this is the nature of generative AI +- Good variable, function and class names help provide additional context and drive better suggestions (and it's a good practice anyway) +- Model the coding style you want to see from GitHub Copilot, as its suggestions are based on the practices it sees in action + +## Resources + +- [How to use GitHub Copilot: Prompts, tips, and use cases](https://github.blog/2023-06-20-how-to-write-better-prompts-for-github-copilot/) \ No newline at end of file