Skip to content

Add a cosml.build command to build a project on a cluster - #518

Open
sjoubert wants to merge 1 commit into
mainfrom
modapi_build_PROD-16371
Open

Add a cosml.build command to build a project on a cluster#518
sjoubert wants to merge 1 commit into
mainfrom
modapi_build_PROD-16371

Conversation

@sjoubert

@sjoubert sjoubert commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

This makes use of temporary project in the modeling api, unless we decide to have full support for a persistent Project resource.

Until the modeling api is publicly exposed, babylon creates a temporary port-forward via kubectl.

Design discussion points left open:

  • Missing support for the new payload file in the init command, but the actual form of the file will depend of the other discussion points
  • Do we need full support for the modapi sub-commands like for the run api? Appart from the build use case it probably won't be used much for now.
  • Name of the sub-command group(s): cosml? for separate one-shot commands, modapi/mod-api/modeling-api? for the api command wrappers
  • Do we add support for it in apply? It probably needs a toggle to avoid triggering a build each time the project data is applied.
  • Do we add first class support for the Project resource or do we keep using a temporary project for now? If we only have a ProjectBuild for now, is the project archive url better placed in a metadata field or as a sidecar.

This is part of a multi repo effort that also involves the terraform modules to have the modeling api deploy in a tenant (Cosmo-Tech/terraform-shared#31, Cosmo-Tech/terraform-tenant#41) and will require the next SDK version (12.3.0)

@sjoubert
sjoubert force-pushed the modapi_build_PROD-16371 branch from e546bcc to 349acd1 Compare August 14, 2026 08:35
@sjoubert
sjoubert requested a review from sellisd August 14, 2026 09:48
@sjoubert
sjoubert force-pushed the modapi_build_PROD-16371 branch from 349acd1 to 97a4aed Compare August 14, 2026 12:47
@sjoubert
sjoubert force-pushed the modapi_build_PROD-16371 branch 2 times, most recently from 28210d2 to 5f24078 Compare August 28, 2026 15:29
@sjoubert

sjoubert commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Code has been updated with latest design decisions:

  • Remove the separate micro-command and integrate the ProjectBuild resource into the apply macro-command
  • I still think that ProjectBuild resources should not be enabled by default, but I didn't find adding a boolean in the yaml file very easy/practical for the whole payload. So for now one has to used the --exclude projectbuild option to avoid rebuilding the project every time. Let me know if that's ok with you or if you want another behavior/way of dealing with that
  • The build log behavior is now the following:
    • I've removed the log streaming, build output is only retrieved and handled once the build is complete
    • If the build succeed, the build output is logged at the debug level. So it will be recorded in the babylon log file but not displayed in the terminal (for a standard run at info level)
    • If the build fails, the build output is logged at the error level. So it will be recorded in the babylon log file but also appear in the terminal.

@MohcineTor MohcineTor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s okay for me we can go with this approach for now using --exclude. Later, we can have a quick discussion with the Integration team to see what their preference is.

I also have a quick remark: we could change the order of the steps. We could start with building the project, then move on to organizing the solution, etc. in applay command

Comment thread Babylon/commands/macro/build_project.py Outdated
@sjoubert
sjoubert force-pushed the modapi_build_PROD-16371 branch 2 times, most recently from 93c2ca3 to 788d9a2 Compare September 2, 2026 09:56
@sjoubert
sjoubert marked this pull request as ready for review September 2, 2026 09:58
@sjoubert
sjoubert force-pushed the modapi_build_PROD-16371 branch from 788d9a2 to e6927cf Compare September 2, 2026 12:00
This makes use of temporary project in the modeling api to build a
simulator and optionnally push the resulting docker image in the tenant
registry
Until the modeling api is publicly exposed, babylon creates a temporary
port-forward via kubectl
@sjoubert
sjoubert force-pushed the modapi_build_PROD-16371 branch from e6927cf to accb458 Compare September 2, 2026 12:06
@MohcineTor
MohcineTor self-requested a review September 3, 2026 09:16

@MohcineTor MohcineTor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


# Once the modeling api is publicly exposed we should be able to remove the port-forward workaround
# and just get the target url in the babylon config instead of the service name
class ModelingAPIPortForward:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is a good idea, or at least we risk keeping this here longer than we should.

In a cosmotech cluster this works fine because we all access the cluster with almost admin priviledges, but we should not rely on this being the case! I am afraid this will become a frozen accident and will require the user (or LLM) running Babylon alwats require elevated rights.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it either but I don't have a better path until we can expose the modeling api through the gateway.
As for the cluster access, babylon already requires it to retrieve its remote state and its config (including the future modeling api url). So I'm not sure this changes things.

Comment thread Babylon/commands/macro/build_project.py
"Successful",
"Failed",
]:
time.sleep(5)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should break after some maximum if the api freezes or has any other issues. If this happens is it safe to quit babylon with an error here? or do some cleanup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup should already be done or error using the project and port-forward context manager.
I can try to add a timeout, but I'm not sure which value to use as project build time can vary a lot between project.

from click import argument, command, echo, option, style
from yaml import safe_dump, safe_load

from Babylon.commands.macro.build_project import build_project

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file is build_project, the variable is project_build, but the resource is one word (I think I can't remember now), can we simplify further, e.g. just call it build?

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.

3 participants