Skip to content

testing client gen - #441

Closed
stan-dot wants to merge 54 commits into
mainfrom
364-auto-generate-rest-client-1
Closed

stan-dot wants to merge 54 commits into
mainfrom
364-auto-generate-rest-client-1

Conversation

@stan-dot

Copy link
Copy Markdown
Contributor

No description provided.

@stan-dot stan-dot self-assigned this Apr 29, 2024
@stan-dot stan-dot linked an issue Apr 29, 2024 that may be closed by this pull request
@stan-dot
stan-dot force-pushed the 364-auto-generate-rest-client-1 branch from da2e091 to 92788f5 Compare April 29, 2024 15:42
@stan-dot
stan-dot marked this pull request as ready for review April 29, 2024 16:29
@stan-dot

Copy link
Copy Markdown
Contributor Author

need to get mypy and ruff to ignore the auto-gen folder

@stan-dot

stan-dot commented May 1, 2024

Copy link
Copy Markdown
Contributor Author

rc/blueapi/cli/cli_new.py:195: error: Argument 1 to "submit_task_tasks_post" of "DefaultApi" has incompatible type "blueapi.worker.task.Task"; expected "blueapi.openapi_client.models.task.Task" [arg-type]
src/blueapi/cli/cli_new.py:200: error: Argument 1 to "update_task_worker_task_put" of "DefaultApi" has incompatible type "blueapi.service.model.WorkerTask"; expected "blueapi.openapi_client.models.worker_task.WorkerTask" [arg-type]
src/blueapi/cli/cli_new.py:230: error: Argument 1 to "set_state_worker_state_put" of "DefaultApi" has incompatible type "WorkerState"; expected "StateChangeRequest" [arg-type]
src/blueapi/cli/cli_new.py:240: error: Argument 1 to "set_state_worker_state_put" of "DefaultApi" has incompatible type "WorkerState"; expected "StateChangeRequest" [arg-type]
src/blueapi/cli/cli_new.py:257: error: Argument "state_change_request" to "set_state_worker_state_put" of "DefaultApi" has incompatible type "blueapi.service.model.StateChangeRequest"; expected "blueapi.openapi_client.models.state_change_request.StateChangeRequest" [arg-type]
src/blueapi/cli/cli_new.py:270: error: Argument "state_change_request" to "set_state_worker_state_put" of "DefaultApi" has incompatible type "blueapi.service.model.StateChangeRequest"; expected "blueapi.openapi_client.models.state_change_request.StateChangeRequest" [arg-type]
Found 6 errors in 1 file (checked 73 source files)
ERROR: InvocationError for command /opt/hostedtoolcache/Python/3.11.9/x64/bin/mypy src tests (exited with code 1)

one possible issue is the types overlap. possibly it's not duck-typed

@stan-dot

stan-dot commented May 1, 2024

Copy link
Copy Markdown
Contributor Author

potentially might need lines to delete the duplicate models and import from the original ones. but that would break the isolation

@joeshannon

Copy link
Copy Markdown
Contributor

Have we investigated if the code can be generated at "build" time with python? This is the approach we have used for autogenerated Java clients and has the advantage that the autogenerated code doesn't have to be committed as if they were source files.

@stan-dot

Copy link
Copy Markdown
Contributor Author

realization - need to nicely handle the stomp error in the CLI first (even withoutthe test)

@stan-dot

Copy link
Copy Markdown
Contributor Author

what is the expected behavior there?
image

should we be able to run the cli plans without the bus running?

@callumforrester

Copy link
Copy Markdown
Contributor

@stan-dot see this #459 and all the issues linked from it

@callumforrester

Copy link
Copy Markdown
Contributor

Have we investigated if the code can be generated at "build" time with python? This is the approach we have used for autogenerated Java clients and has the advantage that the autogenerated code doesn't have to be committed as if they were source files.

@joeshannon yes, I agree, I wonder if there is a way to generate it when we run pip install for dev and build it into the wheel for prod...

@stan-dot

Copy link
Copy Markdown
Contributor Author

This is the approach we have used for autogenerated Java clients and has the advantage that the autogenerated code doesn't have to be committed as if they were source files
why is this an advantage?

@stan-dot

Copy link
Copy Markdown
Contributor Author

In dev if you don't need a message bus simply don't define one.

but the CLI expects it @DiamondJoseph
#459 (comment)

@stan-dot

Copy link
Copy Markdown
Contributor Author

`def run_plan(
obj: dict, name: str, parameters: str | None, timeout: float | None
) -> None:
"""Run a plan with parameters"""
config: ApplicationConfig = obj["config"]
client: BlueapiRestClient = obj["rest_client"]

logger = logging.getLogger(__name__)
if config.stomp is not None:
    _message_template = StompMessagingTemplate.autoconfigured(config.stomp)
else:
    raise RuntimeError(
        "Cannot run plans without Stomp configuration to track progress"
    )
amq_client = AmqClient(_message_template)

`

@callumforrester what do you think?

@stan-dot

Copy link
Copy Markdown
Contributor Author

trying to run without the stomp listener

@stan-dot

Copy link
Copy Markdown
Contributor Author

actually mocking the stomp message bus might be one way to do this

@stan-dot

Copy link
Copy Markdown
Contributor Author

@stan-dot

Copy link
Copy Markdown
Contributor Author

proceeding with testing the microcks as it has CNCF sandbox status https://www.cncf.io/sandbox-projects/

@stan-dot

Copy link
Copy Markdown
Contributor Author

@stan-dot

Copy link
Copy Markdown
Contributor Author

stomp config conundrum

@stan-dot stan-dot closed this May 15, 2024
@stan-dot stan-dot reopened this May 15, 2024
@stan-dot

Copy link
Copy Markdown
Contributor Author

no idea why did this close

@stan-dot

Copy link
Copy Markdown
Contributor Author

pydantic v1 generator wasn't all that great to work it and only now the assumption 'not to put generated code into git' has surfaced.

idea - to work on this with the generic, hopefully better supported python generator , once the #449 is done

@stan-dot

Copy link
Copy Markdown
Contributor Author

as mentioned in the issue, this has been a learning experience, though it will be better to do this from scratch with python generator (not pydantic-v1) and from the start as without git ignored

@stan-dot stan-dot closed this May 20, 2024
@DiamondJoseph
DiamondJoseph deleted the 364-auto-generate-rest-client-1 branch September 5, 2024 10:32
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.

Auto-generate rest client

3 participants