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 @@
1name: Pylint
2
3on:
4 push:
5 paths:
6 - '**.py'
7
8jobs:
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 @@
1name: Ruff
2
3on:
4 push:
5 paths:
6 - '**.py'
7
8jobs:
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
1010import pandas as pd
1111import plotly.graph_objs as go
1212
13locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
13locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
1414
1515# Read the CSV file
16df = pd_read_csv('~/git/cleberg.net/theme/static/salary.csv')
16df = pd_read_csv("~/git/cleberg.net/theme/static/salary.csv")
17
1718
1819def format_currency(value: float) -> str:
1920 """
@@ -27,11 +28,13 @@ def format_currency(value: float) -> str:
2728 """
2829 return f"${value:,.2f}"
2930
31
3032# Reverse the order of the DataFrame
3133df = df.iloc[::-1].reset_index(drop=True)
3234
3335# Calculate the percentage increase
34df['Percentage Increase'] = df['Salary'].pct_change() * 100
36df["Percentage Increase"] = df["Salary"].pct_change() * 100
37
3538
3639def create_trace(row: pd.Series) -> go.Scatter:
3740 """
@@ -44,20 +47,21 @@ def create_trace(row: pd.Series) -> go.Scatter:
4447 go.Scatter: The created scatter plot trace.
4548 """
4649 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"]):
4952 text = f"{salary_formatted} ({row['Percentage Increase']:.2f}%)"
5053 else:
5154 text = salary_formatted
5255 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"]],
5558 text=[text],
56 mode='lines+text',
59 mode="lines+text",
5760 name=title_company,
58 textposition='top center'
61 textposition="top center",
5962 )
6063
64
6165# Initialize the plot
6266fig = go.Figure()
6367
@@ -70,16 +74,16 @@ fig.update_layout(
7074 title="Salary Data Over Time (annualized)",
7175 xaxis_title="Time",
7276 yaxis_title="Salary",
73 font={"family": 'monospace', "size": 16},
77 font={"family": "monospace", "size": 16},
7478 margin={"l": 50, "r": 50, "t": 50, "b": 100},
7579 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,
8185 },
82 height=800
86 height=800,
8387)
8488
8589# Display the plot