Skip to content

Commit

Permalink
Add GK check to see if we should allow preempting
Browse files Browse the repository at this point in the history
Summary:
The previous diff added logic around figuring out if we should retry a type check if it was preempted.

With that logic present, this diff adds logic to check a gatekeeper and see if we should allow the preemptible flag to be passed to the subprocess call.

Along with that, we need to make sure any time we type check in the default isolation directory, we **always** use the preemptible flag. We should never block user buck operations because of an IDE type check. This should be handled by the GK,  but there's also going to be an extra check here to make sure we don't accidentally mess this up and cause issues.

Reviewed By: grievejia

Differential Revision: D64979502

fbshipit-source-id: 600e6b510740f6d65a48fcd004f5628a0c2b246e
  • Loading branch information
connernilsen authored and facebook-github-bot committed Oct 29, 2024
1 parent 40aa399 commit 6e63d8e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions client/commands/pyre_language_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,14 +730,20 @@ async def _query_buck_for_type_errors(
file=argfile,
)
argfile.flush()
if (
self.get_language_server_features().type_errors_preemptible.is_enabled()
or self.get_language_server_features().per_target_isolation_dir.is_disabled()
):
preemptible = [
"--preemptible=ondifferentstate",
]
else:
preemptible = []
if self.get_language_server_features().per_target_isolation_dir.is_enabled():
isolation_dir = [f"--isolation-dir={PTT_ISOLATION_PREFIX}"]
preemptible = []
else:
isolation_dir = []
preemptible = [
"--preemptible=ondifferentstate",
]

type_check_parameters = [
"buck2",
*isolation_dir,
Expand Down Expand Up @@ -1016,6 +1022,10 @@ async def handle_overlay_type_errors(
"new_file_loaded": new_file_loaded,
"isolation_dir": isolation_dir,
"sharding_enabled": self.get_language_server_features().type_error_sharding.is_enabled(),
"preemptible": (
self.get_language_server_features().type_errors_preemptible.is_enabled()
or self.get_language_server_features().per_target_isolation_dir.is_disabled()
),
},
**daemon_status_before.as_telemetry_dict(),
},
Expand Down
4 changes: 4 additions & 0 deletions client/language_server/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def is_disabled(self) -> bool:
PerTargetTypeErrorsAvailability = CustomAvailability
PerTargetIsolationDirAvailability = CustomAvailability
TypeErrorShardingAvailability = CustomAvailability
TypeErrorsPreemptibleAvailability = CustomAvailability
PythonAutoTargetsAvailability = CustomAvailability
SystemPyAutoTargetsAvailability = CustomAvailability
# TODO: T204372341 remove this once we have rolled out addition and removal features
Expand Down Expand Up @@ -127,6 +128,9 @@ class LanguageServerFeatures:
type_error_sharding: TypeErrorShardingAvailability = (
TypeErrorShardingAvailability.from_enabled(False)
)
type_errors_preemptible: TypeErrorsPreemptibleAvailability = (
TypeErrorsPreemptibleAvailability.from_enabled(False)
)
unsaved_changes: UnsavedChangesAvailability = UnsavedChangesAvailability.DISABLED
telemetry: TelemetryAvailability = TelemetryAvailability.DISABLED
completion: CompletionAvailability = CompletionAvailability.DISABLED
Expand Down

0 comments on commit 6e63d8e

Please sign in to comment.