Fixing pull --beta and refactoring along the way#1084
Fixing pull --beta and refactoring along the way#1084josephjclark merged 18 commits intorelease/nextfrom
Conversation
| const { OPENFN_API_KEY, OPENFN_ENDPOINT } = process.env; | ||
|
|
||
| const config: Partial<Config> = { | ||
| const cfg: Partial<Config> = { |
There was a problem hiding this comment.
This old config stuff was just a cheap way to use the old deploy API. We need to phase it out soon
|
|
||
| // TODO is outputRoot the right dir for this? | ||
| const workspace = new Workspace(outputRoot); | ||
| const config = workspace.getConfig(); |
There was a problem hiding this comment.
Not a fan of the getter - I just want to use workspace.config here. Why make it private?
packages/cli/src/pull/beta.ts
Outdated
|
|
||
| const project = Project.from('state', data, { | ||
| endpoint: config.endpoint, | ||
| repo: config, |
There was a problem hiding this comment.
The second argument here needs the same structure as new Project
So basically I'm passing state (as string, yam or json, maybe even as a file path?) and we'll load all the values from that state file. But if I want to override anything, or add context which the state file doesn't have, all that stuff just goes on the second argument.
packages/cli/src/pull/beta.ts
Outdated
| const workflowsRoot = path.resolve( | ||
| outputRoot, | ||
| project.repo?.workflowRoot ?? 'workflows' | ||
| project.repo.dirs?.workflows ?? 'workflows' |
There was a problem hiding this comment.
Shouldn't need any of this optional chaining bullshit: I want good robust config with everything defaulted
packages/project/src/Project.ts
Outdated
| // workspace-wide configuration options | ||
| // these should be shared across projects | ||
| // and saved to an openfn.yaml file | ||
| // TODO should this just be the Workspace now? |
There was a problem hiding this comment.
The hestitation is that there's a bit of circularity between Project and Workspace. I should be able to have one without the other - but they're actually coupled a bit nastily through config.
Needs more thought
|
Here's the plan to tidy some of this stuff up:
|
|
Oh and That gives you metadata about the checked out project, and config for the workspace generally We should support legacy and new file formats for a while, but always serialize to the new |
|
From reading the description. we want to use workspace class in maybe ? - run if not already run |
|
Yeah, something like that. Either the CLI can run
|
|
Really need to wrap this up so I think I'm going to pause the "a Project should reference its workspace" thing and open a new issue I think there are big improvements here, and it seems to work, so I'm going to declare victory ASAP |
|
Old yaml files, pre 0.6, are still 100% compatible. Very few tests have updated to the new structure. 👨🍳 💋 |
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| '@openfn/project': patch | |||
There was a problem hiding this comment.
I'll recycle all this into a better patch note on release
This PR fixes a bug where workspace config settings are not properly respected by pull. This must be known.
|
@doc-han When you get a chance I'd like you to have a close look over this please: partly for your opinions (this is the right thing to do right??) but also to keep you in-sync with the changes. There's more work I want to do and you might be "it" for the next ticket |
| t.is(result.content, 'x: 1'); | ||
| }); | ||
|
|
||
| test('find openfn.json', (t) => { |
There was a problem hiding this comment.
@doc-han thank you for the project integration tests! They caught an issue here which would have resulted in a big breakage 😬
doc-han
left a comment
There was a problem hiding this comment.
I don't have much issue with the code here. looks fine. my only issue has to do with some typings(Typescript) not being strict.
|
@doc-han agreed - let's try and fix those as we go. We should be striving to improve the typing and general semantics on every PR from here going forward - I welcome your contributions in cleaning this all up! |
Had to get an old state.json format for Elias and it turned into a nightmare
Basically
pullwas written before a lot of our niceWorkspaceAPIs and stuff, and was rushed out even thenAnd what's happening is the pull isn't using config properly from the openfn.yaml file
This PR basically plugs in the Workspace class to make life easier.
But I hit loads of little problems on the way - the code here is super messy and we really need to tidy up a bit
Fixes #1083
Headline changes
project.repotoproject.config{ project, workspace })AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy