Skip to content

Simplify BlueapiClient creation #1015

Closed

Description

@RJCD-Diamond

Establishing a blueapi client setup to create tasks can be done from:

Establishing:

  • StompClient()
  • EventBusClient()
  • BlueapiRestClient()
  • RestConfig()
    and finally
  • BlueapiClient()

alternatively it can be done from the BlueapiClient.from_config() but that is also complex, and I have not succeeded in getting it working.

This process could be simplified so that either you can do:

BlueapiClient.load_from_yaml(PATHTOYAML)
or
BlueapiClient.from_dict(dict) where the dict contains the same information as the yaml

Or simplified in such a way that you can give it the minimal amount of information, and number of steps to get it setup

Acceptance Criteria

  • Specific criteria that will be used to judge if the issue is fixed

Activity

  1. callumforrester commented on May 29, 2025

    @callumforrester
    Contributor

    @RJCD-Diamond what complexities have you encountered in from_config? That is meant to be the easy path because it's type hinted, so your IDE should tell you what config is needed, what the field names are, which ones are strings, ints, etc. You'd lose all of that if you pass in a dict.

    Also possibly related to #402

  2. RJCD-Diamond commented on Jun 2, 2025

    @RJCD-Diamond
    ContributorAuthor

    @callumforrester

    The way I am using BlueapiClient.from_config() requires the following lines:

    blueapi_config_path = Path(PATHTOCONFIGYAML)
    config_loader = ConfigLoader(ApplicationConfig)
    config_loader.use_values_from_yaml(blueapi_config_path)
    loaded_config = config_loader.load()
    client = BlueapiClient.from_config(loaded_config)

    Please advise if there is a more straightforward way of doing it from a config? But if not, would be good to have a oneliner BlueapiClient.from_yaml(PATHTOYAML) Yes somewhat related to #402

  3. callumforrester commented on Jun 4, 2025

    @callumforrester
    Contributor

    @RJCD-Diamond Ah I see, you already have YAML config, I was imagining something like

    client = BlueapiClient.from_config(ApplicationConfig(api=ApiConfig(host="...", protocol="https"), stomp=StompConfig(host="...")))

    If you want to pull it from the same YAML file you use for the terminal then yes, I agree, we should have a from_yaml function or similar. The following is a slightly more flexible compromise too:

    client = BlueapiClient.from_config(ConfigLoader.from_yaml(blueapi_config_path))
  4. tpoliaw commented on Feb 23, 2026

    @tpoliaw
    Contributor

    There is now a from_config_file(str|Path) method to create a client. With upcoming changes (#1395) may also soon be a for_url method that doesn't require config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions