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 new dataservices fields #3262

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

Conversation

ThibaudDauce
Copy link
Contributor

@ThibaudDauce ThibaudDauce commented Feb 5, 2025

@ThibaudDauce ThibaudDauce requested a review from maudetes February 5, 2025 09:50
@@ -13,13 +13,13 @@ class DataserviceCsvAdapter(csv.Adapter):
("url", lambda d: d.self_web_url()),
"description",
"base_api_url",
"endpoint_description_url",
"machine_documentation_url",
Copy link
Contributor

Choose a reason for hiding this comment

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

It may break the HVD DAG @Pierlou

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as it doesn't change anymore I'm fine with it, I'll change it when this is deployed 🤝

def migrate(db):
log.info("Processing dataservices…")

Dataservice.objects(is_restricted=True, has_token=True).update(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we cover all cases since we can have is_restricted and has_token to None.
We should make sure that Dataservice.objects(access_type__exists=True).count() == Dataservice.objects().count() right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum… We can have None in these fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did a None request here 6e7c399

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget the changelog explaining the new fields and mentioning the migration

to_set = {}
if (
dataservice["endpoint_description_url"].endswith(".json")
or dataservice["endpoint_description_url"].endswith(".yaml")
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add .yml extension as well (see examples).

Suggested change
or dataservice["endpoint_description_url"].endswith(".yaml")
or dataservice["endpoint_description_url"].endswith(".yaml")
or dataservice["endpoint_description_url"].endswith(".yml")

Comment on lines +24 to +33
filter={
"$or": [
{
"is_restricted": None,
"has_token": None,
},
{"is_restricted": {"$exists": False}},
{"has_token": {"$exists": False}},
]
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you should set all dataservices with None value on is_restricted OR has_token at open.
For example, this dataservice with has_token: null, is_restricted: true is set to open after migration.

I think that None should be treated as False.
You may make this first update to make the rest of the logic easier?

count = get_db().dataservice.update_many(
filter={
"is_restricted": True,
"has_token": True,
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't care about has_token here? If we have is_restricted, we can set it to restricted without any worry about the token?

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