Skip to content

Add dev profile for quick building #2

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

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ jobs:
echo "Fixing HOME to /root (was '$HOME')"
export HOME=/root
mkdir -p $HOME/.m2
[[ "${{ github.event_name }}" == "push" ]] && MAVEN_PHASE=deploy || MAVEN_PHASE=install
[[ "${{ github.event_name }}" == "push" ]] && MAVEN_PHASE=deploy MAVEN_PROFILES=ossrh || MAVEN_PHASE=install MAVEN_PROFILES=ossrh,dev
echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > $HOME/.m2/settings.xml
echo Executing Maven $MAVEN_PHASE
mvn clean $MAVEN_PHASE -Possrh -B -U -e -Djavacpp.platform=linux-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }}
mvn clean $MAVEN_PHASE -P$MAVEN_PROFILES -B -U -e -Djavacpp.platform=linux-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }}
df -h
macosx-x86_64:
runs-on: macos-latest
Expand All @@ -67,11 +67,11 @@ jobs:
mvn -version
bazel version
mkdir -p $HOME/.m2
[[ "${{ github.event_name }}" == "push" ]] && MAVEN_PHASE=deploy || MAVEN_PHASE=install
[[ "${{ github.event_name }}" == "push" ]] && MAVEN_PHASE=deploy MAVEN_PROFILES=ossrh || MAVEN_PHASE=install MAVEN_PROFILES=ossrh,dev
echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > $HOME/.m2/settings.xml
df -h
echo Executing Maven $MAVEN_PHASE
mvn clean $MAVEN_PHASE -Possrh -B -U -e -Djavacpp.platform=macosx-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }}
mvn clean $MAVEN_PHASE -P$MAVEN_PROFILES -B -U -e -Djavacpp.platform=macosx-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }}
df -h
windows-x86_64:
runs-on: windows-latest
Expand Down Expand Up @@ -120,12 +120,12 @@ jobs:
call mvn -version
bazel version
mkdir %USERPROFILE%\.m2
if "${{ github.event_name }}"=="push" (set MAVEN_PHASE=deploy) else (set MAVEN_PHASE=install)
if "${{ github.event_name }}"=="push" (set MAVEN_PHASE=deploy & MAVEN_PROFILES=ossrh) else (set MAVEN_PHASE=install & MAVEN_PROFILES=ossrh,dev)
echo ^<settings^>^<servers^>^<server^>^<id^>ossrh^</id^>^<username^>${{ secrets.CI_DEPLOY_USERNAME }}^</username^>^<password^>${{ secrets.CI_DEPLOY_PASSWORD }}^</password^>^</server^>^</servers^>^</settings^> > %USERPROFILE%\.m2\settings.xml
df -h
wmic pagefile list /format:list
echo Executing Maven %MAVEN_PHASE%
call mvn clean %MAVEN_PHASE% -Possrh -B -U -e -Djavacpp.platform=windows-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }}
call mvn clean %MAVEN_PHASE% -P$MAVEN_PROFILES -B -U -e -Djavacpp.platform=windows-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }}
if ERRORLEVEL 1 exit /b
df -h
wmic pagefile list /format:list
Expand All @@ -139,7 +139,7 @@ jobs:
- name: Redeploy snapshot artifacts
run: |
cd tensorflow-core
mvn dependency:resolve -Possrh -Predeploy -N -B -U -e -Djavacpp.platform.custom -Djavacpp.platform.linux-x86_64 -Djavacpp.platform.macosx-x86_64
mvn dependency:resolve -Possrh,redeploy -N -B -U -e -Djavacpp.platform.custom -Djavacpp.platform.linux-x86_64 -Djavacpp.platform.macosx-x86_64
cp $HOME/.m2/repository/org/tensorflow/tensorflow-core-api/*-SNAPSHOT/tensorflow-core-api-*-SNAPSHOT*.jar .
for f in *.jar; do
if [[ $f =~ tensorflow-core-api-.*SNAPSHOT-(.*).jar ]]; then
Expand All @@ -149,4 +149,4 @@ jobs:
fi
done
echo "<settings><servers><server><id>ossrh</id><username>${{ secrets.CI_DEPLOY_USERNAME }}</username><password>${{ secrets.CI_DEPLOY_PASSWORD }}</password></server></servers></settings>" > $HOME/.m2/settings.xml
mvn clean deploy -Possrh -Predeploy -N -B -U -e -Dfiles=$FILES -Dtypes=$TYPES -Dclassifiers=$CLASSIFIERS
mvn clean deploy -Possrh,redeploy -N -B -U -e -Dfiles=$FILES -Dtypes=$TYPES -Dclassifiers=$CLASSIFIERS
27 changes: 24 additions & 3 deletions tensorflow-core/tensorflow-core-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@
<protobuf.version>3.8.0</protobuf.version>
</properties>

<profiles>
<!-- Profile suitable for developers who are not altering the TensorFlow runtime library build nor the Java C API bindings.
Among other things, it is optimized to build faster by fetching the pre-built native artifact matching the current version
and platform instead of building it locally. This profile is NOT suitable for production purposes. -->
<profile>
<id>dev</id>
<dependencies>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow-core-api</artifactId>
<version>${project.version}</version>
<classifier>${native.classifier}</classifier>
</dependency>
</dependencies>
<properties>
<javacpp.build.skip>true</javacpp.build.skip>
<javacpp.parser.skip>true</javacpp.parser.skip>
<javacpp.compiler.skip>true</javacpp.compiler.skip>
<!-- Javadoc generation is a bit slow and CPU-consuming while not being very useful in development mode, so skip it -->
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
Expand Down Expand Up @@ -318,9 +342,6 @@
-Djava.library.path=${project.build.directory}/native/org/tensorflow/internal/c_api/${native.classifier}
</argLine>
<additionalClasspathElements>${project.build.directory}/native/</additionalClasspathElements>
<systemPropertyVariables>
<NATIVE_PLATFORM>${javacpp.platform}</NATIVE_PLATFORM>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

import java.nio.file.Path;
import java.nio.file.Paths;

import org.junit.Ignore;
Expand All @@ -44,9 +45,11 @@ public void registeredOpList() {

@Test
public void loadLibrary() {
// FIXME(karllessard) Custom ops libraries are not supported on Windows since TF is built monolithic
// Once we are able to lift this restriction, enable this test
disableOnPlatform("windows");
Path customOpsLibraryPath = Paths.get("").resolve("bazel-bin/libcustom_ops_test.so");

// Skip this test if the custom ops library was not build (can be the case when building in
// dev mode or on platforms that do not support custom ops, like Windows)
assumeTrue(customOpsLibraryPath.toFile().exists());

try (Graph g = new Graph()) {
// Build a graph with an unrecognized operation.
Expand All @@ -58,7 +61,7 @@ public void loadLibrary() {
}

// Load the library containing the operation.
OpList opList = TensorFlow.loadLibrary(Paths.get("").resolve("bazel-bin/libcustom_ops_test.so").toString());
OpList opList = TensorFlow.loadLibrary(customOpsLibraryPath.toString());
assertNotNull(opList);
assertEquals(1, opList.getOpCount());
assertEquals(opList.getOpList().get(0).getName(), "MyTest");
Expand All @@ -67,9 +70,4 @@ public void loadLibrary() {
g.opBuilder("MyTest", "MyTest").build();
}
}

private void disableOnPlatform(String platform) {
String current = System.getProperty("NATIVE_PLATFORM");
assumeFalse(current != null && current.startsWith(platform.toLowerCase()));
}
}