-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adds in the ability for the client to get a remote_id from the server #15849
Conversation
CodSpeed Performance ReportMerging #15849 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good! Just a few minor comments from me
src/prefect/workers/base.py
Outdated
if ( | ||
get_current_settings().experiments.worker_logging_to_api_enabled | ||
and ( | ||
"api.prefect.cloud" in get_current_settings().api.url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check with the current client if it's connected to Cloud like this:
self._client.server_type == ServerType.CLOUD
src/prefect/client/orchestration.py
Outdated
|
||
if get_worker_id: | ||
return_dict = {"return_id": get_worker_id} | ||
else: | ||
return_dict = {} | ||
|
||
resp = await self._client.post( | ||
f"/work_pools/{work_pool_name}/workers/heartbeat", | ||
json={ | ||
"name": worker_name, | ||
"heartbeat_interval_seconds": heartbeat_interval_seconds, | ||
}, | ||
} | ||
| return_dict, | ||
) | ||
|
||
if get_worker_id and resp.status_code == 200: | ||
return UUID(resp.text) | ||
else: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to include a check for whether the client is connected to Cloud in this method. If someone is using this method directly with an self-hosted server, it'd cause problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default /heartbeat
should only send 204s not 200s but I agree it's probably better to be safe then sorry!
# Conflicts: # src/prefect/settings/models/root.py
…or backward compatibility
4e8cb41
to
52d747f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small comment on the client method docstring, but the rest LGTM!
Co-authored-by: Alexander Streed <desertaxle@users.noreply.github.com>
Add in the optional ability for a worker to get it's ID from the server using the heartbeat mechanism. This should only be enabled if
PREFECT_EXPERIMENTAL_WORKER_LOGGING_API_ENABLED
is set. This PR doesn't do any logging atm, just set the ground work for future PRs.Checklist
<link to issue>
"mint.json
.