Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add platform-test workflow #74

Merged
merged 25 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9a4b825
chore: add platform-test workflow
bogovicj Apr 18, 2024
6540c5a
chore: add n5-aws-s3, n5-blosc dependencies
bogovicj Apr 18, 2024
ca8ae04
Merge remote-tracking branch 'origin/master' into windows-dsets
bogovicj Apr 24, 2024
0458574
test: fix macro test for windows
bogovicj Apr 24, 2024
fcab73e
chore: rm unnecessary deprecated method
bogovicj Apr 24, 2024
be0efb6
wip: macro test on windows
bogovicj Apr 24, 2024
0ee8d0e
test/wip: windows ome-zarr axes tests
bogovicj Apr 24, 2024
c8a781c
test/wip: more assertions for ome-zarr tests
bogovicj Apr 24, 2024
cde4023
wip(N5Importer): test different url parsing
bogovicj Apr 25, 2024
cc82606
wip: investigating windows test failures
bogovicj Apr 26, 2024
08b369a
wip: investigating windows issue
bogovicj Apr 26, 2024
eace7bc
wip: investigate windows macro test
bogovicj Apr 26, 2024
f5d3305
wip: windows macro tests with fwd slashes temporarily
bogovicj Apr 26, 2024
1e76ebc
wip: toward input uri validation
bogovicj Apr 28, 2024
0c26266
pref: rm file:// prefix from uri
bogovicj Apr 29, 2024
7f1326d
refactor: use COMMIT_OR_REVERT focus lost behavior
bogovicj Apr 29, 2024
de2ea40
test: macros use uri string
bogovicj Apr 29, 2024
c3d91d4
chore: clean up macro test
bogovicj Apr 29, 2024
0c2f09b
test: use URI for containerDir
bogovicj Apr 29, 2024
000b801
test: uri validation
bogovicj Apr 29, 2024
4aa4e52
refactor: make UriValidator protected
bogovicj Apr 29, 2024
41a90b6
fix: don't explicitly set warning dialog size
bogovicj Apr 29, 2024
ffc5929
test: more uri validation tests
bogovicj Apr 29, 2024
933f8d0
fix: valid relative uri's fall through to paths
bogovicj Apr 29, 2024
0e5abc2
test: uri on windows needs scheme to be absolute
bogovicj Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/platform-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: test

on:
push:
branches:
- master
tags:
- "*-[0-9]+.*"
pull_request:
branches:
- master
workflow_dispatch:

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install blosc (Windows)
if: matrix.os == 'windows-latest'
run: |
pip install blosc --no-input --target src/test/resources
mv src/test/resources/bin/* src/test/resources
- name: Install blosc (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
pip install blosc --no-input --target src/test/resources
mv src/test/resources/lib64/* src/test/resources
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'zulu'
cache: 'maven'
- name: Maven Test
run: mvn -B clean test --file pom.xml
8 changes: 5 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-ij</artifactId>
<version>4.1.3-SNAPSHOT</version>
<version>4.1.2-SNAPSHOT</version>

<name>N5 ImageJ Bindings</name>
<description>ImageJ convenience layer for N5</description>
Expand Down Expand Up @@ -86,10 +86,12 @@
<releaseProfiles>sign,deploy-to-scijava</releaseProfiles>

<n5.version>3.2.0</n5.version>
<n5-aws-s3.version>4.1.2</n5-aws-s3.version>
<n5-blosc.version>1.1.1</n5-blosc.version>
<n5-google-cloud.version>4.1.0</n5-google-cloud.version>
<n5-hdf5.version>2.2.0</n5-hdf5.version>
<n5-imglib2.version>7.0.0</n5-imglib2.version>
<n5-google-cloud.version>4.1.0</n5-google-cloud.version>
<n5-universe.version>1.4.2</n5-universe.version>
<n5-universe.version>1.4.3-SNAPSHOT</n5-universe.version>
<n5-zarr.version>1.3.1</n5-zarr.version>
<n5-zstandard.version>1.0.2</n5-zstandard.version>
</properties>
Expand Down
52 changes: 49 additions & 3 deletions src/main/java/org/janelia/saalfeldlab/n5/ij/N5Importer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -62,6 +64,7 @@
import org.janelia.saalfeldlab.n5.universe.N5DatasetDiscoverer;
import org.janelia.saalfeldlab.n5.universe.N5Factory;
import org.janelia.saalfeldlab.n5.universe.N5TreeNode;
import org.janelia.saalfeldlab.n5.universe.N5Factory.StorageFormat;
import org.janelia.saalfeldlab.n5.universe.metadata.N5CosemMetadata;
import org.janelia.saalfeldlab.n5.universe.metadata.N5CosemMetadataParser;
import org.janelia.saalfeldlab.n5.universe.metadata.N5CosemMultiScaleMetadata;
Expand Down Expand Up @@ -108,6 +111,7 @@
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.numeric.real.DoubleType;
import net.imglib2.type.numeric.real.FloatType;
import net.imglib2.util.Pair;
import net.imglib2.util.Util;
import net.imglib2.view.Views;

Expand Down Expand Up @@ -855,11 +859,17 @@ public N5Reader apply(final String n5UriOrPath) {
if (n5UriOrPath == null || n5UriOrPath.isEmpty())
return null;


String rootPath = null ;
String rootPath = null;
if (n5UriOrPath.contains("?")) {

try {
rootPath = new N5URI(n5UriOrPath).getContainerPath();
// need to strip off storage format for n5uri to correctly remove query;
final Pair<StorageFormat, URI> fmtUri = N5Factory.StorageFormat.parseUri(n5UriOrPath);
final StorageFormat format = fmtUri.getA();

final N5URI n5uri = from(fmtUri.getB().toString());
// add the format prefix back if it was present
rootPath = format == null ? n5uri.getContainerPath() : format.toString().toLowerCase() + ":" + n5uri.getContainerPath();
} catch (URISyntaxException e) {}
}

Expand All @@ -877,6 +887,42 @@ public N5Reader apply(final String n5UriOrPath) {
}
}

/**
* Generate an {@link N5URI} from a String.
*
* @param uriOrPath
* a string representation of a uri or a path string.
* @return the {@link N5URI}
*/
private static N5URI from(final String uriOrPath) {

try {
return new N5URI(new URI(uriOrPath));
} catch (Throwable ignore) {}

try {
final String[] split = uriOrPath.split("\\?");
final URI tmp = Paths.get(split[0]).toUri();
if (split.length == 1)
return new N5URI(tmp);
else {
StringBuffer buildUri = new StringBuffer();
buildUri.append(tmp.toString());
buildUri.append("?");
for (int i = 1; i < split.length; i++)
buildUri.append(split[i]);

return new N5URI(new URI(buildUri.toString()));
}
} catch (Throwable ignore) {}

try {
return new N5URI(N5URI.encodeAsUri(uriOrPath));
} catch (URISyntaxException e) {
throw new N5Exception(e);
}
}

private static String upToLastExtension(final String path) {

final int i = path.lastIndexOf('.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1487,9 +1487,6 @@ private static class DetailedOverwriteWarningDialog extends JDialog {
public DetailedOverwriteWarningDialog(final Frame parent, final String root, final String dataset) {
super(parent,"WARNING", true);
initComponents(root, dataset);
final Dimension dims = new Dimension(600, 250);
setSize(dims);
setPreferredSize(dims);
setResizable(false);
setLocationRelativeTo(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFormattedTextField.AbstractFormatter;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
Expand All @@ -72,7 +72,11 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.io.File;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.Collator;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
Expand Down Expand Up @@ -105,7 +109,7 @@ public class DatasetSelectorDialog {

private JFrame dialog;

private JTextField containerPathText;
private ImprovedFormattedTextField containerPathText;

private JCheckBox virtualBox;

Expand Down Expand Up @@ -366,8 +370,7 @@ private JFrame buildDialog() {
tabs.addTab("Metadata Translation", translationPanel.buildPanel());
tabs.addTab("Translation Result", translationResultPanel.buildPanel());

containerPathText = new JTextField();
containerPathText.setText(initialContainerPath);
containerPathText = new ImprovedFormattedTextField(new UriValidator(), initialContainerPath);
containerPathText.setPreferredSize(new Dimension(frameSizeX / 3, containerPathText.getPreferredSize().height));
containerPathText.addActionListener(e -> openContainer(n5Fun, () -> getN5RootPath(), pathFun));

Expand Down Expand Up @@ -934,4 +937,38 @@ private static boolean pathsEqual(final String a, final String b) {
return normalDatasetName(a, "/").equals(normalDatasetName(b, "/"));
}

protected static class UriValidator extends AbstractFormatter {

private static final long serialVersionUID = 6765664180035018335L;

@Override
public Object stringToValue(String input) throws ParseException {

if (input == null || input.isEmpty())
return null;

try {
final URI uri = new URI(input);
if (uri.isAbsolute())
return uri;
} catch (Throwable ignore) {}

try {
return Paths.get(input).toUri();
} catch (Throwable ignore) {}

throw new ParseException("input " + input + " not a valid URI", 0);
}

@Override
public String valueToString(Object arg) throws ParseException {

if( arg instanceof URI )
return ((URI)arg).toString().replaceFirst("^file://", "");
else
throw new ParseException("input " + arg + " not a valid URI", 0);
}

}

}
Loading
Loading