Skip to content

Commit 20ef498

Browse files
committed
chore!: update downstream dependencies
* update FileSystemKeyValueAccess constructors * update createS3 change * add read/writeShard
1 parent 8afc84f commit 20ef498

11 files changed

Lines changed: 47 additions & 60 deletions

File tree

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@
111111
<!-- NB: Deploy releases to the SciJava Maven repository. -->
112112
<releaseProfiles>sign,deploy-to-scijava</releaseProfiles>
113113

114-
<n5.version>4.0.0-alpha-8</n5.version>
115-
<n5-aws-s3.version>4.4.0-alpha-5</n5-aws-s3.version>
116-
<n5-google-cloud.version>5.2.0-alpha-4</n5-google-cloud.version>
117-
<n5-zarr.version>2.0.0-alpha-5</n5-zarr.version>
118-
<n5-hdf5.version>2.3.0-alpha-5</n5-hdf5.version>
114+
<n5.version>4.0.0-alpha-9</n5.version>
115+
<n5-aws-s3.version>4.4.0-alpha-6</n5-aws-s3.version>
116+
<n5-google-cloud.version>5.2.0-alpha-5</n5-google-cloud.version>
117+
<n5-zarr.version>2.0.0-alpha-7</n5-zarr.version>
118+
<n5-hdf5.version>2.3.0-alpha-6</n5-hdf5.version>
119119
<n5-blosc.version>2.0.0-alpha-4</n5-blosc.version>
120120
<n5-imglib2.version>7.1.0-alpha-7</n5-imglib2.version>
121121
<n5-zstandard.version>2.0.0-alpha-4</n5-zstandard.version>

src/main/java/org/janelia/saalfeldlab/n5/universe/KeyValueAccessBackend.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ private static AmazonS3KeyValueAccess newAmazonS3KeyValueAccess(final URI uri, f
120120
final String uriString = uri.toString();
121121
final S3Client s3 = factory.createS3(uriString);
122122

123+
// throw exception if s3 endpoint is not reachable
124+
AmazonS3Utils.ensureS3EndpointIsReachable(s3);
125+
123126
return new AmazonS3KeyValueAccess(s3, uri, true);
124127
}
125128

126129
private static FileSystemKeyValueAccess newFileSystemKeyValueAccess(final URI uri, final N5Factory factory) {
127130

128-
return new FileSystemKeyValueAccess(FileSystems.getDefault());
131+
return new FileSystemKeyValueAccess();
129132
}
130133

131134
private static HttpKeyValueAccess newHttpKeyValueAccess(final URI uri, final N5Factory factory) {

src/main/java/org/janelia/saalfeldlab/n5/universe/N5Factory.java

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@
4848
import org.janelia.saalfeldlab.n5.zarr.ZarrKeyValueWriter;
4949
import org.janelia.saalfeldlab.n5.zarr.v3.ZarrV3KeyValueReader;
5050
import org.janelia.saalfeldlab.n5.zarr.v3.ZarrV3KeyValueWriter;
51-
import software.amazon.awssdk.auth.credentials.AwsCredentials;
52-
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
53-
import software.amazon.awssdk.http.SdkHttpClient;
5451
import software.amazon.awssdk.services.s3.S3Client;
52+
import software.amazon.awssdk.services.s3.S3ClientBuilder;
5553

5654
import javax.annotation.Nullable;
5755
import java.io.Serializable;
@@ -60,6 +58,7 @@
6058
import java.nio.file.Paths;
6159
import java.util.Arrays;
6260
import java.util.function.BiFunction;
61+
import java.util.function.Consumer;
6362
import java.util.regex.Pattern;
6463

6564
import static org.janelia.saalfeldlab.n5.universe.StorageFormat.getStorageFromNestedScheme;
@@ -91,11 +90,7 @@ public class N5Factory implements Serializable {
9190
private boolean zarrMergeAttributes = true;
9291
private String googleCloudProjectId = null;
9392
private boolean googleCloudCreateBucket = false;
94-
private String s3Region = null;
95-
private AwsCredentials s3Credentials = null;
96-
private SdkHttpClient.Builder<?> s3ClientBuilder = null;
97-
private boolean s3Anonymous = true;
98-
private String s3Endpoint;
93+
private Consumer<S3ClientBuilder> builderConfig;
9994
private StorageFormat preferredStorageFormat = null;
10095

10196
public N5Factory hdf5DefaultBlockSize(final int... blockSize) {
@@ -152,30 +147,6 @@ public N5Factory googleCloudProjectId(final String projectId) {
152147
return this;
153148
}
154149

155-
/**
156-
* This factory will use the {@link DefaultCredentialsProvider} to
157-
* find s3 credentials.
158-
*
159-
* @return this N5Factory
160-
*/
161-
public N5Factory s3UseCredentials() {
162-
163-
s3Anonymous = false;
164-
return this;
165-
}
166-
167-
public N5Factory s3UseCredentials(final AwsCredentials credentials) {
168-
169-
this.s3Credentials = credentials;
170-
return this;
171-
}
172-
173-
public N5Factory s3ClientConfiguration(final SdkHttpClient.Builder<?> clientBuilder) {
174-
175-
this.s3ClientBuilder = clientBuilder;
176-
return this;
177-
}
178-
179150
/**
180151
* When N5Factory cannot determine the StorageFormat from the URI, it will attempt to
181152
* try and create a reader/writer with all known StorageFormat values.
@@ -191,28 +162,22 @@ public N5Factory preferredStorageFormat(final StorageFormat format) {
191162
return this;
192163
}
193164

194-
@Deprecated
195-
public N5Factory s3RetryWithCredentials() {
196-
197-
return this;
198-
}
199-
200-
public N5Factory s3Endpoint(final String s3Endpoint) {
201-
202-
this.s3Endpoint = s3Endpoint;
203-
return this;
204-
}
205-
206-
public N5Factory s3Region(final String s3Region) {
165+
/**
166+
* This factory will use the builderConfig to configure the {@link S3ClientBuilder},
167+
* and thereby the {@link S3Client}.
168+
*
169+
* @return this N5Factory
170+
*/
171+
public N5Factory s3Configuration(final Consumer<S3ClientBuilder> builderConfig) {
207172

208-
this.s3Region = s3Region;
173+
this.builderConfig = builderConfig;
209174
return this;
210175
}
211176

212177
protected S3Client createS3(final String uri) {
213178

214179
try {
215-
return AmazonS3Utils.createS3(uri, s3Endpoint, AmazonS3Utils.getS3Credentials(s3Credentials, s3Anonymous), s3ClientBuilder, s3Region);
180+
return AmazonS3Utils.createS3(uri, builderConfig);
216181
} catch (final Throwable e) {
217182
throw new N5Exception("Could not create s3 client from uri: " + uri, e);
218183
}

src/main/java/org/janelia/saalfeldlab/n5/universe/container/ContainerMetadataNode.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ public boolean remove() {
354354
public <T> void writeBlock(String pathName, DatasetAttributes datasetAttributes, DataBlock<T> dataBlock) {
355355
throw new UnsupportedOperationException("ContainerMetadata does not support writeBlock");
356356
}
357+
358+
@Override
359+
public <T> void writeShard(String pathName, DatasetAttributes datasetAttributes, DataBlock<T> dataBlock) {
360+
throw new UnsupportedOperationException("ContainerMetadata does not support writeBlock");
361+
}
357362

358363
@Override
359364
public <T> void writeRegion(String datasetPath, DatasetAttributes datasetAttributes, long[] min, long[] size, DataBlockSupplier<T> dataBlocks,
@@ -381,6 +386,11 @@ public boolean deleteBlock(String datasetPath, DatasetAttributes datasetAttribut
381386
public DataBlock<?> readBlock(String pathName, DatasetAttributes datasetAttributes, long... gridPosition) {
382387
return null;
383388
}
389+
390+
@Override
391+
public DataBlock<?> readShard(String pathName, DatasetAttributes datasetAttributes, long... gridPosition) {
392+
return null;
393+
}
384394

385395
@SuppressWarnings("unchecked")
386396
public static <N extends GsonN5Reader & N5Reader > ContainerMetadataNode build(

src/main/java/org/janelia/saalfeldlab/n5/universe/translation/TranslatedN5Reader.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public DataBlock<?> readBlock(String pathName, DatasetAttributes datasetAttribut
6868
return n5.readBlock( originalPath( pathName ), datasetAttributes, gridPosition);
6969
}
7070

71+
@Override
72+
public DataBlock<?> readShard(String pathName, DatasetAttributes datasetAttributes, long... gridPosition) {
73+
74+
return n5.readShard(originalPath(pathName), datasetAttributes, gridPosition);
75+
}
76+
7177
@Override
7278
public boolean exists(String pathName) {
7379
return translation.getTranslated().exists(pathName);

src/main/java/org/janelia/saalfeldlab/n5/universe/translation/TranslatedN5Writer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ public <T> void writeBlock(String pathName, DatasetAttributes datasetAttributes,
122122
writer.writeBlock(originalPath(pathName), datasetAttributes, dataBlock);
123123
}
124124

125+
@Override
126+
public <T> void writeShard(String pathName, DatasetAttributes datasetAttributes, DataBlock<T> dataBlock) {
127+
writer.writeShard(originalPath(pathName), datasetAttributes, dataBlock);
128+
}
129+
125130
@Override
126131
public <T> void writeRegion(String datasetPath, DatasetAttributes datasetAttributes, long[] min, long[] size, DataBlockSupplier<T> dataBlocks,
127132
boolean writeFully) throws N5Exception {

src/test/java/org/janelia/saalfeldlab/n5/universe/N5FactoryTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.io.IOException;
1919
import java.net.URI;
2020
import java.net.URISyntaxException;
21-
import java.nio.file.FileSystems;
2221
import java.nio.file.Files;
2322
import java.nio.file.Path;
2423
import java.nio.file.Paths;
@@ -503,7 +502,7 @@ public void testCachedFactoryKeys() throws IOException {
503502
public void testZarr2VsZarr3Disambiguation() throws URISyntaxException {
504503

505504
final URI uri = new URI("src/test/resources/metadata.zarr");
506-
final FileSystemKeyValueAccess kva = new FileSystemKeyValueAccess(FileSystems.getDefault());
505+
final FileSystemKeyValueAccess kva = new FileSystemKeyValueAccess();
507506

508507
final StorageFormat format = StorageFormat.guessStorageFromKeys(uri, kva);
509508
assertEquals("zarr 2", StorageFormat.ZARR2, format);

src/test/java/org/janelia/saalfeldlab/n5/universe/benchmarks/BlockReadWriteBenchmarks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void setup() {
129129
File tmpDir;
130130
try {
131131
tmpDir = Files.createTempDirectory("n5-blockWriteBenchmark-").toFile();
132-
FileSystemKeyValueAccess kva = new FileSystemKeyValueAccess(FileSystems.getDefault());
132+
FileSystemKeyValueAccess kva = new FileSystemKeyValueAccess();
133133
n5 = new N5KeyValueWriter(kva, tmpDir.getAbsolutePath(), new GsonBuilder(), true);
134134

135135
int[] blockSize = new int[numDimensions];

src/test/java/org/janelia/saalfeldlab/n5/universe/benchmarks/KeyValueAccessBenchmarks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static void main(String... args) throws RunnerException {
9292
public void setup() throws IOException {
9393

9494
random = new Random();
95-
kva = new FileSystemKeyValueAccess(FileSystems.getDefault());
95+
kva = new FileSystemKeyValueAccess();
9696

9797
data = new byte[objectSizeBytes];
9898
random.nextBytes(data);

src/test/java/org/janelia/saalfeldlab/n5/universe/benchmarks/PartialReadBenchmarks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void teardown() {
7676
public void setup() {
7777

7878
random = new Random(1);
79-
kva = new FileSystemKeyValueAccess(FileSystems.getDefault());
79+
kva = new FileSystemKeyValueAccess();
8080

8181
File tmpFile;
8282
try {

0 commit comments

Comments
 (0)