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

Migrate public endpoint Get Task to FastAPI #43718

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

omkar-foss
Copy link
Collaborator

closes: #42874
related: #42370

This migrates the Get Task API from api_connexion to api_fastapi.

@boring-cyborg boring-cyborg bot added area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. labels Nov 5, 2024
@omkar-foss omkar-foss added the legacy api Whether legacy API changes should be allowed in PR label Nov 5, 2024
@omkar-foss omkar-foss self-assigned this Nov 5, 2024
@omkar-foss
Copy link
Collaborator Author

omkar-foss commented Nov 8, 2024

@pierrejeambrun PR rebased and synced with main and all comments resolved, please check it out. Thank you!

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

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

Overall looking good. Need rebasing and conflicts resolution. Thanks

Comment on lines 65 to 86
def get_class_ref(obj: Operator) -> dict[str, str | None]:
"""Return the class_ref dict for obj."""
is_mapped_or_serialized = isinstance(obj, (MappedOperator, SerializedBaseOperator))

module_path = None
if is_mapped_or_serialized:
module_path = obj._task_module
else:
module_type = inspect.getmodule(obj)
module_path = module_type.__name__ if module_type else None

class_name = None
if is_mapped_or_serialized:
class_name = obj._task_type
elif obj.__class__ is type:
class_name = obj.__name__
else:
class_name = type(obj).__name__

return {
"module_path": module_path,
"class_name": class_name,
}
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we use field validator as in the legacy code to populate class_ref and operator_name ? This code should not be in types

Copy link
Collaborator Author

@omkar-foss omkar-foss Nov 8, 2024

Choose a reason for hiding this comment

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

Because we don't get the __class__ and other special properties of task in TaskResponse, so we need to perform isinstance() and other checks before building the TaskResponse model.

Copy link
Collaborator Author

@omkar-foss omkar-foss Nov 8, 2024

Choose a reason for hiding this comment

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

@pierrejeambrun where shall I move this code to? Can we keep a helpers.py file to have such helper functions or similar?

Since we cannot access the type related properties in the validators, we'll need to call this function before creating TaskResponse model.

tests/api_fastapi/core_api/routes/public/test_tasks.py Outdated Show resolved Hide resolved
@omkar-foss
Copy link
Collaborator Author

Overall looking good. Need rebasing and conflicts resolution. Thanks

Done! Rebased and conflicts resolved ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers. legacy api Whether legacy API changes should be allowed in PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AIP-84 Migrate the public endpoint Get Task to FastAPI
3 participants