Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current date to gantt chart #31

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .assets/timeline-gantt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ Planned and historic release dates:
|   stable2407-7 | 2025-02-06 | 2025-02-06 | | [Released](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-stable2407-7) |
|   stable2407-8 | 2025-03-03 | 2025-03-06 | | Planned |
|   stable2407-9 | 2025-04-07 | 2025-04-10 | | Planned |
|   ([5 more past, 1 more planned](CALENDAR.md)) | | | | |
|   [5 more past, 1 more planned](CALENDAR.md) | | | | |
| **stable2409** | 2024-09-02 | 2024-09-26 | 2025-09-25 | [Released](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-stable2409) |
|   stable2409-3 | 2024-12-23 | 2024-12-23 | | [Released](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-stable2409-3) |
|   stable2409-4 | 2025-01-23 | 2025-01-23 | | [Released](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-stable2409-4) |
|   stable2409-5 | 2025-02-10 | 2025-02-13 | | Planned |
|   stable2409-6 | 2025-03-10 | 2025-03-13 | | Planned |
|   ([2 more past, 7 more planned](CALENDAR.md)) | | | | |
|   [2 more past, 7 more planned](CALENDAR.md) | | | | |
| **stable2412** | 2024-11-06 | 2024-12-17 | 2025-12-16 | [Released](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-stable2412) |
|   stable2412-1 | 2025-01-29 | 2025-01-31 | | [Released](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-stable2412-1) |
|   stable2412-2 | 2025-02-17 | 2025-02-20 | | Planned |
|   stable2412-3 | 2025-03-17 | 2025-03-20 | | Planned |
|   ([9 more planned](CALENDAR.md)) | | | | |
|   [9 more planned](CALENDAR.md) | | | | |
| **stable2503** | 2025-02-17 | 2025-03-31 | 2026-03-31 | Planned |
|   stable2503-1 | 2025-04-28 | 2025-05-01 | | Planned |
|   stable2503-2 | 2025-05-26 | 2025-05-29 | | Planned |
|   ([11 more planned](CALENDAR.md)) | | | | |
|   [11 more planned](CALENDAR.md) | | | | |
| **stable2506** | 2025-05-15 | 2025-06-30 | 2026-06-30 | Planned |
|   stable2506-1 | 2025-08-04 | 2025-08-07 | | Planned |
|   stable2506-2 | 2025-09-01 | 2025-09-04 | | Planned |
|   ([11 more planned](CALENDAR.md)) | | | | |
|   [11 more planned](CALENDAR.md) | | | | |

<!-- TEMPLATE END -->

Expand Down
193 changes: 100 additions & 93 deletions scripts/update-gantt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,109 +7,116 @@
from typing import List, Dict, Any

def parse_date(date_info: Any) -> datetime:
if isinstance(date_info, str):
return datetime.fromisoformat(date_info)
elif isinstance(date_info, dict):
date_str = date_info.get('when') or date_info.get('estimated')
return datetime.fromisoformat(date_str) if date_str else None
return None
if isinstance(date_info, str):
return datetime.fromisoformat(date_info)
elif isinstance(date_info, dict):
date_str = date_info.get('when') or date_info.get('estimated')
return datetime.fromisoformat(date_str) if date_str else None
return None

COLOR_RELEASED_BAR = '#E6007A' # released version
COLOR_RELEASED_PATCH = '#E6007A' # released patch
COLOR_PLANNED_BAR = '#a3a3a3' # planned version
COLOR_PLANNED_PATCH = '#a3a3a3' # planned patch
COLOR_CURRENT_DATE = '#FF0000' # current date line

def process_releases(data: Dict) -> tuple[List[Dict], datetime, datetime]:
tasks = []
min_date = datetime.max
max_date = datetime.min
sdk_data = data.get("Polkadot SDK", {})
releases = sdk_data.get("releases", [])
for release in releases:
name = release['name']
start_date = parse_date(release['publish'])
end_date = parse_date(release['endOfLife'])
if not (start_date and end_date):
continue
min_date = min(min_date, start_date)
max_date = max(max_date, end_date)
tasks.append({
'name': name,
'start': start_date,
'end': end_date,
'color': COLOR_RELEASED_BAR if release['state'] == 'released' else COLOR_PLANNED_BAR
})
for patch in release.get('patches', []):
patch_date = parse_date(patch['publish'])
if not patch_date:
continue
patch_end = patch_date + timedelta(days=7)
max_date = max(max_date, patch_end)
is_planned = isinstance(patch['publish'], dict) and 'estimated' in patch['publish']
tasks.append({
'name': patch['name'].split('-')[1],
'start': patch_date,
'end': patch_end,
'color': COLOR_PLANNED_PATCH if is_planned else COLOR_RELEASED_PATCH
})
return tasks, min_date, max_date
tasks = []
min_date = datetime.max
max_date = datetime.min
sdk_data = data.get("Polkadot SDK", {})
releases = sdk_data.get("releases", [])
for release in releases:
name = release['name']
start_date = parse_date(release['publish'])
end_date = parse_date(release['endOfLife'])
if not (start_date and end_date):
continue
min_date = min(min_date, start_date)
max_date = max(max_date, end_date)
tasks.append({
'name': name,
'start': start_date,
'end': end_date,
'color': COLOR_RELEASED_BAR if release['state'] == 'released' else COLOR_PLANNED_BAR
})
for patch in release.get('patches', []):
patch_date = parse_date(patch['publish'])
if not patch_date:
continue
patch_end = patch_date + timedelta(days=7)
max_date = max(max_date, patch_end)
is_planned = isinstance(patch['publish'], dict) and 'estimated' in patch['publish']
tasks.append({
'name': patch['name'].split('-')[1],
'start': patch_date,
'end': patch_end,
'color': COLOR_PLANNED_PATCH if is_planned else COLOR_RELEASED_PATCH
})
return tasks, min_date, max_date

def create_gantt_chart(tasks: List[Dict], min_date: datetime, max_date: datetime, output: str):
fig, ax = plt.subplots(figsize=(15, 8))

# Plot bars
for idx, task in enumerate(tasks):
ax.barh(idx,
(task['end'] - task['start']).days,
left=task['start'],
color=task['color'],
alpha=0.8)

# Customize axis
ax.set_ylim(-0.5, len(tasks) - 0.5)
ax.set_yticks(range(len(tasks)))
ax.set_yticklabels(['stable\n'+t['name'].replace('stable', '') if 'stable' in t['name'] else '' for t in tasks], fontsize=15)

# Format dates
ax.xaxis.set_major_locator(mdates.MonthLocator())
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))
plt.xticks(rotation=45)

# Add grid and title
ax.grid(True, axis='x', alpha=0.3)
ax.set_title('Polkadot SDK Release Timeline', pad=12)

# Adjust layout and save
plt.tight_layout()
plt.savefig(output, dpi=300, bbox_inches='tight')
plt.close()
fig, ax = plt.subplots(figsize=(15, 8))

# Plot bars
for idx, task in enumerate(tasks):
ax.barh(idx,
(task['end'] - task['start']).days,
left=task['start'],
color=task['color'],
alpha=0.8)

# Add current date line
current_date = datetime.now()
if min_date <= current_date <= max_date:
ax.axvline(x=current_date, color=COLOR_CURRENT_DATE, linestyle='--', linewidth=1, label='Current Date', dashes=(5, 5))
ax.legend()

# Customize axis
ax.set_ylim(-0.5, len(tasks) - 0.5)
ax.set_yticks(range(len(tasks)))
ax.set_yticklabels(['stable\n'+t['name'].replace('stable', '') if 'stable' in t['name'] else '' for t in tasks], fontsize=15)

# Format dates
ax.xaxis.set_major_locator(mdates.MonthLocator())
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))
plt.xticks(rotation=45)

# Add grid and title
ax.grid(True, axis='x', alpha=0.3)
ax.set_title('Polkadot SDK Release Timeline', pad=12)

# Adjust layout and save
plt.tight_layout()
plt.savefig(output, dpi=300, bbox_inches='tight')
plt.close()

def main():
parser = argparse.ArgumentParser(description='Generate release timeline Gantt chart')
parser.add_argument('input', help='Input JSON file path')
parser.add_argument('-o', '--output', help='Output PNG file path', default='gantt.png')
args = parser.parse_args()
try:
with open(args.input, 'r') as f:
data = json.load(f)
except Exception as e:
print(f"Error reading input file: {e}", file=sys.stderr)
sys.exit(1)
tasks, min_date, max_date = process_releases(data)
create_gantt_chart(tasks, min_date, max_date, args.output)
parser = argparse.ArgumentParser(description='Generate release timeline Gantt chart')
parser.add_argument('input', help='Input JSON file path')
parser.add_argument('-o', '--output', help='Output PNG file path', default='gantt.png')
args = parser.parse_args()
try:
with open(args.input, 'r') as f:
data = json.load(f)
except Exception as e:
print(f"Error reading input file: {e}", file=sys.stderr)
sys.exit(1)
tasks, min_date, max_date = process_releases(data)
create_gantt_chart(tasks, min_date, max_date, args.output)

if __name__ == '__main__':
main()
main()
6 changes: 3 additions & 3 deletions scripts/update-readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def generate_markdown_table(data: Dict[str, Any], max_patches=3) -> str:

if len(past_patches) > max_patches or len(future_patches) > max_patches:
if len(past_patches) > max_patches:
table += f"| &nbsp;&nbsp;([{len(past_patches) - max_patches} more past"
table += f"| &nbsp;&nbsp;[{len(past_patches) - max_patches} more past"
if len(past_patches) > max_patches and len(future_patches) > max_patches:
table += ", "
else:
table += "| &nbsp;&nbsp;(["
table += "| &nbsp;&nbsp;["
if len(future_patches) > max_patches:
table += f"{len(future_patches) - max_patches} more planned"
table += "](CALENDAR.md)) | | | | |\n"
table += "](CALENDAR.md) | | | | |\n"

return table

Expand Down