Esempio n. 1
0
        public void UnloadModels(IList <string> models, IPAddress ipAddress, int port)
        {
            if (models is null)
            {
                throw new ArgumentNullException(nameof(models));
            }
            if (ipAddress is null)
            {
                throw new ArgumentNullException(nameof(ipAddress));
            }
            if (models.Count < 1)
            {
                return;
            }

            var target  = $"{ipAddress}:{port}";
            var channel = new Channel(target, ChannelCredentials.Insecure);

            try
            {
                var grpcClient = new GRPCService.GRPCServiceClient(channel);

                foreach (var modelName in models)
                {
                    var request = new ModelControlRequest()
                    {
                        ModelName = modelName,
                        Type      = ModelControlRequest.Types.Type.Unload
                    };

                    var response = grpcClient.ModelControl(request);

                    if (response.RequestStatus.Code != RequestStatusCode.Success && response.RequestStatus.Code != RequestStatusCode.AlreadyExists)
                    {
                        throw new ModelUnloadException(response.RequestStatus.Msg, modelName, ipAddress, response.RequestStatus.Code);
                    }
                }
            }
            finally
            {
                var task = Task.Run(async() =>
                {
                    await channel.ShutdownAsync();
                });

                task.Wait();
            }
        }
Esempio n. 2
0
        public ITritonStatus GetStatus(IPAddress ipAddress, int port)
        {
            if (ipAddress is null)
            {
                throw new ArgumentNullException(nameof(ipAddress));
            }

            var target  = $"{ipAddress}:{port}";
            var channel = new Channel(target, ChannelCredentials.Insecure);

            try
            {
                var grpcClient = new GRPCService.GRPCServiceClient(channel);

                var response = grpcClient.Status(new StatusRequest());

                if (response is null)
                {
                    throw new InvalidOperationException("Grpc client failed to respond; the response was null.");
                }

                if (response.RequestStatus.Code != RequestStatusCode.Success)
                {
                    throw new InferenceServerGetStatusException(response.RequestStatus.Msg, ipAddress, response.RequestStatus.Code);
                }

                return(new TritonGrpcStatus(response.ServerStatus));
            }
            finally
            {
                var task = Task.Run(async() =>
                {
                    await channel.ShutdownAsync();
                });

                task.Wait();
            }
        }