Spaces:
Sleeping
Sleeping
Commit ·
468877a
1
Parent(s): c9ea83a
docs: Create LESSONS.md file
Browse files- LESSONS.md +113 -0
LESSONS.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Lessons
|
| 2 |
+
|
| 3 |
+
## Table of Contents
|
| 4 |
+
|
| 5 |
+
1. [📦 Git LFS (Large File Storage)](#1-git-lfs-large-file-storage)
|
| 6 |
+
2. [🌊 Marimo: Code Display Behavior](#2-marimo-code-display-behavior)
|
| 7 |
+
|
| 8 |
+
## 1. 📦 Git LFS (Large File Storage)
|
| 9 |
+
|
| 10 |
+
Git LFS (Large File Storage) is an extension for Git that allows you to track and version large files (e.g. `.db`, `.csv`, `.model`) without bloating your repository. Instead of storing the actual file content in Git, it stores a lightweight pointer and pushes the real content to a separate LFS server.
|
| 11 |
+
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
### How to Install
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
sudo apt install git-lfs
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
After installation, initialize LFS:
|
| 21 |
+
|
| 22 |
+
```bash
|
| 23 |
+
git lfs install
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
### How to Use (Basic Example)
|
| 29 |
+
|
| 30 |
+
1. **Track the file type or name:**
|
| 31 |
+
|
| 32 |
+
```bash
|
| 33 |
+
git lfs track "olist.db"
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
2. **Edit `.gitignore` **
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
# Ignore all database files
|
| 40 |
+
*.db
|
| 41 |
+
# But include this one (make sure it's tracked with git LFS)
|
| 42 |
+
!olist.db
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
3. **Stage the tracking file (`.gitattributes`) and your large file:**
|
| 46 |
+
|
| 47 |
+
```bash
|
| 48 |
+
git add .gitattributes
|
| 49 |
+
git add olist.db
|
| 50 |
+
git commit -m "Track olist.db with Git LFS"
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
4. **Push to your remote repo:**
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
git push origin main
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## 2. 🌊 Marimo: Code Display Behavior
|
| 60 |
+
|
| 61 |
+
By default, **Marimo hides the code cells** in the deployed (read-only) version of your app, especially when running as a Hugging Face Space or a `.py` script.
|
| 62 |
+
|
| 63 |
+
This behavior is intentional and aligns with Marimo’s goal of turning Python notebooks into polished, interactive **data apps** — focusing on the results and UI rather than code.
|
| 64 |
+
|
| 65 |
+
| Environment | Notes |
|
| 66 |
+
| ------------------------------------ | ---------------------------------- |
|
| 67 |
+
| Local Dev Mode (`marimo run app.py`) | Full interactivity + visible code |
|
| 68 |
+
| Deployed App (e.g., HF Spaces) | Only outputs / UI components shown |
|
| 69 |
+
|
| 70 |
+
**If you want to show the code:**
|
| 71 |
+
|
| 72 |
+
You can **explicitly render code** using `mo.ui.code()` or `mo.md()` with fenced code blocks:
|
| 73 |
+
|
| 74 |
+
```python
|
| 75 |
+
code = '''
|
| 76 |
+
revenue_by_month_year = query_results[QueryEnum.REVENUE_BY_MONTH_YEAR.value]
|
| 77 |
+
revenue_by_month_year
|
| 78 |
+
'''
|
| 79 |
+
|
| 80 |
+
mo.ui.code(code, language="python")
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
Or in Markdown:
|
| 84 |
+
|
| 85 |
+
````python
|
| 86 |
+
mo.md("""```python
|
| 87 |
+
revenue_by_month_year = ...
|
| 88 |
+
revenue_by_month_year
|
| 89 |
+
```""")
|
| 90 |
+
````
|
| 91 |
+
|
| 92 |
+
Or set a global config int hte app header
|
| 93 |
+
|
| 94 |
+
```py
|
| 95 |
+
__marimo__ = {
|
| 96 |
+
"hide_code": False # or True to hide all
|
| 97 |
+
}
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
### 💡 Tip:
|
| 101 |
+
|
| 102 |
+
If your app is intended as a tutorial or learning resource, you can:
|
| 103 |
+
|
| 104 |
+
- Create a separate `notebook.md` or `.ipynb` with all code visible
|
| 105 |
+
- Link to that from the main app using `mo.md("[View full notebook](./notebook.md)")`
|
| 106 |
+
- Use Marimo's UI components to conditionally show/hide code with toggles
|
| 107 |
+
|
| 108 |
+
```python
|
| 109 |
+
show_code = mo.ui.checkbox(value=False, label="Show Code")
|
| 110 |
+
|
| 111 |
+
if show_code.value:
|
| 112 |
+
mo.ui.code(code)
|
| 113 |
+
```
|