Skip to content

Purge unsupported adaptors in metadata cli with version-aware caching #953

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

Merged
merged 11 commits into from
Jul 8, 2025

Conversation

stuartc
Copy link
Member

@stuartc stuartc commented Jul 3, 2025

Short Description

When Lightning requests metadata via the CLI, adaptors that don't support metadata are downloaded but never removed, wasting space and causing issues in container environments.

Fixes #952
Re: OpenFn/lightning#3351

Implementation Details

  • Removes adaptors that don't support metadata after download
  • Remembers unsupported adaptors per major.minor version to avoid unnecessary future downloads
  • --keep-unsupported flag allows opting out of automatic removal
  • Uses npm uninstall instead of manual file deletion

QA Notes

Still needs to be hand tested!

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Release branch checklist

Delete this section if this is not a release PR.

If this IS a release branch:

  • Run pnpm changeset version from root to bump versions
  • Run pnpm install
  • Commit the new version numbers
  • Run pnpm changeset tag to generate tags
  • Push tags git push --tags

Tags may need updating if commits come in after the tags are first generated.

- Auto-remove adaptors that don't support metadata to prevent memory leaks
- Cache unsupported adaptors per major.minor version to avoid unnecessary downloads
- Add --keep-unsupported flag to opt out of automatic purging
- Comprehensive test coverage for version comparison logic

Addresses #952 and OpenFn/lightning#3351
@github-project-automation github-project-automation bot moved this to New Issues in v2 Jul 3, 2025
@josephjclark josephjclark changed the base branch from main to release/next July 4, 2025 17:57
Base automatically changed from release/next to main July 6, 2025 17:22

const getPath = (repoDir: string, key: string) => `${repoDir}/meta/${key}.json`;
const CACHE_DIR = '.cli-cache';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Phew, glad I checked this. This is incorrect.

.cli-cache is created by the CLI when running a workflow. It's created in the same folder as workflow.json, and it saves the outputs of each step in the workflow. Think of it like a local dataclip cache. It makes it easy to re-run a workflow from step 18 without having to manually build the right state object.

The metadata cache lives in a global CLI metadata folder called The Repo. This is where adaptors autoinstalled to.

Because the repo existed before the local dataclip cache, when I wanted a cache for the metadata service I added it to this repo. And to be fair I still think it's the correct behaviour - the metadata cache is global to a credential, if that makes sense.

So I'm pretty much going to revert this little change (which may also fix the broken tests)

in unit tests sometimes autoinstalled adaptors don't have a dependencies object. I don't think this affects anything in prod
@josephjclark josephjclark marked this pull request as ready for review July 7, 2025 15:45
@josephjclark josephjclark merged commit a2208de into main Jul 8, 2025
9 checks passed
@josephjclark josephjclark deleted the 952-metadata-purge-unsupported branch July 8, 2025 08:43
@github-project-automation github-project-automation bot moved this from New Issues to Done in v2 Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

CLI to purge packages that do not support metadata from disc
2 participants