Skip to content

Commit

Permalink
Finishing out the challenges
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekTrainer committed Oct 8, 2023
1 parent 91f7f90 commit 242d9b9
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 7 deletions.
2 changes: 1 addition & 1 deletion content/0-get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ GitHub Copilot has extensions for Visual Studio, Visual Studio Code, NeoVIM and

## 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).
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).
2 changes: 1 addition & 1 deletion content/1-create-model-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ There's quite a bit of data in this dataset, and numerous directions you could g

## 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).
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](./2-create-api.md).
32 changes: 32 additions & 0 deletions content/2-create-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Expose data through an API

In the prior exercise you created a model to predict the likelihood a flight will be delayed into an airport by more than 15 minutes on a given day of the week. Now it's time to expose both this model and the associated list of airports so you can create the front-end application.

## Defining success

You will have successfully completed the challenge after:

- creating an endpoint to accept the id of the day of week and airport, which calls the model and returns both the chances the flight will be delayed and the confidence percent of the prediction.
- creating an endpoint which returns the list of airport names and IDs, sorted in alphabetical order.
- all data is returned as JSON.

## Tips

While you may find [Flask](https://flask.palletsprojects.com/en/2.3.x/) and [FastAPI](https://fastapi.tiangolo.com/) best suited for the task, you can use the framework you feel most comfortable with.

> **NOTE:** When using [GitHub Codespaces](https://docs.github.com/codespaces/overview) you are able to connect to a web server running in the cloud-based container. If you receive a 404 error, you may need to update [devcontainer.json](../.devcontainer/devcontainer.json) to add a [forwarded port](https://docs.github.com/en/codespaces/developing-in-codespaces/forwarding-ports-in-your-codespace#automatically-forwarding-a-port-1).
### Jump start

To get started with this challenge:

1. Create a new folder named **server**, and the file you'll use to be the server.
2. Start the file by adding in a couple of lines of comment describing what you're looking to accomplish.

## Sparking imagination

There's a few directions you could go to build upon the solution you've created. You could add a [Swagger](https://swagger.io/) implementation. You could implement caching to improve performance. You could add unit tests for the APIs. If you created additional models or data manipulations, you can expose those as well.

## Next steps

The primary goal of this exercise is to provide the opportunity to explore how GitHub Copilot works with a framework, and how you can help provide context by adding descriptive text at the beginning of the file. Now it's time to finish out the application by [creating the frontend](./3-create-frontend.md)!
31 changes: 31 additions & 0 deletions content/3-create-frontend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Create a user experience

With the API created it's time to close everything out by creating a frontend application. While the first two exercises have been relatively prescriptive in the frameworks and style, this exercise offers you the ability to choose the direction you'd like to go for creating a frontend. You can create a website using React or Svelte, a mobile app, a Windows app... Whatever you feel most comfortable with! You can also use this as an opportunity to explore a new framework.

## Defining success

You will have successfully completed the challenge after:

- you have a UI which displays a list of days of the week and airport.
- after the user makes their selection, the API you created is called.
- the result is displayed to the user.

## Tips

As highlighted above, you're free to use the framework you desire and create the type of application you like.

GitHub Copilot does not replace the need for a developer. While it can help guide and generate suggestions, the developer still needs to understand the code being generated. However, it can support a developer as they're exploring a framework for the first time. You can interact with GitHub Copilot through comments, describing what you're looking to accomplish, and seeing the suggested code.

> **NOTE:** If you are using a web frontend framework you may run into CORS issues when calling the API. See if GitHub Copilot can help you out!
## Sparking imagination

Now it's time to put a bow on everything you've been creating up until this point! Call all the APIs you created. Implement client-side caching. Add style and flair!

## Next steps

Congratulations on completing the workshop! Over the course of these challenges you explored how:

- GitHub Copilot can support development.
- to provide context to GitHub Copilot to improve suggestions.
- you need to be flexible when working with AI.
30 changes: 25 additions & 5 deletions copilot-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ Consider the following analogy. You ask a stranger, "Bring me some ice cream." W

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.

## Starting on the right foot

Every developer is familiar with the importance of comment documentation to help developers who'll later support the code (or when you return to it in the future). This holds true with GitHub Copilot as well. As highlighted above, providing GitHub Copilot with a clear idea of what you're trying to accomplish, and how you're trying to do it, will drive better suggestions. Starting a new file (or updating an existing one) with a few sentences describing the tasks at hand will payoff in the long run. You might want to include:

- the frameworks you're using
- a brief description of what needs to be done
- examples of the data you'll be with or actions you need to perform
- any additional supporting context

For example, let's say I'm creating a set of views using [Django](https://www.djangoproject.com/) for talks for a conference. I might start the file with the following comment block (or maybe as a [docstring](https://peps.python.org/pep-0257/)):

```python
# Using Django
# Using the generic views, display all talks, all talks by track, and all talks by speaker
# Preload all data whenever possible
# Readonly, no edit views are needed
```

## Coding for success

GitHub Copilot understands natural language and code. Just as it will read comments and make inferences when generating code, it will read your code and do the same. As a result, it's important to be clear when naming items in code.

It is common for developers to use single-letter variables (`x`, `i`, etc.), or use abbreviations (`spkr_count`, `tlk_ttl`, etc.). When using GitHub Copilot, it's generally best to spell things out and give items clear names. This helps provide clear context and will improve the quality of suggestions. (It's also just a better coding practice.)

## 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.
Expand All @@ -23,10 +47,6 @@ You can use this functionality to better guide GitHub Copilot towards what you'r

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:
Expand All @@ -40,4 +60,4 @@ Here's some quick, actionable tips you can use to help get the most out of GitHu

## 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/)
- [How to use GitHub Copilot: Prompts, tips, and use cases](https://github.blog/2023-06-20-how-to-write-better-prompts-for-github-copilot/)
6 changes: 6 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- jupyter
- matplotlib
- numpy
- psycopg2
- pylint

0 comments on commit 242d9b9

Please sign in to comment.