def require(self, resourceRequest): if isinstance(resourceRequest, TaskResourceRequests): if self._java_resource_profile_builder is not None: if resourceRequest._java_task_resource_requests is not None: self._java_resource_profile_builder.require( resourceRequest._java_task_resource_requests) else: taskReqs = TaskResourceRequests(self._jvm, resourceRequest.requests) self._java_resource_profile_builder.require( taskReqs._java_task_resource_requests) else: self._task_resource_requests.update(resourceRequest.requests) else: if self._java_resource_profile_builder is not None: if resourceRequest._java_executor_resource_requests is not None: self._java_resource_profile_builder.require( resourceRequest._java_executor_resource_requests) else: execReqs = ExecutorResourceRequests( self._jvm, resourceRequest.requests) self._java_resource_profile_builder.require( execReqs._java_executor_resource_requests) else: self._executor_resource_requests.update( resourceRequest.requests) return self
def require( self, resourceRequest: Union[ExecutorResourceRequest, TaskResourceRequests] ) -> "ResourceProfileBuilder": if isinstance(resourceRequest, TaskResourceRequests): if self._java_resource_profile_builder is not None: if resourceRequest._java_task_resource_requests is not None: self._java_resource_profile_builder.require( resourceRequest._java_task_resource_requests ) else: taskReqs = TaskResourceRequests(self._jvm, resourceRequest.requests) self._java_resource_profile_builder.require( taskReqs._java_task_resource_requests ) else: self._task_resource_requests.update( # type: ignore[union-attr] resourceRequest.requests ) else: if self._java_resource_profile_builder is not None: r = resourceRequest._java_executor_resource_requests # type: ignore[attr-defined] if r is not None: self._java_resource_profile_builder.require(r) else: execReqs = ExecutorResourceRequests( self._jvm, resourceRequest.requests # type: ignore[attr-defined] ) self._java_resource_profile_builder.require( execReqs._java_executor_resource_requests ) else: self._executor_resource_requests.update( # type: ignore[union-attr] resourceRequest.requests # type: ignore[attr-defined] ) return self
def require( self, resourceRequest: Union[ExecutorResourceRequests, TaskResourceRequests] ) -> "ResourceProfileBuilder": """ Add executor resource requests Parameters ---------- resourceRequest : :class:`ExecutorResourceRequests` or :class:`TaskResourceRequests` The detailed executor resource requests, see :class:`ExecutorResourceRequests` Returns ------- dict a dictionary of resources to :class:`ExecutorResourceRequest` """ if isinstance(resourceRequest, TaskResourceRequests): if self._java_resource_profile_builder is not None: if resourceRequest._java_task_resource_requests is not None: self._java_resource_profile_builder.require( resourceRequest._java_task_resource_requests) else: taskReqs = TaskResourceRequests(self._jvm, resourceRequest.requests) self._java_resource_profile_builder.require( taskReqs._java_task_resource_requests) else: self._task_resource_requests.update(resourceRequest.requests) else: if self._java_resource_profile_builder is not None: r = resourceRequest._java_executor_resource_requests if r is not None: self._java_resource_profile_builder.require(r) else: execReqs = ExecutorResourceRequests( self._jvm, resourceRequest.requests) self._java_resource_profile_builder.require( execReqs._java_executor_resource_requests) else: self._executor_resource_requests.update( resourceRequest.requests) return self