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

Gradle Kotlin script plus other stuff #3167

Merged
merged 39 commits into from May 27, 2024
Merged

Conversation

elect86
Copy link
Contributor

@elect86 elect86 commented May 8, 2024

Description

This PR convert Gradle Groovy scripts to Kotlin, which is also recommended by Gradle, being a statically typed language

this change is backward compatible

Interesting edge cases to note here:

There a couple of TODOs which I still have to figure it out, but the 95% work is done and there for you to start looking at it so that I can already get some early feedbacks from you, folks

Also, why are you disabling the Gradle Metadata generation?

# Conflicts:
#	engines/pytorch/pytorch-jni/build.gradle
#	engines/pytorch/pytorch-native/build.gradle
#	gradle.properties
#	gradle/wrapper/gradle-wrapper.properties
@elect86 elect86 requested review from zachgk, frankfliu and a team as code owners May 8, 2024 12:39
docs/README.md Outdated
@@ -63,16 +63,16 @@ Note: when searching in JavaDoc, if your access is denied, please try removing t
## Extensions and utilities

- [Android support](../android/README.md)
- [Audio support](../extensions/audio/README.md)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we need to rename extensions folder?

Copy link
Contributor Author

@elect86 elect86 May 13, 2024

Choose a reason for hiding this comment

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

because the typesafe project accessor clashes with a getter called extensions, so we either rename that directory or we disable the typesafe accessor

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's disable this feature for now. Since this project is experimental, we can create a ticket to gradle and see if they can adda flag to change "extension" folder name

Copy link
Contributor

@frankfliu frankfliu left a comment

Choose a reason for hiding this comment

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

Let's focus on gradle changes in this PR. Would you please remove these Kotlin tests?

@elect86
Copy link
Contributor Author

elect86 commented May 13, 2024

Let's focus on gradle changes in this PR. Would you please remove these Kotlin tests?

Absolutely, sorry, I already meant to do that, but I forgot

# Conflicts:
#	extension/tokenizers/src/main/python/arg_parser.py
#	extension/tokenizers/src/main/python/djl_converter/__init__.py
#	extension/tokenizers/src/main/python/djl_converter/arg_parser.py
#	extension/tokenizers/src/main/python/djl_converter/fill_mask_converter.py
#	extension/tokenizers/src/main/python/djl_converter/huggingface_converter.py
#	extension/tokenizers/src/main/python/djl_converter/huggingface_models.py
#	extension/tokenizers/src/main/python/djl_converter/metadata.py
#	extension/tokenizers/src/main/python/djl_converter/model_zoo_importer.py
#	extension/tokenizers/src/main/python/djl_converter/question_answering_converter.py
#	extension/tokenizers/src/main/python/djl_converter/safetensors_convert.py
#	extension/tokenizers/src/main/python/djl_converter/sentence_similarity_converter.py
#	extension/tokenizers/src/main/python/djl_converter/shasum.py
#	extension/tokenizers/src/main/python/djl_converter/text_classification_converter.py
#	extension/tokenizers/src/main/python/djl_converter/token_classification_converter.py
#	extension/tokenizers/src/main/python/djl_converter/zip_utils.py
#	extension/tokenizers/src/main/python/fill_mask_converter.py
#	extension/tokenizers/src/main/python/huggingface_converter.py
#	extension/tokenizers/src/main/python/huggingface_models.py
#	extension/tokenizers/src/main/python/metadata.py
#	extension/tokenizers/src/main/python/model_zoo_importer.py
#	extension/tokenizers/src/main/python/question_answering_converter.py
#	extension/tokenizers/src/main/python/safetensors_convert.py
#	extension/tokenizers/src/main/python/sentence_similarity_converter.py
#	extension/tokenizers/src/main/python/setup.py
#	extension/tokenizers/src/main/python/shasum.py
#	extension/tokenizers/src/main/python/text_classification_converter.py
#	extension/tokenizers/src/main/python/token_classification_converter.py
#	extension/tokenizers/src/main/python/zip_utils.py
#	extensions/tokenizers/src/main/python/arg_parser.py
#	extensions/tokenizers/src/main/python/fill_mask_converter.py
#	extensions/tokenizers/src/main/python/huggingface_converter.py
#	extensions/tokenizers/src/main/python/huggingface_models.py
#	extensions/tokenizers/src/main/python/metadata.py
#	extensions/tokenizers/src/main/python/model_zoo_importer.py
#	extensions/tokenizers/src/main/python/question_answering_converter.py
#	extensions/tokenizers/src/main/python/safetensors_convert.py
#	extensions/tokenizers/src/main/python/sentence_similarity_converter.py
#	extensions/tokenizers/src/main/python/shasum.py
#	extensions/tokenizers/src/main/python/text_classification_converter.py
#	extensions/tokenizers/src/main/python/token_classification_converter.py
#	extensions/tokenizers/src/main/python/zip_utils.py
#	gradle.properties
@elect86
Copy link
Contributor Author

elect86 commented May 13, 2024

I re-sync'ed with the upstream and re-ordered the versions in libs.versions.toml alphabetically

@@ -0,0 +1,22 @@
rootProject.name = "djl"

val reserved = listOf("gradle", "buildSrc")
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer list all project here, it can also treat as an project index file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer list all project here

Ok, as you wish

it can also treat as an project index file.

What do you mean, exactly?

#
# This file has been generated by Gradle and is intended to be consumed by Gradle
#
[metadata]
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is generated file, do we need to check in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was generated, but then I modified to fill in the needed libraries, I'll clean up that original comment

mxnet_version=1.9.1
pytorch_version=2.2.2
tensorflow_version=2.10.1
#djl_version=0.28.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Where these version will be defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the libs.versions.toml above :)

# Conflicts:
#	engines/pytorch/pytorch-engine/build.gradle
#	extension/tokenizers/src/main/python/djl_converter/model_converter.py
- cleaned libs.versions.toml comment
- removed, for the moment, type-safe projects accessors due to bug
@elect86
Copy link
Contributor Author

elect86 commented May 14, 2024

Addressed last wishes plus re-sync

@frankfliu
Copy link
Contributor

I really appreciate your contribution. But I ran into several failures:

  1. not able to compile on Mac M1 machine and windows: https://github.com/deepjavalibrary/djl/actions/runs/9076365418/job/24956766906?pr=3167#step:6:42
  2. Not able compile bom project:
cd bom
gradle build

> Configure project :
e: file:///Users/lufen/source/djl/bom/build.gradle.kts:18:13: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public val TaskContainer.projects: TaskProvider<ProjectReportTask> defined in org.gradle.kotlin.dsl
...
  1. continuous build failed: https://github.com/deepjavalibrary/djl/actions/runs/9076365418/job/24956767288?pr=3167#step:15:29

fixed integration:compileJava compilerArgs removal
# Conflicts:
#	integration/build.gradle
@frankfliu
Copy link
Contributor

@elect86

Still facing a few issues:

  1. Usage of layout.buildDirectory is wrong, it point to DirectoryProperty instead of Directory
  2. still got invalid flag: --release error

@elect86
Copy link
Contributor Author

elect86 commented May 14, 2024

the sourceCompatibility issue is fixed now, I switched from the toolchain to release option and seems fine (more here)

the error we are seeing now it's another one, which I'm gonna hunt down next

@elect86
Copy link
Contributor Author

elect86 commented May 15, 2024

so, I can reproduce locally

interesting to notice, I ran gradlew clean, then ./gradlew -Dai.djl.default_engine=OnnxRuntime :integration:test

same error:

elect@elect-NUC11PHi7:~/IdeaProjects/djl$ ./gradlew -Dai.djl.default_engine=OnnxRuntime :integration:test

Task :extensions:tokenizers:processResources
prebuilt or cached file found for win-x86_64/libwinpthread-1.dll
prebuilt or cached file found for win-x86_64/libgcc_s_seh-1.dll
prebuilt or cached file found for win-x86_64/libstdc%2B%2B-6.dll
prebuilt or cached file found for win-x86_64/tokenizers.dll
prebuilt or cached file found for linux-x86_64/libtokenizers.so
prebuilt or cached file found for linux-aarch64/libtokenizers.so
prebuilt or cached file found for osx-x86_64/libtokenizers.dylib
prebuilt or cached file found for osx-aarch64/libtokenizers.dylib
Downloading PyTorch model zoo metadata: fill_mask
Downloading PyTorch model zoo metadata: question_answer
Downloading PyTorch model zoo metadata: text_classification
Downloading PyTorch model zoo metadata: text_embedding
Downloading Rust model zoo metadata: text_embedding
Downloading PyTorch model zoo metadata: token_classification

Task :engines:ml:xgboost:processResources
Downloading https://publish.djl.ai/xgboost/2.0.3/jnilib/linux/aarch64/libxgboost4j.so

Task :engines:ml:xgboost:jar FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':engines:ml:xgboost:jar'.
    Cannot expand ZIP '/home/elect/IdeaProjects/djl/api/build/classes/java/main' as it is not a file.

I ran the test one another time and now I get

elect@elect-NUC11PHi7:~/IdeaProjects/djl$ ./gradlew -Dai.djl.default_engine=OnnxRuntime :integration:test

Task :engines:mxnet:jnarator:compileJava
/home/elect/IdeaProjects/djl/engines/mxnet/jnarator/build/generated-src/antlr/main/ai/djl/mxnet/jnarator/parser/CParser.java:190: warning: [this-escape] possible 'this' escape before subclass is fully initialized
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
^
/home/elect/IdeaProjects/djl/engines/mxnet/jnarator/build/generated-src/antlr/main/ai/djl/mxnet/jnarator/parser/CLexer.java:160: warning: [this-escape] possible 'this' escape before subclass is fully initialized
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
^
2 warnings

Task :engines:onnxruntime:onnxruntime-engine:processResources
Downloading model zoo metadata: fill_mask
Downloading model zoo metadata: question_answer
Downloading model zoo metadata: text_classification
Downloading model zoo metadata: text_embedding
Downloading model zoo metadata: token_classification

Task :engines:pytorch:pytorch-jni:processResources
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/linux-x86_64/cpu/libdjl_torch.so
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/linux-x86_64/cpu-precxx11/libdjl_torch.so
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/linux-aarch64/cpu-precxx11/libdjl_torch.so
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/osx-aarch64/cpu/libdjl_torch.dylib
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/win-x86_64/cpu/djl_torch.dll
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/linux-x86_64/cu121/libdjl_torch.so
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/linux-x86_64/cu121-precxx11/libdjl_torch.so
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/win-x86_64/cu121/djl_torch.dll
Downloading https://publish.djl.ai/pytorch/2.2.2/jnilib/0.28.0/osx-x86_64/cpu/libdjl_torch.dylib

Task :integration:test FAILED

Gradle suite > Gradle test > ai.djl.CoverageTest > test FAILED
java.lang.NoClassDefFoundError at CoverageTest.java:34
Caused by: java.lang.ClassNotFoundException at CoverageTest.java:34

Gradle suite > Gradle test > ai.djl.integration.IntegrationTests > runIntegrationTests FAILED
java.lang.NoClassDefFoundError at IntegrationTests.java:56
Caused by: java.lang.ClassNotFoundException at IntegrationTests.java:56

@elect86
Copy link
Contributor Author

elect86 commented May 15, 2024

running ml:xgboost:jar after a clean lead to the same not a file error

@elect86
Copy link
Contributor Author

elect86 commented May 15, 2024

Ok, I fixed the first error

now I have both local and CI crashing with the same last error above

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.53%. Comparing base (5c691c0) to head (f9abfc2).
Report is 20 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3167      +/-   ##
============================================
- Coverage     68.41%   63.53%   -4.89%     
+ Complexity     7027     6451     -576     
============================================
  Files           697      697              
  Lines         32759    32790      +31     
  Branches       3406     3416      +10     
============================================
- Hits          22413    20833    -1580     
- Misses         8737    10380    +1643     
+ Partials       1609     1577      -32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@frankfliu frankfliu force-pushed the master branch 3 times, most recently from 9a25da0 to ace47ca Compare May 21, 2024 14:13
@frankfliu frankfliu merged commit 97c6a0d into deepjavalibrary:master May 27, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants