Skip to content

Conversation

@mrnicegyu11
Copy link
Member

@mrnicegyu11 mrnicegyu11 commented Apr 16, 2025

What do these changes do?

For me, it is always confusing to not be able to identify classic (sometimes called legacy, I mean before-dy-sidecar) services from the postgres DB.

FYI: I don't have my heart set on merging this PR. I can run it locally from my fork and can point dv0 to the registry.osparc.io endpoint to compile the necessary information on my local machine in the local postgres. I am presenting this here simply for your consideration and as an informer. Maybe someone finds it useful to have this information in sight.

Related issue/s

ITISFoundation/osparc-issues#1866

How to test

Dev-ops checklist

@mrnicegyu11 mrnicegyu11 added a:director issue related with the director service a:database associated to postgres service and postgres-database package a:catalog catalog service labels Apr 16, 2025
@mrnicegyu11 mrnicegyu11 added this to the Pauwel Kwak milestone Apr 16, 2025
@mrnicegyu11 mrnicegyu11 self-assigned this Apr 16, 2025
@codecov
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 86.56%. Comparing base (b4ffe76) to head (97b267a).
Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7542      +/-   ##
==========================================
- Coverage   87.47%   86.56%   -0.91%     
==========================================
  Files        1742     1327     -415     
  Lines       67432    54372   -13060     
  Branches     1144      380     -764     
==========================================
- Hits        58987    47069   -11918     
+ Misses       8124     7185     -939     
+ Partials      321      118     -203     
Flag Coverage Δ
integrationtests 64.79% <100.00%> (-0.51%) ⬇️
unittests 85.41% <72.72%> (-1.26%) ⬇️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library 85.26% <ø> (ø)
pkg_postgres_database 88.18% <ø> (ø)
pkg_service_integration 70.03% <ø> (ø)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 85.40% <ø> (ø)
agent 96.46% <ø> (ø)
api_server 90.26% <ø> (ø)
autoscaling 96.08% <ø> (ø)
catalog 92.52% <100.00%> (+<0.01%) ⬆️
clusters_keeper 99.24% <ø> (ø)
dask_sidecar 91.29% <ø> (ø)
datcore_adapter 98.12% <ø> (ø)
director 76.61% <50.00%> (-0.26%) ⬇️
director_v2 89.66% <ø> (-1.64%) ⬇️
dynamic_scheduler 97.40% <ø> (ø)
dynamic_sidecar 90.11% <100.00%> (ø)
efs_guardian 89.79% <ø> (ø)
invitations 93.28% <ø> (ø)
payments 92.66% <ø> (ø)
resource_usage_tracker 89.18% <ø> (-0.06%) ⬇️
storage 87.70% <ø> (+0.10%) ⬆️
webclient ∅ <ø> (∅)
webserver 81.26% <ø> (-4.68%) ⬇️

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 b4ffe76...97b267a. 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.

@mrnicegyu11 mrnicegyu11 marked this pull request as ready for review April 16, 2025 12:08
@sonarqubecloud
Copy link

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

thx! I like the idea and you triggered some interesting use cases that will allow me to extend the catalog but I left some caution notes.

At first sight, these changes will have no effect on the service_meta_data table of current deploys (because of point 1 in my comment) but I can modify the background task to identify editable and non-editable.

Nonetheless, we should double check

  1. added columns in ServiceMetaDataPublished
  2. heuristics in the director that determines that this service is "legacy" (BTW have you checked how is done in the directorv2/sidecars ?)

await services_repo.create_or_update_service(
ServiceMetaDataDBCreate(
**service_metadata.model_dump(exclude_unset=True), owner=owner_gid
**service_metadata.model_dump(exclude_unset=True, exclude={""}),
Copy link
Member

Choose a reason for hiding this comment

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

what is this exclude={""} ?

if not key.startswith("io.simcore."):
if not key.startswith("io.simcore.") and not key.startswith(
"simcore.service."
): # Keeping "simcore.service." adds additonally input_paths, output_paths, state_paths
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 add some tests on these conditions.
how can we guarantee these heuristics are not discarding other services or future services?
is there any other way e.g. via intergration-version to more reliably identify "legacy dynamic-service"?

label_data = json.loads(labels[key])
for label_key in label_data:
if isinstance(
label_key, dict
Copy link
Member

Choose a reason for hiding this comment

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

  • AFAIK a dict can only use has hashable types as keys, i.e.
>>> d = {}
>>> d[d] = 33
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'

so the only case i can imagine is that label_data is a list[dict| ... ] or some equivalent iterable that might return dicts.
Is this condition ONLY applicable to "simcore.service." ?

Copy link
Member Author

Choose a reason for hiding this comment

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

label_data is in fact sometimes a list of dicts ;)

alias="progress_regexp",
description="regexp pattern for detecting computational service's progress",
)
inputs_path: str | None = Field(
Copy link
Member

Choose a reason for hiding this comment

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

is this a Path?

op.add_column(
"services_meta_data",
sa.Column(
"is_classic_dynamic_service",
Copy link
Member

Choose a reason for hiding this comment

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

The purpose of copying certain labels from the image registry into columns in the service_meta_data table is threefold:

  • To retain a local copy of available registry services (e.g. identifiers).
  • To allow certain fields to be editable (e.g., service owners can modify the original description. SEE also the columns doc-ed as (editable) ).
  • To serve as a searchable cache, avoiding direct dependency on the registry service.

A flag like is_classic_dynamic_service is non-editable, as it reflects an immutable property (unlike, say, a description). While I'm not entirely fond of including it, I acknowledge its usefulness.

But now we face a couple of challenges to solve:

  1. Update of Services: The background task does not overwrite existing rows for services already present in the table. This is intentional, to preserve user-editable fields (e.g., if a user updates a service description, it shouldn't be reverted). As a result, flags like is_classic_dynamic_service will only be updated for new services or from an empty table.
  2. Single Source of Truth: Other simcore-services (e.g., director-v2, sidecar, etc.) must consistently rely on this flag as the single source of truth, rather than applying their own heuristics or deriving the same information independently.

)
inputs_path: str | None = Field(
None,
description="if this is present, the service is a modern style dv2 dynamic service",
Copy link
Member

Choose a reason for hiding this comment

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

If so, I am surprised that was not already here ...
CAREFUL with changes in this class since it is coupled in many projects. Specifically with the .osparc/metadata.yml file used in OOIL

https://github.com/itisfoundation/osparc-simcore/blob/c37d45b4ad9987eb30c6c3b1958f7d3e908354d5/packages/service-integration/src/service_integration/osparc_config.py#L99-L104

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 generally against such a thing for the following reasons:

  • the services metadata table entries are made to be editable, this is now something different
  • this will need to be synchronised, I see in another PR and also after our discussions that we are upgrading these services. How will this be handled?

I think there is already some code in the dynamic sidecar and director-v2 in order to find out whether a service is legacy or not. It is preferable to have a function for this as this is "dynamic" if you allow the term and not something cached in the database.

alias="progress_regexp",
description="regexp pattern for detecting computational service's progress",
)
strip_path: str | None = Field(
Copy link
Member

Choose a reason for hiding this comment

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

what is this?

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 also tend not to agree with these changes. Your source of truth is the simcore.service.paths-mapping label, if it's not None it's a new style dynamic service.
I would rather have an API endpoint on the catalog service instead of adding something to the DB. I also agree with PC's statement regarding the reasons of having the data present in the db.

@mrnicegyu11
Copy link
Member Author

alright thanks for your comments, I will close this PR then

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

Labels

a:catalog catalog service a:database associated to postgres service and postgres-database package a:director issue related with the director service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants