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

ci: auto release java #2827

Merged
merged 5 commits into from
Sep 9, 2024
Merged
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
72 changes: 54 additions & 18 deletions .github/workflows/bump-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,61 @@ name: Bump version for releases
description: "Call bumpversion"
inputs:
part:
description: 'What kind of release is this?'
description: "What kind of release is this?"
required: true
default: 'release'
default: "release"
runs:
using: "composite"
steps:
- name: Set git configs for bumpversion
shell: bash
run: |
git config user.name 'Lance Release'
git config user.email '[email protected]'
- name: Create release version and tags
working-directory: python
shell: bash
run: |
cargo install cargo-bump
cargo bump ${{ inputs.part }}
- name: Synchronize rust version
shell: bash
run: |
cargo install cargo-workspaces --version 0.2.44
cargo ws version --no-git-commit -y --exact --force 'lance*' ${{ inputs.part }}
- name: Set git configs for bumpversion
shell: bash
run: |
git config user.name 'Lance Release'
git config user.email '[email protected]'
- name: Create release version and tags
working-directory: python
shell: bash
run: |
cargo install cargo-bump
cargo bump ${{ inputs.part }}
- name: Synchronize rust version
shell: bash
run: |
cargo install cargo-workspaces --version 0.2.44
cargo ws version --no-git-commit -y --exact --force 'lance*' ${{ inputs.part }}
- name: Bump java version
Copy link
Contributor

Choose a reason for hiding this comment

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

in my previous experience, we always only auto-bump patch version. all major/minor should be manual commit. but it is up to the lance community :-P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, lance community also only auto bump patch version, major/minor needs to be manual commit.
Lancedb release pipeline opens the door for auto bump minor version but is also not recommended.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok i might've misunderstood. but looksl ike the code below handles major/minor/patch bump?

Copy link
Contributor

Choose a reason for hiding this comment

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

We have the capability to bump other versions, but we generally only automatically increment minor version.

working-directory: java
shell: bash
run: |
# Get current version
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
current_version=${current_version%\%}

# Split the version into components using parameter expansion
major=${current_version%%.*}
minor=${current_version#*.}
minor=${minor%%.*}
patch=${current_version##*.}

case "${{ inputs.part }}" in
patch)
patch=$((patch + 1))
;;
minor)
minor=$((minor + 1))
patch=0
;;
major)
major=$((major + 1))
minor=0
patch=0
;;
*)
echo "Invalid part specified"
exit 1
;;
esac

new_version="${major}.${minor}.${patch}"

mvn versions:set versions:commit -DnewVersion=$new_version
7 changes: 7 additions & 0 deletions .github/workflows/java-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Build and publish Java packages
on:
release:
# Use released instead of published, since we don't publish preview/beta
# versions
Comment on lines +4 to +5
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to start publishing them later? Feel like it could be useful since we distribute the binaries for Java, right? The only reason we skip Rust is because it's a source-only release, so there's no benefit of publishing over just letting people reference the git repo directly.

types: [released]
pull_request:
paths:
Expand Down Expand Up @@ -99,7 +101,12 @@ jobs:
run: |
git config --global user.email "Lance Github Runner"
git config --global user.name "[email protected]"
- name: Dry run
if: github.event_name == 'pull_request'
run: |
mvn --batch-mode -DskipTests package
- name: Publish with Java 8
if: github.event_name == 'release'
Copy link
Contributor

Choose a reason for hiding this comment

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

i am a bit confused here. dont you need to invoke bump version first before running Publish with Java 8 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The release pipeline is

  • create a github tag with version bumped
  • create a github release with the created tag
  • a github stable release automatically triggers the java/python publish process

Copy link
Contributor

Choose a reason for hiding this comment

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

ah i see. i've also see you modified the release_process.md. nice. thanks!

run: |
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ jobs:
-Djdk.reflect.useDirectMethodHandle=false \
-Dio.netty.tryReflectionSetAccessible=true"
fi
mvn clean test
mvn clean install
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

4 changes: 3 additions & 1 deletion java/core/src/main/java/com/lancedb/lance/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ public LanceScanner newScan(ScanOptions options) {

/**
* Gets the currently checked out version of the dataset.
*
* @return the version of the dataset
*/
public long version() {
try (LockManager.ReadLock readLock = lockManager.acquireReadLock()) {
Expand All @@ -248,7 +250,7 @@ public long version() {
private native long nativeVersion();

/**
* Gets the latest version of the dataset.
* @return the latest version of the dataset.
*/
public long latestVersion() {
try (LockManager.ReadLock readLock = lockManager.acquireReadLock()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public int getId() {
return metadata.getId();
}

/** Count rows in this Fragment. */
/**
* @return row counts in this Fragment
*/
public int countRows() {
return countRowsNative(dataset, metadata.getId());
}
Expand Down
20 changes: 18 additions & 2 deletions java/core/src/main/java/com/lancedb/lance/Fragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ public class Fragment {
JniLoader.ensureLoaded();
}

/** Create a fragment from the given data in vector schema root. */
/**
* Create a fragment from the given data.
*
* @param datasetUri the dataset uri
* @param allocator the buffer allocator
* @param root the vector schema root
* @param fragmentId the fragment id
* @param params the write params
* @return the fragment metadata
*/
public static FragmentMetadata create(String datasetUri, BufferAllocator allocator,
VectorSchemaRoot root, Optional<Integer> fragmentId, WriteParams params) {
Preconditions.checkNotNull(datasetUri);
Expand All @@ -46,7 +55,14 @@ public static FragmentMetadata create(String datasetUri, BufferAllocator allocat
}
}

/** Create a fragment from the given data. */
/**
* Create a fragment from the given arrow stream.
* @param datasetUri the dataset uri
* @param stream the arrow stream
* @param fragmentId the fragment id
* @param params the write params
* @return the fragment metadata
*/
public static FragmentMetadata create(String datasetUri, ArrowArrayStream stream,
Optional<Integer> fragmentId, WriteParams params) {
Preconditions.checkNotNull(datasetUri);
Expand Down
12 changes: 12 additions & 0 deletions java/core/src/main/java/com/lancedb/lance/ReadOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public static class Builder {
/**
* Set the version of the dataset to read.
* If not set, read from latest version.
*
* @param version the version of the dataset
* @return this builder
*/
public Builder setVersion(int version) {
this.version = Optional.of(version);
Expand All @@ -80,6 +83,9 @@ public Builder setVersion(int version) {
* Block size in bytes.
* Provide a hint for the size of the minimal I/O request.
* Recommended to be set to value bigger than 4KB.
*
* @param blockSize the block size in bytes
* @return this builder
*/
public Builder setBlockSize(int blockSize) {
this.blockSize = Optional.of(blockSize);
Expand All @@ -97,6 +103,9 @@ public Builder setBlockSize(int blockSize) {
* / number of IVF partitions.
* pq = number of PQ sub-vectors.
* Default is 256.
*
* @param indexCacheSize the index cache size
* @return this builder
*/
public Builder setIndexCacheSize(int indexCacheSize) {
this.indexCacheSize = indexCacheSize;
Expand All @@ -107,6 +116,9 @@ public Builder setIndexCacheSize(int indexCacheSize) {
* Metadata cache size for the fragment metadata. If it is zero, metadata
* cache is disabled.
* Default is 256.
*
* @param metadataCacheSize the metadata cache size
* @return this builder
*/
public Builder setMetadataCacheSize(int metadataCacheSize) {
this.metadataCacheSize = metadataCacheSize;
Expand Down
13 changes: 11 additions & 2 deletions java/core/src/main/java/com/lancedb/lance/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,23 @@
/** Utility. */
public class Utils {

/** Convert Arrow Schema to FFI Arrow Schema. */
/**
* Convert schema to ArrowSchema for JNI processing.
* @param schema schema
* @param allocator buffer allocator
* @return ArrowSchema
*/
public static ArrowSchema toFfi(Schema schema, BufferAllocator allocator) {
ArrowSchema arrowSchema = ArrowSchema.allocateNew(allocator);
Data.exportSchema(allocator, schema, null, arrowSchema);
return arrowSchema;
}

/** Convert optional array to optional list for JNI processing. */
/**
* Convert optional array to optional list for JNI processing.
* @param optionalArray Optional array
* @return Optional list
*/
public static Optional<List<String>> convert(Optional<String[]> optionalArray) {
if (optionalArray.isPresent()) {
return Optional.of(Arrays.asList(optionalArray.get()));
Expand Down
5 changes: 4 additions & 1 deletion java/core/src/main/java/com/lancedb/lance/WriteParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public Optional<Long> getMaxBytesPerFile() {
return maxBytesPerFile;
}

/** Get Mode with name. */
/**
* Get Mode with name.
* @return mode
*/
public Optional<String> getMode() {
return mode.map(Enum::name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public Builder() {}
/**
* Set the distance type for calculating the distance between vectors.
* Default to L2.
*
* @param distanceType distance type
* @return this builder
*/
public Builder setDistanceType(DistanceType distanceType) {
this.distanceType = distanceType;
Expand All @@ -47,6 +50,8 @@ public Builder setDistanceType(DistanceType distanceType) {

/**
* Vector index parameters for creating a vector index.
* @param vectorIndexParams vector index parameters
* @return this builder
*/
public Builder setVectorIndexParams(VectorIndexParams vectorIndexParams) {
this.vectorIndexParams = Optional.of(vectorIndexParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public Builder setShufflePartitionBatches(int shufflePartitionBatches) {
* By making this value smaller, this shuffle will consume less memory
* but will take longer to complete, and vice versa.
*
* @param shufflePartitionConcurrency
* @param shufflePartitionConcurrency the number of shuffle partitions to process concurrently
* @return Builder
*/
public Builder setShufflePartitionConcurrency(int shufflePartitionConcurrency) {
Expand All @@ -125,7 +125,7 @@ public Builder setShufflePartitionConcurrency(int shufflePartitionConcurrency) {

/**
* Set whether to use residual for k-means clustering. Default value is true.
* @param useResidual
* @param useResidual whether to use residual for k-means clustering
* @return Builder
*/
public Builder setUseResidual(boolean useResidual) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Builder() {
* The number of subvectors to divide the source vectors into.
* This must be a divisor of the vector dimension.
*
* @param numSubVectors
* @param numSubVectors the number of subvectors
* @return Builder
*/
public Builder setNumSubVectors(int numSubVectors) {
Expand Down Expand Up @@ -95,7 +95,7 @@ public Builder setKmeansRedos(int kmeansRedos) {

/**
* @param sampleRate sample rate to train PQ codebook
* @return
* @return Builder
*/
public Builder setSampleRate(int sampleRate) {
this.sampleRate = sampleRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Builder setNumBits(short numBits) {

/**
* @param sampleRate sample rate for training
* @return
* @return Builder
*/
public Builder setSampleRate(int sampleRate) {
this.sampleRate = sampleRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private void validate() {
*
* @param numPartitions the number of partitions of IVF (Inverted File Index)
* @param distanceType the distance type for calculating the distance between vectors
* @return the VectorIndexParams
*/
public static VectorIndexParams ivfFlat(int numPartitions, DistanceType distanceType) {
return new Builder(new IvfBuildParams.Builder().setNumPartitions(numPartitions).build())
Expand Down Expand Up @@ -92,8 +93,8 @@ public static VectorIndexParams ivfPq(int numPartitions, int numBits, int numSub
* Create a new IVF index with PQ quantizer.
*
* @param distanceType the distance type for calculating the distance between vectors
* @param IvfBuildParams the IVF build parameters
* @param PQBuildParams the PQ build parameters
* @param ivf the IVF build parameters
* @param pq the PQ build parameters
* @return the VectorIndexParams
*/
public static VectorIndexParams withIvfPqParams(DistanceType distanceType,
Expand All @@ -110,9 +111,9 @@ public static VectorIndexParams withIvfPqParams(DistanceType distanceType,
* The dataset is partitioned into IVF partitions, and each partition builds an HNSW graph.
*
* @param distanceType the distance type for calculating the distance between vectors
* @param IvfBuildParams the IVF build parameters
* @param hnswBuildParams the HNSW build parameters
* @param PQBuildParams the PQ build parameters
* @param ivf the IVF build parameters
* @param hnsw the HNSW build parameters
* @param pq the PQ build parameters
* @return the VectorIndexParams
*/
public static VectorIndexParams withIvfHnswPqParams(DistanceType distanceType,
Expand All @@ -131,9 +132,9 @@ public static VectorIndexParams withIvfHnswPqParams(DistanceType distanceType,
* The dataset is partitioned into IVF partitions, and each partition builds an HNSW graph.
*
* @param distanceType the distance type for calculating the distance between vectors
* @param IvfBuildParams the IVF build parameters
* @param hnswBuildParams the HNSW build parameters
* @param SQBuildParams the SQ build parameters
* @param ivf the IVF build parameters
* @param hnsw the HNSW build parameters
* @param sq the SQ build parameters
* @return the VectorIndexParams
*/
public static VectorIndexParams withIvfHnswSqParams(DistanceType distanceType,
Expand Down Expand Up @@ -173,7 +174,7 @@ public Builder setDistanceType(DistanceType distanceType) {
}

/**
* @param sqParams the SQ quantizer build parameters
* @param pqParams the PQ quantizer build parameters
* @return Builder
*/
public Builder setPqParams(PQBuildParams pqParams) {
Expand Down
Loading
Loading