Skip to content

Commit

Permalink
Kotlin upgrade, Spring client update (#6)
Browse files Browse the repository at this point in the history
This pull request includes several changes across multiple files to
improve the build process, update dependencies, and enhance
documentation.

- Implemented lazy-loaded properties for more efficient API method
initialization.
- Test cases have been updated accordingly to accommodate the new access
pattern.
- **Workaround for polymorphic deserialization without supertype.**
Deserialize into JsonNode and then programmaticaly to the correct type

---------

Co-authored-by: Konstantin Pavlov <{ID}+{username}@users.noreply.github.com>
  • Loading branch information
kpavlov and Konstantin Pavlov authored Dec 5, 2024
1 parent 43bdcec commit 345d4a3
Show file tree
Hide file tree
Showing 13 changed files with 609 additions and 167 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Publish Docs to GitHub Pages

on:
release:
types:
- created
push:
branches: [ "main" ]
# Allow running this workflow manually from the Actions tab
workflow_dispatch:

jobs:
deploy:

permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 23
uses: actions/setup-java@v4
with:
java-version: '23'
distribution: 'temurin'
cache: maven

- name: Generate Dokka Site
run: |-
mvn clean compile site && \
mkdir -p target/docs && \
cp -R target/dokka target/docs/api
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: target/docs/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .idea/ktlint-plugin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 23 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
build:
mvn clean verify site

lint:
# brew install ktlint
ktlint --format
# https://docs.openrewrite.org/recipes/maven/bestpractices
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.activeRecipes=org.openrewrite.maven.BestPractices \
-Drewrite.exportDatatables=true
mvn clean verify site

apidocs:
mvn mvn clean compile site && \
mkdir -p target/docs && \
cp -R target/dokka target/docs/api

lint:prepare
ktlint '!**/target/**' && \
mvn spotless:check

# https://docs.openrewrite.org/recipes/maven/bestpractices
format:prepare
ktlint --format '!**/target/**' && \
mvn spotless:apply && \
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.activeRecipes=org.openrewrite.maven.BestPractices \
-Drewrite.exportDatatables=true

prepare:
brew install ktlint --quiet

all: format lint build
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Langfuse-JVM 🪢☕️

JVM clients for [Langfuse](https://api.reference.langfuse.com)

[![Kotlin CI with Maven](https://github.com/kpavlov/langfuse-jvm/actions/workflows/maven.yml/badge.svg?branch=main)](https://github.com/kpavlov/langfuse-jvm/actions/workflows/maven.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b213cf0965cb47dba3bdd67e3b463e08)](https://app.codacy.com/gh/kpavlov/langfuse-jvm/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Codacy Coverage](https://app.codacy.com/project/badge/Coverage/b213cf0965cb47dba3bdd67e3b463e08)](https://app.codacy.com/gh/kpavlov/langfuse-jvm/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
[![ktlint](https://img.shields.io/badge/ktlint%20code--style-%E2%9D%A4-FF4081)](https://pinterest.github.io/ktlint/)

# Overview

Expand All @@ -23,10 +25,13 @@ LANGFUSE_HOST="https://cloud.langfuse.com" # 🇪🇺 EU region
```

Building project locally:

```shell
mvn clean verify
```

or

```shell
make build
```
Expand Down
18 changes: 9 additions & 9 deletions langfuse-client-java/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>
<parent>
<groupId>me.kpavlov.langfuse</groupId>
Expand Down Expand Up @@ -43,7 +41,6 @@
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${jackson-databind-nullable.version}</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
Expand Down Expand Up @@ -99,13 +96,15 @@
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<extensions>true</extensions> <!-- You can set this option
<extensions>true</extensions>
<!-- You can set this option
to automatically take information about lifecycles -->
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal> <!-- You can skip the <goals> element
<goal>compile</goal>
<!-- You can skip the <goals> element
if you enable extensions for the plugin -->
</goals>
<configuration>
Expand All @@ -119,7 +118,8 @@
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal> <!-- You can skip the <goals> element
<goal>test-compile</goal>
<!-- You can skip the <goals> element
if you enable extensions for the plugin -->
</goals>
<configuration>
Expand All @@ -146,17 +146,17 @@
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<phase>compile</phase>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<phase>test-compile</phase>
</execution>
</executions>
</plugin>
Expand Down
62 changes: 32 additions & 30 deletions langfuse-client-spring/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>
<parent>
<groupId>me.kpavlov.langfuse</groupId>
Expand Down Expand Up @@ -30,7 +28,6 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
Expand All @@ -40,6 +37,22 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-reactor</artifactId>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
Expand Down Expand Up @@ -69,37 +82,26 @@
<goal>generate</goal>
</goals>
<configuration>
<generatorName>kotlin</generatorName>
<library>jvm-spring-webclient</library>
<generatorName>java</generatorName>
<library>webclient</library>
<packageName>me.kpavlov.langfuse.spring</packageName>
<apiPackage>me.kpavlov.langfuse.spring</apiPackage>
<modelPackage>me.kpavlov.langfuse.spring.model</modelPackage>
<configOptions>
<omitGradleWrapper>true</omitGradleWrapper>
<omitGradlePluginVersions>true</omitGradlePluginVersions>
<nullableReturnType>false</nullableReturnType>
<enumPropertyNaming>UPPERCASE</enumPropertyNaming>
<annotationLibrary>none</annotationLibrary>
<documentationProvider>none</documentationProvider>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<openApiNullable>true</openApiNullable>
<serializationLibrary>jackson</serializationLibrary>
<sortModelPropertiesByRequiredFlag>true</sortModelPropertiesByRequiredFlag>
<sortParamsByRequiredFlag>true</sortParamsByRequiredFlag>
<useAbstractionForFiles>true</useAbstractionForFiles>
<useGzipFeature>true</useGzipFeature>
<useJakartaEe>true</useJakartaEe>
<useOneOfDiscriminatorLookup>true</useOneOfDiscriminatorLookup>
<useOneOfInterfaces>true</useOneOfInterfaces>
<enumUnknownDefaultCase>true</enumUnknownDefaultCase>
<legacyDiscriminatorBehavior>true</legacyDiscriminatorBehavior>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/openapi/src/main/kotlin</source>
</sources>
<typeMappings>Prompt=com.fasterxml.jackson.databind.JsonNode</typeMappings>
</configuration>
</execution>
</executions>
Expand All @@ -110,7 +112,7 @@
<configuration>
<sourceDirectories>
<dir>${project.basedir}/src/main/kotlin</dir>
<dir>${project.basedir}/target/generated-sources/openapi/src/main/kotlin</dir>
<dir>${project.basedir}/target/generated-sources/openapi/src/main/java</dir>
</sourceDirectories>
</configuration>
</plugin>
Expand Down
Loading

0 comments on commit 345d4a3

Please sign in to comment.