mirror of
https://github.com/PR0M3TH3AN/python_charts.git
synced 2026-10-31 10:50:39 +00:00
Update AGENTS.md and scripts for global dependency installation
- Revise instructions in AGENTS.md to clarify that Python scripts should be run via `startup.sh`, which now installs dependencies globally. - Enhance project overview and command sections for better clarity on usage. - Update coding standards to reflect Python version requirements and Bash script practices. - Improve formatting and organization of command examples for better readability.
This commit is contained in:
1 parent
0b491c4416
commit
a1cf3c888a
5 files changed
+118
-135
No files matched your search
@@ -1,12 +1,10 @@
|
||||
# Lagged Oil–Unemployment Chart
|
||||
# Python Charts
|
||||
|
||||
A self-contained toolkit that:
|
||||
This initial chart is a self-contained toolkit that:
|
||||
|
||||
* Fetches U.S. unemployment rate (UNRATE) and WTI crude oil price (DCOILWTICO) from FRED
|
||||
* Stores the series in a local SQLite database (`data/fred.db`)
|
||||
* Produces a dual-axis plot of unemployment vs. lagged oil price, with customizable lag, date range, and styling
|
||||
|
||||

|
||||
* Fetches U.S. unemployment rate (UNRATE) and WTI crude oil price (DCOILWTICO) from FRED
|
||||
* Stores the series in a local SQLite database (`data/fred.db`)
|
||||
* Produces a dual-axis plot of unemployment vs. lagged oil price, with customizable lag, date range, and styling
|
||||
|
||||
---
|
||||
|
||||
@@ -18,17 +16,19 @@ git clone https://github.com/your-org/python_charts.git
|
||||
cd python_charts
|
||||
|
||||
# One-command: install deps, download data, and plot
|
||||
./startup.sh python scripts/lagged_oil_unrate_chart_styled.py \
|
||||
--offset 12 --end 2025-05-31 --extend-years 5
|
||||
```
|
||||
./startup.sh --offset 12 --end 2025-05-31 --extend-years 5
|
||||
````
|
||||
|
||||
This will:
|
||||
|
||||
1. Create (or reuse) a Python 3 virtual environment (`venv/`)
|
||||
2. Upgrade `pip` & `setuptools` (providing `distutils` support)
|
||||
3. Install required packages (offline wheelhouse first, PyPI fallback)
|
||||
4. Download UNRATE & DCOILWTICO into `data/fred.db` if missing
|
||||
5. Generate the chart with a 12-month oil lead, extending the x-axis by 5 years
|
||||
1. Upgrade `pip` & `setuptools` globally
|
||||
2. Install required packages from `requirements.txt` via
|
||||
|
||||
```bash
|
||||
pip install --upgrade -r requirements.txt
|
||||
```
|
||||
3. Download UNRATE & DCOILWTICO into `data/fred.db` if missing
|
||||
4. Generate the chart with a 12-month oil lead, extending the x-axis by 5 years
|
||||
|
||||
---
|
||||
|
||||
@@ -37,46 +37,28 @@ This will:
|
||||
```
|
||||
python_charts/
|
||||
├── data/
|
||||
│ └── fred.db # Local FRED snapshot (SQLite)
|
||||
│ └── fred.db # Local FRED snapshot (SQLite)
|
||||
├── scripts/
|
||||
│ ├── refresh_data.py # Download and store FRED series
|
||||
│ ├── refresh_data.py # Download and store FRED series
|
||||
│ ├── lagged_oil_unrate_chart_styled.py # Plotting script
|
||||
│ └── pyproject.toml # Packaging metadata
|
||||
├── startup.sh # Bootstraps venv, deps, data, and runs commands
|
||||
├── requirements.txt # Python dependencies
|
||||
└── README.md # This file
|
||||
│ └── pyproject.toml # Packaging metadata
|
||||
├── Makefile # High-level targets (install, plot, etc.)
|
||||
├── startup.sh # Installs deps globally, fetches data, runs commands
|
||||
├── requirements.txt # Python dependencies
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Installation & Setup
|
||||
|
||||
1. **Ensure** you have Python 3.8+ installed on your system.
|
||||
2. **Clone** and navigate into the project:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/your-org/python_charts.git
|
||||
cd python_charts
|
||||
```
|
||||
3. **Make** the startup script executable:
|
||||
|
||||
```bash
|
||||
chmod +x startup.sh
|
||||
```
|
||||
|
||||
> On first run, `startup.sh` will build the environment, install dependencies, and pull data.
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ Usage
|
||||
|
||||
### Refresh FRED data
|
||||
|
||||
```bash
|
||||
./startup.sh python scripts/refresh_data.py
|
||||
./startup.sh scripts/refresh_data.py
|
||||
```
|
||||
|
||||
Downloads the full UNRATE and WTI series (from 1948 to today) into `data/fred.db`.
|
||||
Downloads UNRATE and WTI series (from 1948 to today) into `data/fred.db`.
|
||||
|
||||
### Generate the chart
|
||||
|
||||
@@ -84,17 +66,16 @@ Downloads the full UNRATE and WTI series (from 1948 to today) into `data/fred.db
|
||||
# Default 18-month lag
|
||||
./startup.sh
|
||||
|
||||
# Custom lag, range, and extension
|
||||
./startup.sh python scripts/lagged_oil_unrate_chart_styled.py \
|
||||
--offset 6 --start 1980-01-01 --end 2025-05-31 --extend-years 2
|
||||
# Custom lag, date range, and extension
|
||||
./startup.sh --offset 6 --start 1980-01-01 --end 2025-05-31 --extend-years 2
|
||||
```
|
||||
|
||||
| Option | Description |
|
||||
| ---------------- | --------------------------------------------------------- |
|
||||
| `--offset` | Lag in months (positive = oil leads; negative = oil lags) |
|
||||
| `--start` | Start date (YYYY-MM-DD) |
|
||||
| `--end` | End date (YYYY-MM-DD) |
|
||||
| `--extend-years` | Years to extend the x-axis beyond the end date |
|
||||
| Option | Description |
|
||||
| ---------------- | ----------------------------------------------- |
|
||||
| `--offset` | Lag in months (pos = oil leads; neg = oil lags) |
|
||||
| `--start` | Start date (YYYY-MM-DD) |
|
||||
| `--end` | End date (YYYY-MM-DD) |
|
||||
| `--extend-years` | Years to extend the x-axis beyond the end date |
|
||||
|
||||
---
|
||||
|
||||
@@ -105,7 +86,7 @@ Downloads the full UNRATE and WTI series (from 1948 to today) into `data/fred.db
|
||||
|
||||
* Left y-axis: unemployment rate (%) from 3 to 15%, ticks every 2%.
|
||||
* Right y-axis: log scale oil price (USD), doubling ticks from \$3 upward.
|
||||
* X-axis: years, major tick every 5 years, minor tick every year.
|
||||
* X-axis: major tick every 5 years, minor tick every year.
|
||||
|
||||
---
|
||||
|
||||
@@ -121,18 +102,17 @@ lxml>=4.6.0
|
||||
python-dateutil>=2.8.1
|
||||
```
|
||||
|
||||
`startup.sh` also upgrades `pip` & `setuptools` to ensure `distutils` is available.
|
||||
|
||||
---
|
||||
|
||||
## 🛡️ Troubleshooting
|
||||
|
||||
* **ModuleNotFoundError: distutils**: resolved automatically by upgrading `setuptools` in `startup.sh`.
|
||||
* **Database not found**: run `./startup.sh python scripts/refresh_data.py` to populate `data/fred.db`.
|
||||
* **Virtual-env issues**: delete `venv/` and re-run `startup.sh`.
|
||||
* **ModuleNotFoundError: distutils**: resolved by `pip install --upgrade setuptools`.
|
||||
* **Database not found**: run `./startup.sh scripts/refresh_data.py`.
|
||||
* **Permission errors**: ensure write access to the project directory.
|
||||
|
||||
---
|
||||
|
||||
## 📄 License
|
||||
|
||||
This project is released under the MIT License. See [LICENSE](LICENSE) for details.
|
||||
Released under the MIT License. See [LICENSE](LICENSE) for details.
|
||||
|
||||
Reference in new issue
Block a user