Skip to content

Commit

Permalink
Apply remaining review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Jul 25, 2024
1 parent 5427b04 commit 8155d90
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
9 changes: 2 additions & 7 deletions src/Nexus/Extensibility/DataSource/DataSourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,7 @@ private async Task ReadOriginalAsync(

try
{
var pipelinePosition = 0;

foreach (var dataSource in _dataSources)
for (int pipelinePosition = 0; pipelinePosition < _dataSources.Length; pipelinePosition++)
{
var currentReadRequests = readRequests
.Where(request =>
Expand All @@ -428,15 +426,13 @@ request.CatalogItem.Resource.Properties is null ||
)
.ToArray();

await dataSource.ReadAsync(
await _dataSources[pipelinePosition].ReadAsync(
begin,
end,
currentReadRequests,
readDataHandler,
progress,
cancellationToken);

pipelinePosition++;
}
}
catch (OutOfMemoryException)
Expand Down Expand Up @@ -680,7 +676,6 @@ private async Task ReadResampledAsync(
try
{
/* load and process data from source */
var elementSize = baseItem.Representation.ElementSize;
var sourceSamplePeriod = baseSamplePeriod;
var targetSamplePeriod = samplePeriod;

Expand Down
5 changes: 3 additions & 2 deletions src/Nexus/Extensions/Sources/Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace Nexus.Sources;
"https://github.com/nexus-main/nexus/blob/master/src/Nexus/Extensions/Sources/Sample.cs")]
internal class Sample : IDataSource
{
public static Guid PipelineId = new("c2c724ab-9002-4879-9cd9-2147844bee96");
public static readonly Guid PipelineId = new("c2c724ab-9002-4879-9cd9-2147844bee96");

private static readonly double[] DATA =
[
6.5,
Expand Down Expand Up @@ -146,7 +147,7 @@ public async Task ReadAsync(
{
var tasks = requests.Select(request =>
{
var (originalResourceName, catalogItem, data, status) = request;
var (_, catalogItem, data, status) = request;

return Task.Run(() =>
{
Expand Down
9 changes: 4 additions & 5 deletions src/Nexus/Services/DataControllerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public async Task<IDataSourceController> GetDataSourceControllerAsync(
DataSourcePipeline pipeline,
CancellationToken cancellationToken)
{
var logger = _loggerFactory.CreateLogger<DataSourceController>();

var dataSources = pipeline.Registrations
.Select(registration => _extensionHive.GetInstance<IDataSource>(registration.Type))
.ToArray();
Expand All @@ -60,12 +58,13 @@ public async Task<IDataSourceController> GetDataSourceControllerAsync(
var controller = new DataSourceController(
dataSources,
pipeline.Registrations,
systemConfiguration: clonedSystemConfiguration,
requestConfiguration: requestConfiguration,
clonedSystemConfiguration,
requestConfiguration,
_processingService,
_cacheService,
_dataOptions,
logger);
_loggerFactory.CreateLogger<DataSourceController>()
);

var catalogCache = _appState.CatalogState.Cache.GetOrAdd(
pipeline,
Expand Down
15 changes: 10 additions & 5 deletions tests/Nexus.Tests/Services/DataControllerServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,17 @@ public async Task CanCreateAndInitializeDataWriterController()
Options.Create(new DataOptions()),
loggerFactory);

var actual = await dataControllerService.GetDataWriterControllerAsync(
resourceLocator,
exportParameters,
CancellationToken.None);
async Task action()
{
var _ = await dataControllerService.GetDataWriterControllerAsync(
resourceLocator,
exportParameters,
CancellationToken.None);
};

var actual = await Record.ExceptionAsync(action);

// Assert
/* nothing to assert */
Assert.NotNull(actual);
}
}

0 comments on commit 8155d90

Please sign in to comment.