Commit 4907bbc909
4907bbc909a9b0a3e1b34277c99fefb4b2cbe5ae
parent: c094cb2a27
Unsigned
cmc <hello@cleberg.net> · 2025-04-05 18:29 UTC
committer: <noreply@github.com>
test ruff-action (#4)
* test ruff-action
* Commit from GitHub Actions (Ruff)
* reduce to one python version
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Layout: unified · split
.github/workflows/pylint.yml
deleted
−26
| @@ -1,26 +0,0 @@ |
| 1 | | name: Pylint |
| 2 | | |
| 3 | | on: |
| 4 | | push: |
| 5 | | paths: |
| 6 | | - '**.py' |
| 7 | | |
| 8 | | jobs: |
| 9 | | build: |
| 10 | | runs-on: ubuntu-latest |
| 11 | | strategy: |
| 12 | | matrix: |
| 13 | | python-version: ["3.8", "3.9", "3.10"] |
| 14 | | steps: |
| 15 | | - uses: actions/checkout@v4 |
| 16 | | - name: Set up Python ${{ matrix.python-version }} |
| 17 | | uses: actions/setup-python@v3 |
| 18 | | with: |
| 19 | | python-version: ${{ matrix.python-version }} |
| 20 | | - name: Install dependencies |
| 21 | | run: | |
| 22 | | python -m pip install --upgrade pip |
| 23 | | pip install pylint pandas plotly |
| 24 | | - name: Analysing the code with pylint |
| 25 | | run: | |
| 26 | | pylint $(git ls-files '*.py') |
.github/workflows/ruff.yml
added
+37
| @@ -0,0 +1,37 @@ |
| 1 | name: Ruff |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | paths: |
| 6 | - '**.py' |
| 7 | |
| 8 | jobs: |
| 9 | build: |
| 10 | runs-on: ubuntu-latest |
| 11 | strategy: |
| 12 | matrix: |
| 13 | python-version: ["3.x"] |
| 14 | steps: |
| 15 | - uses: actions/checkout@v4 |
| 16 | - name: Set up Python ${{ matrix.python-version }} |
| 17 | uses: actions/setup-python@v5 |
| 18 | with: |
| 19 | python-version: ${{ matrix.python-version }} |
| 20 | ref: ${{ github.event.pull_request.head.ref }} |
| 21 | - name: Install dependencies |
| 22 | run: | |
| 23 | python -m pip install --upgrade pip |
| 24 | pip install pandas plotly |
| 25 | - name: Install Ruff |
| 26 | uses: astral-sh/ruff-action@v3.2.2 |
| 27 | - name: Ruff Actions |
| 28 | run: | |
| 29 | ruff check --fix |
| 30 | ruff format |
| 31 | - name: Add and Commit |
| 32 | uses: EndBug/add-and-commit@v9 |
| 33 | env: |
| 34 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 35 | with: |
| 36 | default_author: github_actions |
| 37 | pathspec_error_handling: ignore |
utils/salary_visualization.py
+20 −16
| @@ -10,10 +10,11 @@ from pandas import read_csv as pd_read_csv |
| 10 | 10 | import pandas as pd |
| 11 | 11 | import plotly.graph_objs as go |
| 12 | 12 | |
| 13 | | locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') |
| 13 | locale.setlocale(locale.LC_ALL, "en_US.UTF-8") |
| 14 | 14 | |
| 15 | 15 | # Read the CSV file |
| 16 | | df = pd_read_csv('~/git/cleberg.net/theme/static/salary.csv') |
| 16 | df = pd_read_csv("~/git/cleberg.net/theme/static/salary.csv") |
| 17 | |
| 17 | 18 | |
| 18 | 19 | def format_currency(value: float) -> str: |
| 19 | 20 | """ |
| @@ -27,11 +28,13 @@ def format_currency(value: float) -> str: |
| 27 | 28 | """ |
| 28 | 29 | return f"${value:,.2f}" |
| 29 | 30 | |
| 31 | |
| 30 | 32 | # Reverse the order of the DataFrame |
| 31 | 33 | df = df.iloc[::-1].reset_index(drop=True) |
| 32 | 34 | |
| 33 | 35 | # Calculate the percentage increase |
| 34 | | df['Percentage Increase'] = df['Salary'].pct_change() * 100 |
| 36 | df["Percentage Increase"] = df["Salary"].pct_change() * 100 |
| 37 | |
| 35 | 38 | |
| 36 | 39 | def create_trace(row: pd.Series) -> go.Scatter: |
| 37 | 40 | """ |
| @@ -44,20 +47,21 @@ def create_trace(row: pd.Series) -> go.Scatter: |
| 44 | 47 | go.Scatter: The created scatter plot trace. |
| 45 | 48 | """ |
| 46 | 49 | title_company = f"{row['Title']} ({row['Company']})" |
| 47 | | salary_formatted = format_currency(row['Salary']) |
| 48 | | if pd.notna(row['Percentage Increase']): |
| 50 | salary_formatted = format_currency(row["Salary"]) |
| 51 | if pd.notna(row["Percentage Increase"]): |
| 49 | 52 | text = f"{salary_formatted} ({row['Percentage Increase']:.2f}%)" |
| 50 | 53 | else: |
| 51 | 54 | text = salary_formatted |
| 52 | 55 | return go.Scatter( |
| 53 | | x=[row['Start'], row['End']], |
| 54 | | y=[row['Salary'], row['Salary']], |
| 56 | x=[row["Start"], row["End"]], |
| 57 | y=[row["Salary"], row["Salary"]], |
| 55 | 58 | text=[text], |
| 56 | | mode='lines+text', |
| 59 | mode="lines+text", |
| 57 | 60 | name=title_company, |
| 58 | | textposition='top center' |
| 61 | textposition="top center", |
| 59 | 62 | ) |
| 60 | 63 | |
| 64 | |
| 61 | 65 | # Initialize the plot |
| 62 | 66 | fig = go.Figure() |
| 63 | 67 | |
| @@ -70,16 +74,16 @@ fig.update_layout( |
| 70 | 74 | title="Salary Data Over Time (annualized)", |
| 71 | 75 | xaxis_title="Time", |
| 72 | 76 | yaxis_title="Salary", |
| 73 | | font={"family": 'monospace', "size": 16}, |
| 77 | font={"family": "monospace", "size": 16}, |
| 74 | 78 | margin={"l": 50, "r": 50, "t": 50, "b": 100}, |
| 75 | 79 | legend={ |
| 76 | | "orientation": 'h', |
| 77 | | "yanchor": 'top', |
| 78 | | "y": -0.3, |
| 79 | | "xanchor": 'center', |
| 80 | | "x": 0.5 |
| 80 | "orientation": "h", |
| 81 | "yanchor": "top", |
| 82 | "y": -0.3, |
| 83 | "xanchor": "center", |
| 84 | "x": 0.5, |
| 81 | 85 | }, |
| 82 | | height=800 |
| 86 | height=800, |
| 83 | 87 | ) |
| 84 | 88 | |
| 85 | 89 | # Display the plot |