class: center, middle, inverse, title-slide .title[ # BAA1030 - Data Analytics and Story Telling ] .subtitle[ ## Lecture 10: Publish your Quarto with GitHub ] .author[ ### Damien Dupré - Dublin City University ] --- # Objectives The last tool for data analytics and visualisations displayed in this lecture is called **GitHub**. GitHub has a lot of different functions. For now, we will only see how to use it to **publish the html document output from Quarto**. .center[ <!-- --> ] --- # What is GitHub Primarily used to collaborate on code development, it became multi-purpose: - Version Control - File and Code Storage - Collaboration - Developers Social Media - Online Publication & Website Host - Automatic Actions And even more that I am not aware of! --- # What is GitHub Primarily used to collaborate on code development, it became multi-purpose: - Version Control - **File and Code Storage** - Collaboration - Developers Social Media - **Online Publication & Website Host** - Automatic Actions And even more that I am not aware of! --- class: title-slide, middle ## 🛠️ Your Turn! 1/ Go to https://github.com and click **sign up** (or **log in** if you already have an account) 2/ Fill the information requested, find a **good user name** as it will be used for your default website (e.g., `firstname-name` is usually good) 3/ Later, add a profile picture
−
+
02
:
00
--- # Welcome to GitHub <!-- --> --- class: inverse, mline, center, middle # GitHub Repository --- # How does GitHub Work? The core principle of GitHub is a remote desktop (or profile) with a folder called **Repository** for each project you are working on or you worked on (also called "Repo" if you want to use the slang). <!-- --> --- class: title-slide, middle ## Demo --- class: title-slide, middle ## 🛠️ Your Turn! Follow the steps hereafter to **create your first repository**. --- # GitHub Repositories [To create a Repository](https://docs.github.com/en/get-started/quickstart/create-a-repo): 1/ In the upper-right corner of any page, use the `+` drop-down menu, and select New repository. <!-- --> --- # GitHub Repositories <!-- --> --- # GitHub Repositories 2/ **Type a short, memorable name** for your repository. For example, "hello-world". <!-- -->
<i class="fas fa-exclamation-triangle faa-flash animated faa-slow " style=" color:red;"></i>
Warning: Do NOT use white space between words, snake case convention highly recommended. 3/ **Optionally**, add a description of your repository. For example, "My first repository on GitHub." --- # GitHub Repositories 4/ **Choose a PUBLIC repository visibility**. For more information, see "About repositories." 5/ Tick **Add a README file**. 6/ Click **Create repository**. ### Congratulations! You've successfully created your first repository, and initialized it with a README file. .center[ <img src="https://external-preview.redd.it/H3X9ghkU1diDoEaB2j6OLakfRVvtelkI-VVCAMvpHFw.jpg?auto=webp&s=812777b2de31ed351475ecfb9cfe91a74931201b" width="50%" /> ] --- class: inverse, mline, center, middle # GitHub Commit --- # Always Commit Changes In GitHub, a commit is a saved change to a project's source code or other files. When you make changes to a file in a GitHub repository, you create a new version of that file. **A commit contains a snapshot of the changes** you've made to one or more files, along with a message that describes the changes. This **message should be descriptive and clear**, so that other developers can understand what changes you've made and why. ### Every time you want to take into account a change in your repository, you need to commit these changes --- class: title-slide, middle ## Demo --- class: title-slide, middle ## 🛠️ Your Turn! When you created your new repository, you initialized it with a README file. README files are a great place to describe your project in more detail, or add some documentation such as how to install or use your project. The contents of your README file are automatically shown on the front page of your repository. **Follow the steps hereafter to commit a change to the README file.** --- # Commit the First Change 1/ In your repository's list of files, **click README.md**. <img src="https://docs.github.com/assets/cb-44661/mw-1000/images/help/repository/create-commit-open-readme.webp" width="50%" /> --- # Commit the First Change 2/ In the upper right corner of the file view, **click the pen icon to open the file editor**. <img src="https://docs.github.com/assets/cb-90977/mw-1000/images/help/repository/edit-file-edit-button.webp" width="80%" /> 3/ In the text box, **type some information about the project**. 4/ Above the new content, click **Preview**. <img src="https://docs.github.com/assets/cb-66827/mw-1000/images/help/repository/edit-readme-preview-changes.webp" width="80%" /> --- # Commit the First Change .pull-left[ 5/ **Review the changes** you made to the file. You will see the new content in green. 6/ Click **Commit changes...** 7/ In the "Commit message" field, type a short, meaningful **commit message** that describes the change you made to the file. ] .pull-right[ <!-- --> ] 8/ Below the commit message fields, decide whether to add your commit to the current branch or to a new branch. Select **commit directly to the `main` branch** for now.
<i class="fas fa-exclamation-triangle faa-flash animated faa-slow " style=" color:red;"></i>
Warning: For collaborative projects never commit to the main branch 9/ Click **Propose file change**. --- class: title-slide, middle ## Demo --- class: title-slide, middle ## 🛠️ Your Turn! **Fill your Repository with the `report.html` file** created when you used Quarto to render the `report.ipynb` file to html by following the steps described hereafter: 1/ In your Repository Page in GitHub, Click **Add files** then **Upload files** 2/ **Drop your `report.html` file** in the main box 3/ Write a descriptive commit message (e.g., "Add Quarto report") and **commit your changes** 4/ Go back to your repository page and verify that the file appears in the list
−
+
02
:
00
--- class: inverse, mline, center, middle # GitHub Pages --- # GitHub Pages GitHub Pages is a **web hosting service** offered by GitHub that allows you to host static websites directly from a GitHub repository. This means you can use GitHub to store and version control your website's code, and then host it for free using GitHub Pages. GitHub Pages supports several **different types of websites, including personal or project pages**, documentation, blogs, and more. You can use custom domains or subdomains for your website, and GitHub Pages also supports HTTPS encryption for secure communication. To create a GitHub Pages website, you need to have a GitHub account and a **repository containing your website's HTML, CSS, and other files**. Once you've created your repository and pushed your website's files to it, you can **enable GitHub Pages in the repository settings**. Your website will then be published at a URL based on your GitHub username and repository name (e.g., username.github.io/repository). --- # GitHub Pages <!-- --> --- class: title-slide, middle ## Demo --- class: title-slide, middle ## 🛠️ Your Turn! Turn on GitHub Pages for your project repository: 1/ Go to **Settings** and find **Pages** on the left pane 2/ In **Branch**, instead of None select **Main** and click **Save** 3/ Click on **Actions** and wait for "pages build and deployment" to finish. When it's done, go to **https://username.github.io/repository/report**
−
+
03
:
00
--- # GitHub Pages URL By default, your html report will be published at: **https://username.github.io/repository/report** If: - Your GitHub username is **damien-dupre** - Your Repository name is **data-analytics** - Your Project folder name is **project** - Your html file name is **report.html** Then, your report will be published at: **https://damien-dupre.github.io/data-analytics/project/report** --- # GitHub Pages URL
<i class="fas fa-exclamation-triangle faa-flash animated faa-slow " style=" color:red;"></i>
Warning: Do NOT use white spaces between words, snake case convention is highly recommended. If you use a white space in any of the Repository name, Project folder name, or html file name then this white space will be replaced by the symbol **%20** For example, a Repository name called **data analytics** will have the following URL: **https://damien-dupre.github.io/data%20analytics/project/report** --- # GitHub Pages URL There are two special cases to consider with URLs: 1/ If your html file name is **index.html**, then your file URL will be: **https://damien-dupre.github.io/data-analytics/project** 2/ If your Repository name is **username.github.io** (e.g., damien-dupre.github.io), then your file URL will be: **https://damien-dupre.github.io/project/report** --- # GitHub Pages URL Both shortcuts can be used to display a document at: **https://username.github.io** If: - Your GitHub username is **damien-dupre** - Your Repository name is **damien-dupre.github.io** - Your html file name is **index.html** Then your report will be published at the URL: **https://damien-dupre.github.io** --- class: inverse, mline, center, middle # Assignment 2 Brief --- # Assignment Instructions ### Context You are Data Analyst for the UNICEF organisation, and you have been asked to design a report to raise awareness of the public on a specific world issue. ### Task Using the files that you already have received by email (i.e., one or both **unicef_indicator_1.csv** and **unicef_indicator_2.csv** files as well as **unicef_metadata.csv** file), **create an html report that contains a story** (i.e., narrative) **and some visualisations** to support this story. This html report must be **rendered by Quarto** and **published with GitHub Pages**. ### Story You can copy-paste the exact same text included in your Tableau Dashboard assignment. You can also modify it or write a new one if you prefer. This story has to __use text emphasis styles__ (e.g., title levels, italic/bold font, list and bullet points, ...). --- # Assignment Instructions .pull-left[ ### Visualisations They will have to be created with plotnine. You need to __include 4 visualisations__: - A World Map chart, - A bar chart, - A scatterplot with a regression line, - A time-series chart. ] .pull-right[ ### HTML Output The report must contain a YAML text cell with, **at least**, the following code: ```yaml --- format: html: embed-resources: true code-fold: true --- ``` ] More specifications of the YAML, the addition of a HTML theme, full customisation of the visualisations and the use of hashpipe options in the code cells will be positively assessed. --- # Assignment Instructions ## Submission Submit the **URL of your html report** published with GitHub Pages AND the link to your `report.ipynb` file from your Google Drive on the **BAA1030 Loop page** by **April 7th, 1pm**. ## Assessment Criteria - Overall Code (25%) - Data Transformations (25%) - Visualisation Design (25%) - HTML Output (25%) See criteria quality grid for a description of expected submissions. --- class: inverse, mline, center, middle # Vibe Coding and GitHub --- # Vibe Coding Your Assignment Vibe coding is the practice of **describing what you want in natural language** and letting an AI assistant (such as ChatGPT, Claude, or GitHub Copilot) generate the code for you. For the assignment, vibe coding can help you with: - Writing the **plotnine visualisations** (world map, bar chart, scatterplot, time-series) - Setting up the **Quarto YAML** with the correct options - Writing **Polars data transformations** (filtering, grouping, joining) - Formatting the **markdown text** for your story
<i class="fas fa-exclamation-triangle faa-flash animated faa-slow " style=" color:red;"></i>
Vibe coding does **not** mean blindly trusting AI output. Always **read and understand** the code before running it! --- # Vibe Coding in Practice **Step 1:** Write a prompt describing a specific visualisation you need > "Using plotnine and Polars, from a dataframe called unicef_indicator_1 joined with unicef_metadata, create a world map showing the indicator value for the most recent year available. Use a yellow-to-red colour gradient and add a descriptive title." **Step 2:** The AI generates Polars + plotnine code **Step 3:** Read the code, verify that column names match your actual data, and run it -- **Important for the assignment:** - Always tell the AI the **exact column names** from your CSV files - Specify **"using Polars and plotnine"** (not pandas or matplotlib) - Ask for **Quarto hashpipe options** if you want to customise the output - Test each code cell individually before rendering with Quarto --- # Tips for Vibe Coding the Assignment .pull-left[ **Good prompts for the assignment:** > "Using Polars, read unicef_indicator_1.csv and unicef_metadata.csv, join them on country, and create a bar chart of the top 10 countries by indicator value using plotnine." > "Write a Quarto YAML with the flatly theme, code folding, embedded resources, title 'UNICEF Report', and my name as author." > "Using plotnine, create a time-series line chart of the indicator value over the years, coloured by continent." ] .pull-right[ **Common pitfalls to avoid:** - Not checking that column names match your actual data files - Forgetting to specify Polars (AI defaults to pandas) - Not running all cells before calling `quarto render` - Using white spaces in file names (breaks GitHub Pages URLs) **Always verify:** - Does the code run without errors in Google Colab? - Does the Quarto YAML have correct indentation? - Is `embed-resources: true` included in the YAML? ] --- class: title-slide, middle ## 🛠️ Your Turn! Use an AI assistant (ChatGPT, Claude, or Copilot) to help you get started on the assignment. **Review all generated code before running it!** 1/ Ask the AI: *"Using Polars, write Python code to read a CSV file called unicef_indicator_1.csv and display its first 5 rows."* 2/ Ask the AI: *"Using plotnine and Polars, create a bar chart showing the average value of the obs_value column by continent."* (adjust column names to match your actual data) 3/ Paste the generated code into your `report.ipynb`, run the cells, and verify the output. Did you need to adjust any column names?
−
+
10
:
00
--- class: inverse, mline, left, middle <img class="circle" src="https://github.com/damien-dupre.png" width="250px"/> # Thanks for your attention and don't hesitate to ask if you have any question! [
@damien-dupre](http://github.com/damien-dupre) [
https://damien-dupre.github.io](https://damien-dupre.github.io) [
damien.dupre@dcu.ie](mailto:damien.dupre@dcu.ie)