Skip to content

Automate jobs board with schema validation#360

Open
shibo911 wants to merge 11 commits intopybamm-team:mainfrom
shibo911:main
Open

Automate jobs board with schema validation#360
shibo911 wants to merge 11 commits intopybamm-team:mainfrom
shibo911:main

Conversation

@shibo911
Copy link
Contributor

Fixes #352

Summary

  • Jobs board is generated from YAML files under data/jobs/ using a shortcode + partials.
  • Open roles vs Archived roles split based on expires date; archived retained and collapsed by default.
  • Sorting: Open by deadline asc; Archived by expires desc.
  • Job YAML validation enforced via pre-commit using check-jsonschema + data/jobs/schema.json.
  • Styling uses theme variables with minimal overrides.

How to test

  • pre-commit run --all-files
  • hugo server -D and visit /jobs/

@netlify
Copy link

netlify bot commented Dec 22, 2025

Deploy Preview for pybamm-developer-preview ready!

Name Link
🔨 Latest commit 96237a1
🔍 Latest deploy log https://app.netlify.com/projects/pybamm-developer-preview/deploys/6950fe011cabbb000884c486
😎 Deploy Preview https://deploy-preview-360--pybamm-developer-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99
Accessibility: 100
Best Practices: 92
SEO: 91
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@agriyakhetarpal
Copy link
Member

Thanks, @shibo911! Could you please investigate the build failure?

@agriyakhetarpal
Copy link
Member

BTW, you may use nox to build the entire site instead of hugo server – that'll generate the pagefind search, too.

@shibo911
Copy link
Contributor Author

BTW, you may use nox to build the entire site instead of hugo server – that'll generate the pagefind search, too.

thanks, i will try to fix the pr

…YAML via schema without unsupported flag\n- hugo: suppress legacy GetJSON error from theme (ignoreLogs)\n- css: robust badge spacing and layout for jobs cards\n- jobs: use transform.Unmarshal for YAML loading (no GetJSON)
@shibo911
Copy link
Contributor Author

@agriyakhetarpal

Update: Build fixed; preview ready.

Fixes

  • Jobs data loader uses readFile + transform.Unmarshal for YAML (no legacy GetJSON). Only data/jobs/*.yaml are loaded; schema/template are ignored.
  • Suppressed unrelated legacy theme GetJSON error via ignoreLogs to prevent build aborts.
  • Pre-commit schema validation wired correctly (check-jsonschema with data/jobs/schema.json); pre-commit.ci passes.
  • Hardened jobs badge styling so “pill” spacing is consistent across environments.

Verification

Notes

  • Open vs Archived split and sorting work as specified; Archived collapsed by default.
  • Styling follows theme variables with minimal overrides.

Ready for review.

Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shibo911, this is a good start! There is a lot of code here and while the output looks good on the deploy preview, there are a few things to consider – please see my comments below.

Also, for an individual job, I think we should use the card shortcode to include the data, and for the fields such "100% time", "Remote", etc., these should be included as badges.

My main concern is the use of AI-written code in this PR, which is generally okay as long as the code is good, but right now there are many existing patterns in the theme that the language model you've used has not accounted for. It is necessary to implement this carefully, as there is a maintenance burden attached to this new code and we'd like it if this code were to not break over the course of the many years that this website will be maintained for.

config.yaml Outdated
Comment on lines 11 to 14
# Suppress legacy GetJSON errors originating from theme code
ignoreLogs:
- error-remote-getjson

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the GetJSON error coming from the theme code? Could you please elaborate? I don't see anything here: https://github.com/search?q=repo:scientific-python/scientific-python-hugo-theme+GetJSON&type=code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed, I added that line to test my pr locally. I think there must have been some issue while building the server thats why i added those line, I should have restored some files while pushing git but that's a terrible mistake on my end.

- id: ruff
args: ["--fix", "--show-fixes"]

# Jobs board validation (schema-based)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Jobs board validation (schema-based)

The code is self-explanatory, so this doesn't need a comment


# Jobs board validation (schema-based)
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.33.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rev: 0.33.3
rev: 0.36.0

Is there a reason for using 0.33.3 instead of the latest release available? https://github.com/python-jsonschema/check-jsonschema

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed, used the latest version

Comment on lines 8 to 11
{{/*
Load only YAML postings from data/jobs/*.yaml.
Avoid reading data/jobs/schema.json (used only for validation).
*/}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be cleaned up; it is easy to understand that the file is used only for validation is redundant for the partial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood and addressed

Comment on lines 12 to 32
{{- range (readDir "data/jobs") -}}
{{- if and (not .IsDir) (hasSuffix .Name ".yaml") (ne .Name "_TEMPLATE.yaml") -}}
{{- $path := printf "data/jobs/%s" .Name -}}
{{- $data := (readFile $path | transform.Unmarshal) -}}
{{- $key := replaceRE "\\.yaml$" "" .Name -}}
{{- $job := dict "key" $key | merge $data -}}
{{- $jobs = $jobs | append $job -}}
{{- end -}}
{{- end -}}

{{/* partition */}}
{{- $open := slice -}}
{{- $archived := slice -}}
{{- range $jobs -}}
{{- $exp := .expires -}}
{{- if or (not $exp) (ge (time $exp) $now) -}}
{{- $open = $open | append . -}}
{{- else -}}
{{- $archived = $archived | append . -}}
{{- end -}}
{{- end -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be simplified – see https://stackoverflow.com/a/33233395 for an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed. refactored the layouts/partials/jobs/list.html to simplify data loading using hugo’s built-in data mechanism, per the review suggestion

content/jobs.md Outdated
Comment on lines 34 to 37
1. Open a pull request adding a YAML file at data/jobs/ following data/jobs/_TEMPLATE.yaml.
2. Ensure dates are in YYYY-MM-DD and include a working https:// or http:// URL.
3. Optionally, also [email us](mailto:pybamm@pybamm.org) for visibility.
4. If applicable, make a payment or donation as per our policy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking this comment as we'll need to get some confirmation on the proposed flow for this. @brosaplanella would be the best person to answer this, since he opened #352.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed, added a neutral line just stating the submission instructions, about opening a PR through template.

content/jobs.md Outdated
---

Welcome to the PyBaMM Jobs Board! Here you can find current job openings related to PyBaMM and battery modeling. If you're interested in contributing to the future of battery simulation and modeling, check out the opportunities below.
Welcome to the PyBaMM Jobs Board! This page is generated from simple YAML files under data/jobs/.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bring back the previous sentence here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the code in this file was generated with AI. While we are okay with the use of AI-written code, we consider it your responsibility to thoroughly review it and address any potential mistakes. Could you please remove the comments indicative of AI and remove the redundant CSS rules from here?

Also, these styles will apply to the entire website, so we must ensure that they affect only the jobs page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed and applied the requested clean up and scoping
scoped jobs styles to jobs page and removed ai indicative and verbose comments, also avoided unnecessary global impact, now job related rules are isolated under .jobs-board

Comment on lines 60 to 66
.markdown .adm, .markdown .adm * {
color: var(--text, #f1f5f9) !important;
}
.adm a { color: var(--primary, #9ae6b4) !important; }
/* Provide a gentle dark surface without hardcoding brand colors */
.adm { background: var(--surface-2, rgba(255,255,255,0.06)) !important; }
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of !importants, we should address any dark theme problem upstream with the theme itself – I would advise against using them unless they're really needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed, removed !important and used selector specificity as advised

Comment on lines 47 to 57
<details>
<summary><h2 id="archived-roles" style="display:inline">Archived roles</h2></summary>
{{- $sortedArchived := sort $archived "expires" "desc" -}}
{{- if gt (len $sortedArchived) 0 -}}
{{- range $sortedArchived -}}
{{ partial "jobs/card.html" (dict "job" . "now" $now) }}
{{- end -}}
{{- else -}}
<p>No archived roles yet.</p>
{{- end -}}
</details>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the theme's details shortcode instead of inline HTML code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed, removed the raw HTML and used the theme's detail shortcode

@shibo911
Copy link
Contributor Author

I will work on the comments. Thank you for the thorough review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automate job board page

2 participants