Skip to content

[DRCC][AQUA] Completely Removing OSS bucket config dependency #1147

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

Merged
merged 11 commits into from
Apr 9, 2025

Conversation

kumar-shivam-ranjan
Copy link
Member

Description

This PR is intended to completely remove the dependency of AQUA on config stored in Object storage bucket. Also , this change would ensure Aqua will be available for all realms even when no ODSC_MODEL_COMPARTMENT_OCID env variable is set.

Unit Tests

Screenshot 2025-04-05 at 12 28 04 AM

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Apr 4, 2025
@@ -41,5 +40,5 @@ def set_log_level(log_level: str):
set_auth("resource_principal")

ODSC_MODEL_COMPARTMENT_OCID = (
os.environ.get("ODSC_MODEL_COMPARTMENT_OCID") or fetch_service_compartment()
os.environ.get("ODSC_MODEL_COMPARTMENT_OCID") or "ODSC_MODEL_COMPARTMENT_OCID"
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that I understand this logic. In one case we return the value of the ODSC_MODEL_COMPARTMENT_OCID env var, but if it is not defined we just return the name of the env var?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently , service model compartment ocid is used as a key to cache service model list response. Now since we won't be fetching this compartment id in ADS from container_index.json , just replaced it with constant string.
If we explicitly set this compartment ocid via NB environment variables , then corresponding ocid will be used as key.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we just remove ODSC_MODEL_COMPARTMENT_OCID?
I need to check if we can still use non prod backend for fetching service models list incase we do that since this is only place i feel this env variable is being used.

Copy link
Member

Choose a reason for hiding this comment

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

Here i'm not sure. My vote would be for removing this variable, but @VipulMascarenhas might have a different opinion. We might use this env variable to identify if the model is service or a custom one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tested the flow after removing ODSC_MODEL_COMPARTMENT_OCID. Seems like we don't need this env variable for fetching service models even for non prod backend. The new List models API would take care of it.
We can rename the key for storing service models list response in cache.

So , everything seems fine except there is only once place this is being used where i am not sure it is safe to remove.
CC: @VipulMascarenhas

    if service_model.compartment_id != ODSC_MODEL_COMPARTMENT_OCID:
        logger.info(
            f"Aqua Model {model_id} already exists in the user's compartment."
            "Skipped copying."
        )
        return service_model

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it safe to remove this condition?

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced it with

  # Skip model copying if it is registered model
  if service_model.freeform_tags.get(Tags.BASE_MODEL_CUSTOM) is not None:
      logger.info(
          f"Aqua Model {model_id} already exists in the user's compartment."
          "Skipped copying."
      )
      return service_model

@@ -41,14 +40,14 @@ def ui_compatability_check():
"""This method caches the service compartment OCID details that is set by either the environment variable or if
fetched from the configuration. The cached result is returned when multiple calls are made in quick succession
from the UI to avoid multiple config file loads."""
return ODSC_MODEL_COMPARTMENT_OCID or fetch_service_compartment()
return ODSC_MODEL_COMPARTMENT_OCID
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this compatibility check method now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes , can be removed.
Will remove

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Thanks

@@ -39,19 +36,8 @@ def process(self) -> Union[AdsVersionResponse, CompatibilityCheckResponse]:
)
return response
if request.get("kind") == "CompatibilityCheck":
if ui_compatability_check():
Copy link
Member

Choose a reason for hiding this comment

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

if this always returns ok, does UI need to call this? This won't be needed, right?

Copy link
Member Author

@kumar-shivam-ranjan kumar-shivam-ranjan Apr 7, 2025

Choose a reason for hiding this comment

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

This is compatibility check handler implemented in websockets. We call the one implemented via HTTP. Both the methods should return ok always as we decide to enable AQUA everywhere.

Copy link
Member Author

@kumar-shivam-ranjan kumar-shivam-ranjan Apr 7, 2025

Choose a reason for hiding this comment

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

Yes , we can remove calling this API in UI. I kept it since may be in future we can add some sort of AQUA enabling logic based on CP config. Are you suggesting we removing this api alltogether from ADS?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Thanks

if service_model.compartment_id != ODSC_MODEL_COMPARTMENT_OCID:

# Skip model copying if it is registered model
if service_model.freeform_tags.get(Tags.BASE_MODEL_CUSTOM) is not None:
Copy link
Member

Choose a reason for hiding this comment

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

can freeform_tags be None? I don't think it's going happen for aqua models, but can we add a check here to return appropriate error instead if for some reason these tags are empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will update.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Thanks

logger.info(
f"Returning service models list in {ODSC_MODEL_COMPARTMENT_OCID} from cache."
f"Returning service models list in {AQUA_SERVICE_MODELS} from cache."
Copy link
Member

Choose a reason for hiding this comment

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

nit: might be good to just log this as Returning service models list from cache.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Thanks

logger.info("Fetching service models.")
lifecycle_state = kwargs.pop(
"lifecycle_state", Model.LIFECYCLE_STATE_ACTIVE
)

models = self.list_resource(
self.ds_client.list_models,
compartment_id=ODSC_MODEL_COMPARTMENT_OCID,
compartment_id=compartment_id or COMPARTMENT_OCID,
Copy link
Member

Choose a reason for hiding this comment

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

wondering if we need to filter the model list here based on service model tags. If we list from users compartment, this would only return service models and not other registered models from users compartment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if i fully understand your question
but this would return either service models or user models based on category. If category is user (default) , it would return all registered models from user's compartment

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Thanks

**kwargs,
)

logger.info(
f"Fetched {len(models)} model in compartment_id={ODSC_MODEL_COMPARTMENT_OCID if category==SERVICE else compartment_id}."
f"Fetched {len(models)} models from {AQUA_SERVICE_MODELS if category==SERVICE else compartment_id}."
Copy link
Member

Choose a reason for hiding this comment

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

the message might not be clear with the new service model key, let's just log:
Fetched x service models.
or
Fetched x models from compartment <compartment_id>

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure , will update

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Thanks

@kumar-shivam-ranjan kumar-shivam-ranjan changed the base branch from aqua/ADS_MS_changes to main April 7, 2025 22:04
Copy link

github-actions bot commented Apr 7, 2025

📌 Cov diff with main:

Coverage-61%

📌 Overall coverage:

Coverage-58.60%

Copy link

github-actions bot commented Apr 8, 2025

📌 Cov diff with main:

Coverage-7%

📌 Overall coverage:

Coverage-19.18%

Copy link

github-actions bot commented Apr 8, 2025

📌 Cov diff with main:

Coverage-76%

📌 Overall coverage:

Coverage-58.63%

@kumar-shivam-ranjan kumar-shivam-ranjan merged commit 789786f into main Apr 9, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AQUA OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants