Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
target
dependency-reduced-pom.xml
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG SPARK_VERSION=3.3.2-scala2.12-java17-ubuntu24.04
ARG RS_FISH_SPARK_GIT_HASH=a06db09

FROM ghcr.io/janeliascicomp/spark:${SPARK_VERSION}
ARG RS_FISH_SPARK_GIT_HASH

LABEL \
org.opencontainers.image.title="RS-FISH Spark" \
org.opencontainers.image.description="Spark version of RS-FISH" \
org.opencontainers.image.authors="[email protected],[email protected],[email protected]" \
org.opencontainers.image.licenses="GPL-2.0" \
org.opencontainers.image.version=${RS_FISH_SPARK_GIT_HASH}

USER root

RUN apt update -y; \
apt-get install -y \
libblosc1 libblosc-dev \
libzstd1 libzstd-dev libhdf5-dev;

WORKDIR /app
COPY LICENSE.txt /app/LICENSE.txt
COPY target/RS-FISH-Spark-0.0.2-SNAPSHOT-with-dependencies.jar /app/app.jar
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ The code to run the distributed, [Spark](http://spark.apache.org)-based RS-FISH
### Local execution <a name="local">
</a>

For **local execution** (comparable to efficient multi-threading), compile the repository using `mvn clean package`, which will create a **farjar** in the target directory called `RS-Fish-jar-with-dependencies.jar`. You can then execute the [RS-FISH class](https://github.com/PreibischLab/RS-FISH-Spark/blob/main/src/main/java/net/preibisch/rsfish/spark/SparkRSFISH.java) (for large volumes) or the [RS-FISH-IJ class](https://github.com/PreibischLab/RS-FISH-Spark/blob/main/src/main/java/net/preibisch/rsfish/spark/SparkRSFISH_IJ.java) (for many smaller images), for example:
For **local execution** (comparable to efficient multi-threading), compile the repository using `mvn clean package`, which will create a **farjar** in the target directory called `RS-FISH-Spark-0.0.2-SNAPSHOT-with-dependencies.jar`. You can then execute the [RS-FISH class](https://github.com/PreibischLab/RS-FISH-Spark/blob/main/src/main/java/net/preibisch/rsfish/spark/SparkRSFISH.java) (for large volumes) or the [RS-FISH-IJ class](https://github.com/PreibischLab/RS-FISH-Spark/blob/main/src/main/java/net/preibisch/rsfish/spark/SparkRSFISH_IJ.java) (for many smaller images), for example:

`java -cp target/RS-Fish-jar-with-dependencies.jar -Xmx20G -Dspark.master=local[8] net.preibisch.rsfish.spark.SparkRSFISH --image=/home/test.n5 --dataset=/N2/s0 --minIntensity=0 --maxIntensity=4096 --anisotropy=0.7 --output=points.csv`
`java -cp target/RS-FISH-Spark-0.0.2-SNAPSHOT-with-dependencies.jar -Xmx20G -Dspark.master=local[8] net.preibisch.rsfish.spark.SparkRSFISH --image=/home/test.n5 --dataset=/N2/s0 --minIntensity=0 --maxIntensity=4096 --anisotropy=0.7 --output=points.csv`

*Alternatively, you can import the project into Eclipse and run it from there.*

Expand Down Expand Up @@ -121,7 +121,7 @@ Click on Create cluster from the EMR dashboard.
* Spark-submit options: --class
* for N5 input: net.preibisch.rsfish.spark.aws.AWSSparkRSFISH
* For multiple tifs: net.preibisch.rsfish.spark.aws.RunAWSSparkRSFISHIJ
* Application location*: s3://preibischlab-release-jars/RS-Fish-jar-with-dependencies.jar
* Application location*: s3://preibischlab-release-jars/RS-FISH-Spark-0.0.2-SNAPSHOT-with-dependencies.jar
* Arguments: minimum task arguments for default params:
-i =< N5 container path in s3, e.g. -i s3://bucket-name/smFish.n5 -o, --output= output CSV file in S3, e.g. -o s3://rs-fish/embryo_5_ch0.csv -p, --path= The path of the input Data inside bucket e.g. -p N2-702-ch0/c0/s0 -pk, --publicKey= User public key (*previously created) -pp, --privateKey= User private key

Expand Down
25 changes: 25 additions & 0 deletions build-local-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Run this using `./build-docker-image.sh docker|podman --load|--push`

BUILD_CONTAINER_TOOL=$1
shift
GIT_HASH=f5cad2d

echo "Build RS-FISH:${GIT_HASH} container using ${BUILD_CONTAINER_TOOL}"

if [[ "${BUILD_CONTAINER_TOOL}" == "podman" ]] ; then
podman build \
--platform linux/arm64,linux/amd64 \
--tag ghcr.io/janeliascicomp/rs-fish-spark:${GIT_HASH} \
--build-arg RS_FISH_SPARK_GIT_HASH=${GIT_HASH} \
. \
$*
else
docker buildx build \
--platform linux/arm64,linux/amd64 \
--tag ghcr.io/janeliascicomp/rs-fish-spark:${GIT_HASH} \
--build-arg RS_FISH_SPARK_GIT_HASH=${GIT_HASH} \
. \
$*
fi
142 changes: 107 additions & 35 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>RS-FISH-Spark</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>

<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>39.0.0</version>
<version>40.0.0</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -92,6 +92,7 @@
<!-- <scijava.jvm.version>1.8</scijava.jvm.version> -->
<license.licenseName>gpl_v2</license.licenseName>
<license.copyrightOwners>Developers.</license.copyrightOwners>

</properties>
<repositories>
<!-- NB: for project parent -->
Expand All @@ -118,12 +119,26 @@
<groupId>org.openmicroscopy</groupId>
<artifactId>ome-common</artifactId>
</exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-universe</artifactId>
<!-- <version>1.4.1</version> -->
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-universe</artifactId>
<version>2.1.0</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
Expand All @@ -136,7 +151,16 @@
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-aws-s3</artifactId>
<!-- <version>4.0.0</version> -->
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand All @@ -145,18 +169,18 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.5</version>
<version>2.13.4</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.4.7</version>
<!-- Spark 3.3.2 comes with scala 2.12.15 -->
<artifactId>spark-core_2.12</artifactId>
<version>3.3.2</version>
<exclusions>
<exclusion>
<artifactId>netty-all</artifactId>
<artifactId>netty</artifactId>
<groupId>io.netty</groupId>
</exclusion>

<exclusion>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
Expand All @@ -169,6 +193,10 @@
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-slf4j-impl</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<artifactId>aopalliance-repackaged</artifactId>
<groupId>org.glassfish.hk2.external</groupId>
Expand All @@ -181,6 +209,10 @@
<artifactId>jersey-client</artifactId>
<groupId>org.glassfish.jersey.core</groupId>
</exclusion>
<exclusion>
<artifactId>jersey-core</artifactId>
<groupId>com.sun.jersey</groupId>
</exclusion>
<exclusion>
<artifactId>lz4</artifactId>
<groupId>net.jpountz.lz4</groupId>
Expand All @@ -196,48 +228,88 @@
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.15</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.17.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>3.9.9.Final</version>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
<groupId>net.preibisch</groupId>
<build>
<finalName>RS-Fish</finalName>
<plugins>

<!-- other Maven plugins ... -->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>

<artifactId>maven-shade-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<shadedClassifierName>with-dependencies</shadedClassifierName>
<shadedArtifactAttached>true</shadedArtifactAttached>
<!-- Do not minimize for now to speed up packaging. -->
<transformers combine.children="append">
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/json/org.janelia.saalfeldlab.n5.Compression$CompressionType</resource>
</transformer>
</transformers>
<!--<minimizeJar>true</minimizeJar> -->
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>Angle0.tif</exclude>
<exclude>LICENSE</exclude>
<exclude>LICENSE.txt</exclude>
<exclude>META-INF/DEPENDENCIES</exclude>
<exclude>META-INF/LICENSE</exclude>
<exclude>META-INF/NOTICE</exclude>
<exclude>META-INF/BSDL</exclude>
<exclude>META-INF/COPYING</exclude>
<exclude>META-INF/LEGAL</exclude>
<exclude>META-INF/LICENSE.RUBY</exclude>
<exclude>META-INF/json/org.scijava.plugin.Plugin</exclude>
<exclude>META-INF/*.MF</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.txt</exclude>
<exclude>module-info.class</exclude>
<exclude>plugins.config</exclude>
<exclude>META-INF/versions/9/module-info.class</exclude>
<exclude>META-INF/okio.kotlin_module</exclude>
<exclude>META-INF/services/com.fasterxml.jackson.core.JsonFactory</exclude>
</excludes>
</filter>
</filters>
<!-- Additional configuration. -->
<artifactSet>
<excludes>
<exclude>xpp3:xpp3</exclude>
</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.apache.commons.compress</pattern>
<shadedPattern>org.janelia.saalfeldlab.org.apache.commons.compress</shadedPattern>
</relocation>
<!-- Protect newer gson version from the old one preloaded by spark -->
<relocation>
<pattern>com.google.gson</pattern>
<shadedPattern>org.janelia.saalfeldlab.com.google.gson</shadedPattern>
</relocation>
</relocations>
</configuration>

<!-- binds by default to package phase -->
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
<goal>shade</goal>
</goals>
</execution>
</executions>

</plugin>
</plugins>
</build>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/preibisch/rsfish/spark/Block.java
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cgoina, I do not think changes to this class are necessary. We simply need to use Views.hyperslice() in the SparkRSFISH class ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it like that initially but IMO these made the code in SparkRSFISH cleaner

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

What I do not like is that statements like if ( d < 3 ) and return min.length > 3 ? Arrays.copyOf(min, 3) : min; do some "magic" depending on the input and are very fragile. What happens when I select a block size in c & t > 1?

I would like to keep it the way it is because a Block is a unit that computation is done on, which is either 2D or 3D.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static ArrayList< Block > splitIntoBlocks( final Interval interval, final
min.add( pos );
max.add( pos + Math.min( bs - 1, interval.max( d ) - pos ) );

pos += bs - 2; // one overlap, starts at the max - 2 since the most outer pixels are not evaluated with DoG
pos += bs - 2; // one overlap, starts at the max - 2 since the most outer pixels are not evaluated with DoG
++numBlocks[ d ];
}

Expand Down Expand Up @@ -92,7 +92,7 @@ public static void main( String[] args )
{
ArrayList< Block > blocks = splitIntoBlocks( new FinalInterval( new long[] { 19, -5 }, new long[] { 1000, 100 } ), new int[] { 100, 100 } );

for ( final Block b : blocks )
System.out.println( Util.printInterval( b.createInterval() ) );
for ( final Block b : blocks )
System.out.println( Util.printInterval( b.createInterval() ) );
}
}
Loading