Skip to content

Commit 242d9b9

Browse files
committed
Finishing out the challenges
1 parent 91f7f90 commit 242d9b9

File tree

6 files changed

+96
-7
lines changed

6 files changed

+96
-7
lines changed

content/0-get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ GitHub Copilot has extensions for Visual Studio, Visual Studio Code, NeoVIM and
2828

2929
## Next steps
3030

31-
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).
31+
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).

content/1-create-model-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ There's quite a bit of data in this dataset, and numerous directions you could g
3434

3535
## Next steps
3636

37-
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).
37+
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).

content/2-create-api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Expose data through an API
2+
3+
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.
4+
5+
## Defining success
6+
7+
You will have successfully completed the challenge after:
8+
9+
- 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.
10+
- creating an endpoint which returns the list of airport names and IDs, sorted in alphabetical order.
11+
- all data is returned as JSON.
12+
13+
## Tips
14+
15+
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.
16+
17+
> **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).
18+
19+
### Jump start
20+
21+
To get started with this challenge:
22+
23+
1. Create a new folder named **server**, and the file you'll use to be the server.
24+
2. Start the file by adding in a couple of lines of comment describing what you're looking to accomplish.
25+
26+
## Sparking imagination
27+
28+
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.
29+
30+
## Next steps
31+
32+
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)!

content/3-create-frontend.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Create a user experience
2+
3+
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.
4+
5+
## Defining success
6+
7+
You will have successfully completed the challenge after:
8+
9+
- you have a UI which displays a list of days of the week and airport.
10+
- after the user makes their selection, the API you created is called.
11+
- the result is displayed to the user.
12+
13+
## Tips
14+
15+
As highlighted above, you're free to use the framework you desire and create the type of application you like.
16+
17+
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.
18+
19+
> **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!
20+
21+
## Sparking imagination
22+
23+
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!
24+
25+
## Next steps
26+
27+
Congratulations on completing the workshop! Over the course of these challenges you explored how:
28+
29+
- GitHub Copilot can support development.
30+
- to provide context to GitHub Copilot to improve suggestions.
31+
- you need to be flexible when working with AI.

copilot-tips.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,30 @@ Consider the following analogy. You ask a stranger, "Bring me some ice cream." W
1515

1616
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.
1717

18+
## Starting on the right foot
19+
20+
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:
21+
22+
- the frameworks you're using
23+
- a brief description of what needs to be done
24+
- examples of the data you'll be with or actions you need to perform
25+
- any additional supporting context
26+
27+
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/)):
28+
29+
```python
30+
# Using Django
31+
# Using the generic views, display all talks, all talks by track, and all talks by speaker
32+
# Preload all data whenever possible
33+
# Readonly, no edit views are needed
34+
```
35+
36+
## Coding for success
37+
38+
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.
39+
40+
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.)
41+
1842
## Defining context
1943

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

2448
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.
2549

26-
## Common use cases
27-
28-
29-
3050
## Quick tips
3151

3252
Here's some quick, actionable tips you can use to help get the most out of GitHub Copilot:
@@ -40,4 +60,4 @@ Here's some quick, actionable tips you can use to help get the most out of GitHu
4060

4161
## Resources
4262

43-
- [How to use GitHub Copilot: Prompts, tips, and use cases](https://github.blog/2023-06-20-how-to-write-better-prompts-for-github-copilot/)
63+
- [How to use GitHub Copilot: Prompts, tips, and use cases](https://github.blog/2023-06-20-how-to-write-better-prompts-for-github-copilot/)

environment.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- jupyter
3+
- matplotlib
4+
- numpy
5+
- psycopg2
6+
- pylint

0 commit comments

Comments
 (0)