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

[#3688] Phase 1 - Implement Objecttypes API client #3847

Closed
wants to merge 7 commits into from

Conversation

Viicos
Copy link
Contributor

@Viicos Viicos commented Feb 5, 2024

Part of #3688

@Viicos Viicos changed the title [#3688] Implement API endpoints and the Objects API regisration form [#3688] Phase 1 - Implement API endpoints and the Objects API regisration form Feb 5, 2024
Copy link

codecov bot commented Feb 5, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (745cbbe) 96.33% compared to head (8bf5568) 96.35%.
Report is 30 commits behind head on master.

Files Patch % Lines
...enforms/contrib/objects_api/clients/objecttypes.py 91.66% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3847      +/-   ##
==========================================
+ Coverage   96.33%   96.35%   +0.01%     
==========================================
  Files         707      711       +4     
  Lines       22172    22247      +75     
  Branches     2541     2554      +13     
==========================================
+ Hits        21359    21435      +76     
+ Misses        568      565       -3     
- Partials      245      247       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Viicos Viicos force-pushed the feature/3688-phase1-end branch 2 times, most recently from 5cdc1e9 to 856f8e5 Compare February 6, 2024 10:13
@Viicos Viicos force-pushed the feature/3688-phase1-end branch from 856f8e5 to 775a0cc Compare February 6, 2024 11:10
@SilviaAmAm SilviaAmAm self-requested a review February 6, 2024 11:12
@Viicos Viicos force-pushed the feature/3688-phase1-end branch 2 times, most recently from 99a05e6 to b7625c6 Compare February 8, 2024 13:08
Copy link
Member

@sergei-maertens sergei-maertens left a comment

Choose a reason for hiding this comment

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

I'd like to see this PR broken up in smaller PRs, there's too much going on all at once now 😬

The UI code could've been a separate PR limited to storybook, the additional endpoints could've been a separate PR.

Comment on lines 4 to 8
db:
image: postgres
environment:
- POSTGRES_USER=${DB_USER:-objecttypes}
- POSTGRES_PASSWORD=${DB_PASSWORD:-objecttypes}
Copy link
Member

Choose a reason for hiding this comment

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

let's pin this to the same version of postgres as our main docker-compose.yml and apply the same environment settings:

Suggested change
db:
image: postgres
environment:
- POSTGRES_USER=${DB_USER:-objecttypes}
- POSTGRES_PASSWORD=${DB_PASSWORD:-objecttypes}
db:
image: postgres:${PG_VERSION:-14}
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
# update with appropriate initialize SQL to create the DB for objecttypes and objects each
- ./docker-init-db.sql:/docker-entrypoint-initdb.d/init_db.sql
- objects-apis-db:/var/lib/postgresql/data
networks:
- open-forms-dev
volumes:
objects-apis-db

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Objecttypes API doesn't have a init-db.sql script so I'm keeping it as is for now

Copy link
Member

Choose a reason for hiding this comment

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

I'd take the same structure/set up like in our root docker-init-db.sql - the reason for this is that you'll be created a database for objects and objecttypes each, but in the same DB cluster. You really don't want both django apps to look for the same tables in the same DB, that will cause problems.

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 created the init script but still got some weird errors (FATAL: role "user" does not exist)

I'm also unsure what the open-forms-dev network does and how it relates to the one in our docker compose.

I'm leaving this for now it takes too much of my time and I don't have all the knowledge so I'll come back to this later

Copy link
Member

Choose a reason for hiding this comment

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

okay - some information:

FATAL: role "user" does not exist - in docker-compose, I basically tend to enable TRUST mode, it's not for prod anyway. So we let all the SQL be executed by the postgres superuser. That init script then ensures a DB user exists and creates the necessary database(s) owned by that user.

So in compose you typically want to have:

    environment:
      - POSTGRES_HOST_AUTH_METHOD=trust

The open-forms-dev network is so that we can spin up multiple compose files each from their own shell but all the services are on the same network. That way, we can make the root docker-compose.yml talk to the camunda from docker/docker-compose.camunda.yml etc. That essentially allows you to spin up all the services and have them be connected to use all of OF's features at once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah so it's an error but doesn't block anything. PR was updated


def get_objects(self) -> list[dict[str, Any]]:
with get_objecttypes_client() as client:
return client.list_objecttype_versions(self.kwargs["submission_uuid"])
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 interested to see how this handles 404s for bogus UUIDs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Objecttypes API raises a ValidationError but for some reason a 500 is returned. Should we validate on our side that it is a correct UUID?

Copy link
Member

Choose a reason for hiding this comment

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

no, a 500 is never an intended/deliberate outcome. Create an issue in the objecttypes API for this case, and I think a 404 is more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Viicos Viicos force-pushed the feature/3688-phase1-end branch 4 times, most recently from 5e7c8a5 to 15aaf51 Compare February 9, 2024 13:40
@Viicos Viicos changed the title [#3688] Phase 1 - Implement API endpoints and the Objects API regisration form [#3688] Phase 1 - Implement Objecttypes API client Feb 9, 2024
@Viicos Viicos force-pushed the feature/3688-phase1-end branch from 15aaf51 to c60a0ef Compare February 9, 2024 13:50
@sergei-maertens sergei-maertens marked this pull request as draft February 14, 2024 11:10
@Viicos Viicos closed this Feb 14, 2024
@sergei-maertens sergei-maertens deleted the feature/3688-phase1-end branch March 26, 2024 08:31
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