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

Allow a workflow to support multiple adaptor versions #610

Merged
merged 12 commits into from
Feb 23, 2024

Conversation

josephjclark
Copy link
Collaborator

@josephjclark josephjclark commented Feb 22, 2024

Closes #268

Bit tricky this one! But I think I've got it.

Every step in a workflow gets compiled by the runtime manager (the CLI or the Engine) and is given an import statement import { fn } from '@openfn/language-common'.

It's up to the linker, deep inside the runtime, to decide how how resolve this import. Should we look in the repo? Were we given an explicit mapping? What version do we want?

What usually happens is that the runtime manager (the CLI or worker) will pre-parse the workflow and make a bunch of decisions about these imports. In the CLI, for example, the user might add an explicit path to language-common. Or if someone asked for @latest, the CLI will maybe autoinstall and replace @latest with an actual version (I think).

The problem is that one list of adaptor-version mappings is compiled for the whole workflow, and that one list is shared by the linker. So if we decide that language-common is 1.0, all steps will load 1.0 regardless of what was asked for.

What this PR does is calculate this module map for each step inside the runtime based on the original input, and passes this "localised" map into the linker for each step.

It seems to work.

Sadly I can't get unit tests very close to the code without making major changes. It's actually very small tweak in a glue layer and I can't intercept in the right place.

TODO

  • Add some integration tests around this
  • Ensure autoinstall works with multiple versions
  • Maybe move the adaptor version reporting so that it better reflects what is actually loaded

Basically instead of looking up the adaptor version from the global list of options, we calculate the version for each step and pass that through to execution
This lets the runtime use the repo to install the correct versions of adaptors. It might run a little slower though
@josephjclark
Copy link
Collaborator Author

Likely issue: I think the module-overiding thing is removing path information. So if you specify an adaptor path in the linker options, it'll get blatted out and ignored. This broke the engine and will be a problem in some CLI edge cases.

I've also preferred repoDir to adaptorPaths in the engine, but I wonder if this is really the right thing to do. It might be a bit slower.

@josephjclark josephjclark marked this pull request as ready for review February 23, 2024 12:35
@josephjclark
Copy link
Collaborator Author

So this is good to go... but we can't release it until we do SOMETHING about version reporting.

At the moment the adaptor version, as currently reported, is basically a lie. So I'm going to branch off and fix #574

@josephjclark josephjclark changed the base branch from main to release/next February 23, 2024 17:41
@josephjclark josephjclark merged commit 4f5f1dd into release/next Feb 23, 2024
5 checks passed
@josephjclark josephjclark deleted the workflow-multiple-adaptors branch February 23, 2024 17:44
josephjclark added a commit that referenced this pull request Feb 23, 2024
* runtime: allow each job in a workflow to use a different adaptor version

Basically instead of looking up the adaptor version from the global list of options, we calculate the version for each step and pass that through to execution

* tests: add test of multiple versions

* engine: prefer repoDir to adaptorPaths

This lets the runtime use the repo to install the correct versions of adaptors. It might run a little slower though

* runtime: allow linker options to be passed on each job

* runtime: better mreging of linker options

* engine: update autoinstall to write paths to the plan
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.

Runtime: workflows can't handle two versions of the same adaptor
1 participant