Platform Setup

What is Quarto?

  • Open-source publishing system for reproducible documents, presentations, and websites.
  • Supports multiple languages: Python, R, Julia.
  • Output formats: HTML, PDF, DOCX, Revealjs slides.
  • Think of it as a next-generation R Markdown.

quarto

Platform Background (ModelScope)

https://www.modelscope.cn/

  • /mnt/workspace/ is persistent storage (files survive across sessions).
  • System directories (like ~/.bashrc) are reset on every restart.
  • Requirement:
    • Install software inside /mnt/workspace/.
    • Re-load environment variables after each restart.

Quarto Installation (Step 1 & 2)

  1. Download the Script:

    cd /mnt/workspace
    wget -c https://assets.qiufei.site/install_quarto_linux_ali.sh
  2. Run the Script:

    bash /mnt/workspace/install_quarto_linux_ali.sh
    • Automatically detects architecture and downloads Quarto (~130 MB).
    • Installs to /mnt/workspace/opt/quarto-1.9.37/.

Quarto Activation (Step 3)

  • Since ModelScope resets environment variables, run this every time you open a new terminal:
source /mnt/workspace/quarto_setup.sh
  • Expected Output:

    Quarto 环境已设置 (版本: 1.9.37)
    运行 'quarto --help' 查看帮助

Already Installed? / Verification

  • After System Restart: You don’t need to reinstall. Just re-activate:

    source /mnt/workspace/quarto_setup.sh
  • Verify Installation:

    quarto --version
    # Should output: 1.9.37
    
    quarto check

Quick Start: Your First Document

  1. Create hello.qmd with YAML header, text, and Python code.

  2. Render it in the terminal:

    quarto render hello.qmd
  3. This generates hello.html (or .docx if specified).

Common Quarto Commands

Command Description
quarto render file.qmd Render to default format
quarto render file.qmd --to docx Render to Word
quarto preview file.qmd Live preview with auto-refresh
quarto check Verify installation & engines

Troubleshooting

  • “quarto: command not found”: Remember to run source /mnt/workspace/quarto_setup.sh.
  • Download fails: Manual download from GitHub, place in /mnt/workspace/downloads/, then re-run script.
  • Re-running script: Safe to do; it skips download if already present.

Quarto Extension Installation

  • Click the Extensions icon in the Cloud Studio application, which is the icon resembling a window with four squares.

  • Enter quarto in the search area, and you will see an extension with an icon like this: quarto . Click to install it.

.ipynb File Setup 1

  • Create a new .ipynb file and name it using the format StudentID-Name-Chapter.ipynb, for example, “2016900020-peter-chapter1-test.ipynb”.

  • Open the created file, select add a code cell, and set the type of this first cell to raw.

  • Enter the following content into the cell:

---
title: 'chapter 1 introduction'
subtitle: 'applied statistics 2026'
author: '2016900020-peter'
date: last-modified
date-format: 'YYYY-MM-DD HH:mm:mm'
format: docx
---

.ipynb File Setup 2

  • Modify the content following the colons for title and author according to your actual information; do not modify any other content. Note: There must be a space after the colon.

  • Add another code cell, set the type of this cell to python, and enter print('hello world!') in the cell.

  • Enter the following command in the terminal: quarto render 2016900020-peter-chapter1-test.ipynb. If a .docx document is generated in the file explorer area, then the platform setup is successful.

Course Data Sources

  • By prepending the string https://assets.qiufei.site/data/ to the filename of the data referenced in the textbook, you can obtain the download link for the data.

  • For example, to obtain the data stock/stock_basic_data.h5, its URL would be: https://assets.qiufei.site/data/stock/stock_basic_data.h5

  • Enter the command wget -c https://assets.qiufei.site/data/stock/stock_basic_data.h5 in the terminal to download the data to the workspace.

  • The download command for all data in the textbook requires simply entering wget -c before the URL.

Course Data Usage

  • Change the original data_path = '/home/ubuntu/r2_data_mount/qiufei/data/stock'

  • Modify it to data_path = '/mnt/workspace'

for example:

# Automatically set local data paths based on the operating system
if platform.system() == 'Windows':  
# Check the current operating system type
    data_path = 'C:/qiufei/data/stock'  
    # Data path for Windows
else:  
# Use server data path on Linux
    data_path = '/mnt/workspace'  # the original path is '/home/ubuntu/r2_data_mount/qiufei/data/stock'
    # Data path for Linux

install tables package

  • in order to us h5 data,you should install python’s pytables packages

  • the install command is pip install tables