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

CLI: Adaptor codegen #609

Closed
wants to merge 3 commits into from
Closed

CLI: Adaptor codegen #609

wants to merge 3 commits into from

Conversation

josephjclark
Copy link
Collaborator

@josephjclark josephjclark commented Feb 21, 2024

This PR adds a generate command to the CLI, which calls out to the AI codegen services in gen

See details in #606

At the moment this is a simplified form. It doesn't generate a full adaptor, it just generates adaptor.js with the generated code.

There are a whole host of backend changes required in gen, including:

  • A single http server which we can deploy
  • Generate code inside an existing adaptor
  • Generate for multiple endpoints

Still to do in this PR:

  • Generate from a list of endpoints in the spec (rather than passing an instruction)
  • Validate the input spec
  • Unit tests
  • The signature openfn generate adaptor dhis2 spec=./dhis2.json --endpoint=getTrackedEntityInstances is not particularly friendly. I suppose you can encode the whole request into json openfn generate adaptor ./spec.json, but really you only want to fire it once. At least, if we get it to work.
  • Add some kind of generic openfn data <url> command, or something, which basically posts a payload to an arbitrary endpoint on the python server. This is an extension hook which allows someone to easily add a new endpoint to the Python AI service and call it from the CLI without any development. The data command would load some JSON input, post it to the server (perhaps with an API key), and output the result somewhere on disk.
  • Create a template generator script in the adaptors monorepo. When generating code against the monorepo, this code generator should run first, to ensure there's a decent stub adaptor, and then inject adaptor.js and adaptor.d.ts into it. This template generator is useful even the code generator here is no adopted (and will be the death of the confusing template folder). See Build tool: generate new adaptor adaptors#19

Maybe to do later:

  • Fetch openfnAPI schemas from a url (is that a thing? Do people host their schemas?(

@josephjclark
Copy link
Collaborator Author

I'm gonna pause on this until we know what we want to do about the server (continue to develop in python or shift to js?).

@josephjclark
Copy link
Collaborator Author

Closing in favour of generic apollo command #682.

I might come back to this one day for a more user friendly adaptor generator

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.

None yet

1 participant