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

Add example functions section to api-server #7398

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

bisgaard-itis
Copy link
Contributor

@bisgaard-itis bisgaard-itis commented Mar 19, 2025

What's the point of this PR?

As part of out metamodeling efforts we plan to develop the concept of a function in the api server. These functions could point to concepts we already have in the api-server (studies or solvers) or to new types of functions. This PR does nothing more than setup a few files and connect a functions section in the api-server with a new functions domain in the api-server so that @wvangeit can start implementing the thing. I.e. it is a skeleton to guide the development. I.e. the functions which are introduced in this PR will eventually go away as we start to merge the real functionality for the functions.

What do these changes do?

  • Add functions section in api-server. Expose a single ping endpoint as an example
  • Add functions domain with example files of how to setup the domain.
  • Connect ping endpoint with webserver via rpc to webserver.

Related issue/s

How to test

Dev-ops checklist

@bisgaard-itis bisgaard-itis changed the title 7348 add dummy functions api Add example functions section to api-server Mar 19, 2025
@bisgaard-itis bisgaard-itis changed the title Add example functions section to api-server 👽️ Add example functions section to api-server Mar 19, 2025
@bisgaard-itis bisgaard-itis self-assigned this Mar 19, 2025
@bisgaard-itis bisgaard-itis added this to the The Awakening milestone Mar 19, 2025
@bisgaard-itis bisgaard-itis requested a review from wvangeit March 19, 2025 16:23
@bisgaard-itis bisgaard-itis marked this pull request as ready for review March 19, 2025 16:24
@bisgaard-itis
Copy link
Contributor Author

@wvangeit please let me know if anything in this example is unclear. I am very happy to extend it to make it more realistic or add some actual functionality if required.

Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 65.30612% with 17 lines in your changes missing coverage. Please review.

Project coverage is 85.14%. Comparing base (b5230f1) to head (5d277a9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7398      +/-   ##
==========================================
- Coverage   87.31%   85.14%   -2.17%     
==========================================
  Files        1712     1348     -364     
  Lines       66429    56072   -10357     
  Branches     1125      578     -547     
==========================================
- Hits        58004    47745   -10259     
- Misses       8105     8142      +37     
+ Partials      320      185     -135     
Flag Coverage Δ
integrationtests 65.30% <52.00%> (-0.01%) ⬇️
unittests 83.89% <65.30%> (-2.59%) ⬇️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library 72.10% <0.00%> (-0.16%) ⬇️
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 85.46% <ø> (ø)
agent 96.46% <ø> (ø)
api_server 90.65% <83.33%> (-0.03%) ⬇️
autoscaling 96.08% <ø> (ø)
catalog 92.14% <ø> (ø)
clusters_keeper 99.24% <ø> (ø)
dask_sidecar 91.25% <ø> (ø)
datcore_adapter 98.11% <ø> (ø)
director 76.59% <ø> (-0.10%) ⬇️
director_v2 91.30% <ø> (ø)
dynamic_scheduler 97.33% <ø> (ø)
dynamic_sidecar 90.11% <ø> (ø)
efs_guardian 89.79% <ø> (ø)
invitations 93.28% <ø> (ø)
payments 92.66% <ø> (ø)
resource_usage_tracker 89.12% <ø> (ø)
storage 84.75% <ø> (+0.46%) ⬆️
webclient ∅ <ø> (∅)
webserver 80.36% <88.00%> (-5.49%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5230f1...5d277a9. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

I'm a bit lost. What would be te final goal of this functions?
I see no reference to that

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

I am also not clear what this "function" api is. all this seems very hard-coded in the end... I thought this was something where you send a "function" to be executed in there... but this looks like you have to implement each function precisely instead...

from . import _controller_rpc


def setup_functions(app: web.Application):
Copy link
Member

Choose a reason for hiding this comment

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

setup docorator is missing here! See other setup to check this

@app_module_setup(
    __name__,
    ModuleCategory.ADDON,
    settings_name="WEBSERVER_FUNCTIONS",
    logger=_logger,
)
def setup_functions(app: web.Application) -> bool:
    ... 

Copy link
Member

Choose a reason for hiding this comment

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

Another thing that is missing is to create a settings field and mark is as DEV-FEATURE for this domain e.g.

class ApplicationSettings(BaseApplicationSettings):
  # other fields

  WEBSERVER_FUNCTIONS: Annotated[
      bool,
      Field(
          json_schema_extra={"auto_default_from_env": True, _X_DEV_FEATURE_FLAG: True}
      ),
  ] = False

@@ -44,6 +45,7 @@ def create_router(settings: ApplicationSettings):
router.include_router(
licensed_items.router, tags=["licensed-items"], prefix="/licensed-items"
)
router.include_router(functions.router, tags=["functions"], prefix="/functions")
Copy link
Member

Choose a reason for hiding this comment

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

I would then also enable this if DEV_FEATURE is enabled.

The idea is that as soon as @wvangeit merges, it can be used in master

@bisgaard-itis
Copy link
Contributor Author

bisgaard-itis commented Mar 20, 2025

I'm a bit lost. What would be te final goal of this functions? I see no reference to that

Yes, sorry. That's on me. I did not explain well in the header what exactly the goal of this PR is. I will update it

@bisgaard-itis
Copy link
Contributor Author

I am also not clear what this "function" api is. all this seems very hard-coded in the end... I thought this was something where you send a "function" to be executed in there... but this looks like you have to implement each function precisely instead...

Yes, actually this PR just introduce some "dummy" functions so Werner can start implementing the actual api and has a pattern to follow. I have updated the header of this PR with some more info

@bisgaard-itis bisgaard-itis changed the title 👽️ Add example functions section to api-server Add example functions section to api-server Mar 20, 2025
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

ok thanks for the explanation. I am still a bit unsure. but let's see.

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

Sorry, but I have doubts and issues with this approach. Please let's have chat about it. See my reasons below.

I am not convinced at all by these changes/pattern.

I believe that the current approach will just cause harm in the long run.

I see the following issues/uncertainties:

  • I did not understand the concept of a function
  • no generic interface to register, launch and get the result of a function
  • a function could also be long running (long lived), the current pattern will eventually fail (example, if the webserver is restarted)
  • why was the webserver chosen as the owner of these functions?
  • Can you please provide a schema/diagarm of how the interaction with a functions will work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example functionsapi with a single endpoint which is connected all the way to the webserver via rpc
4 participants