{ "cells": [ { "cell_type": "code", "metadata": { "collapsed": true, "ExecuteTime": { "end_time": "2025-05-31T08:53:54.394193Z", "start_time": "2025-05-31T08:53:17.797604Z" } }, "source": [ "import dev.johnoreilly.climatetrace.di.createHttpClient\n", "import dev.johnoreilly.climatetrace.remote.ClimateTraceApi\n", "import io.ktor.client.engine.java.*\n", "import kotlinx.coroutines.runBlocking\n", "import kotlinx.serialization.json.Json\n", "%useLatestDescriptors\n", "%use dataframe, kandy\n", "%use kandy-geo\n", "\n", "val json = Json { isLenient = true; ignoreUnknownKeys = true }\n", "val engine = Java.create()\n", "val httpClient = createHttpClient(json, true)\n", "val api = ClimateTraceApi(httpClient)\n", "\n", "\n", "\n", "var emissionInfo = runBlocking { api.fetchCountryAssetEmissionsInfo(\"FRA\") }\n", "val emissionsDataFrame = emissionInfo.toDataFrame()\n", "\n", "emissionsDataFrame.sortByDesc(\"emissions\").take(6).plot {\n", " layout.size = 600 to 400\n", " barsH {\n", " y(\"sector\")\n", " x(\"emissions\")\n", " }\n", "}\n", "\n", "\n", "\n", "\n", "//val usaStates =\n", "// GeoDataFrame.readGeoJson(\"https://raw.githubusercontent.com/AndreiKingsley/datasets/refs/heads/main/USA.json\")\n", "//\n", "//usaStates.plot {\n", "// geoPolygon()\n", "//}\n" ], "outputs": [ { "ename": "io.ktor.serialization.JsonConvertException", "evalue": "Illegal input: Receiver class dev.johnoreilly.climatetrace.remote.CountryAssetEmissionsInfo$$serializer does not define or inherit an implementation of the resolved method 'abstract kotlinx.serialization.KSerializer[] typeParametersSerializers()' of interface kotlinx.serialization.internal.GeneratedSerializer.", "output_type": "error", "traceback": [ "io.ktor.serialization.JsonConvertException: Illegal input: Receiver class dev.johnoreilly.climatetrace.remote.CountryAssetEmissionsInfo$$serializer does not define or inherit an implementation of the resolved method 'abstract kotlinx.serialization.KSerializer[] typeParametersSerializers()' of interface kotlinx.serialization.internal.GeneratedSerializer.", "\tat io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:79)", "\tat io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1$2.emit(Emitters.kt:51)", "\tat kotlinx.coroutines.flow.FlowKt__BuildersKt$asFlow$$inlined$unsafeFlow$3.collect(SafeCollector.common.kt:111)", "\tat io.ktor.serialization.ContentConverterKt$deserialize$$inlined$map$1.collect(SafeCollector.common.kt:109)", "\tat kotlinx.coroutines.flow.FlowKt__ReduceKt.firstOrNull(Reduce.kt:247)", "\tat kotlinx.coroutines.flow.FlowKt.firstOrNull(Unknown Source)", "\tat io.ktor.serialization.ContentConverterKt.deserialize(ContentConverter.kt:113)", "\tat io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt.ContentNegotiation$lambda$16$convertResponse(ContentNegotiation.kt:281)", "\tat io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt.access$ContentNegotiation$lambda$16$convertResponse(ContentNegotiation.kt:1)", "\tat io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt$ContentNegotiation$2$2.invokeSuspend(ContentNegotiation.kt:296)", "\tat io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt$ContentNegotiation$2$2.invoke(ContentNegotiation.kt)", "\tat io.ktor.client.plugins.contentnegotiation.ContentNegotiationKt$ContentNegotiation$2$2.invoke(ContentNegotiation.kt)", "\tat io.ktor.client.plugins.api.TransformResponseBodyHook$install$1.invokeSuspend(KtorCallContexts.kt:113)", "\tat io.ktor.client.plugins.api.TransformResponseBodyHook$install$1.invoke(KtorCallContexts.kt)", "\tat io.ktor.client.plugins.api.TransformResponseBodyHook$install$1.invoke(KtorCallContexts.kt)", "\tat io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:79)", "\tat io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:57)", "\tat io.ktor.client.HttpClient$4.invokeSuspend(HttpClient.kt:1401)", "\tat io.ktor.client.HttpClient$4.invoke(HttpClient.kt)", "\tat io.ktor.client.HttpClient$4.invoke(HttpClient.kt)", "\tat io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:79)", "\tat io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:57)", "\tat io.ktor.client.plugins.ReceiveError$install$1.invokeSuspend(HttpCallValidator.kt:165)", "\tat io.ktor.client.plugins.ReceiveError$install$1.invoke(HttpCallValidator.kt)", "\tat io.ktor.client.plugins.ReceiveError$install$1.invoke(HttpCallValidator.kt)", "\tat io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:79)", "\tat io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:57)", "\tat io.ktor.util.pipeline.DebugPipelineContext.execute$ktor_utils(DebugPipelineContext.kt:63)", "\tat io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:92)", "\tat io.ktor.client.call.HttpClientCall.bodyNullable(HttpClientCall.kt:99)", "\tat dev.johnoreilly.climatetrace.remote.ClimateTraceApi.fetchCountryAssetEmissionsInfo(ClimateTraceApi.kt:341)", "\tat dev.johnoreilly.climatetrace.remote.ClimateTraceApi$fetchCountryAssetEmissionsInfo$1.invokeSuspend(ClimateTraceApi.kt)", "\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)", "\tat kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)", "\tat kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)", "\tat kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)", "\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)", "\tat kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)", "\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:47)", "\tat kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)", "\tat Line_22_jupyter.(Line_22.jupyter.kts:17) at Cell In[2], line 17", "\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(Unknown Source)", "\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)", "\tat java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)", "\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:122)", "\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:48)", "\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)", "\tat kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:49)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl$eval$resultWithDiagnostics$1.invokeSuspend(InternalEvaluatorImpl.kt:137)", "\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)", "\tat kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)", "\tat kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)", "\tat kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)", "\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)", "\tat kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)", "\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:48)", "\tat kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:137)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:80)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:78)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.withHost(ReplForJupyterImpl.kt:791)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute-L4Nmkdk(CellExecutorImpl.kt:78)", "\tat org.jetbrains.kotlinx.jupyter.repl.execution.CellExecutor$DefaultImpls.execute-L4Nmkdk$default(CellExecutor.kt:13)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.evaluateUserCode-wNURfNM(ReplForJupyterImpl.kt:613)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.evalExImpl(ReplForJupyterImpl.kt:471)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.access$evalExImpl(ReplForJupyterImpl.kt:143)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl$evalEx$1.invoke(ReplForJupyterImpl.kt:464)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl$evalEx$1.invoke(ReplForJupyterImpl.kt:463)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.withEvalContext(ReplForJupyterImpl.kt:444)", "\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.evalEx(ReplForJupyterImpl.kt:463)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$processExecuteRequest$1$response$1$1.invoke(IdeCompatibleMessageRequestProcessor.kt:159)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$processExecuteRequest$1$response$1$1.invoke(IdeCompatibleMessageRequestProcessor.kt:158)", "\tat org.jetbrains.kotlinx.jupyter.streams.BlockingSubstitutionEngine.withDataSubstitution(SubstitutionEngine.kt:70)", "\tat org.jetbrains.kotlinx.jupyter.streams.StreamSubstitutionManager.withSubstitutedStreams(StreamSubstitutionManager.kt:118)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.withForkedIn(IdeCompatibleMessageRequestProcessor.kt:335)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.access$withForkedIn(IdeCompatibleMessageRequestProcessor.kt:54)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$evalWithIO$1$1.invoke(IdeCompatibleMessageRequestProcessor.kt:349)", "\tat org.jetbrains.kotlinx.jupyter.streams.BlockingSubstitutionEngine.withDataSubstitution(SubstitutionEngine.kt:70)", "\tat org.jetbrains.kotlinx.jupyter.streams.StreamSubstitutionManager.withSubstitutedStreams(StreamSubstitutionManager.kt:118)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.withForkedErr(IdeCompatibleMessageRequestProcessor.kt:324)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.access$withForkedErr(IdeCompatibleMessageRequestProcessor.kt:54)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$evalWithIO$1.invoke(IdeCompatibleMessageRequestProcessor.kt:348)", "\tat org.jetbrains.kotlinx.jupyter.streams.BlockingSubstitutionEngine.withDataSubstitution(SubstitutionEngine.kt:70)", "\tat org.jetbrains.kotlinx.jupyter.streams.StreamSubstitutionManager.withSubstitutedStreams(StreamSubstitutionManager.kt:118)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.withForkedOut(IdeCompatibleMessageRequestProcessor.kt:316)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor.evalWithIO(IdeCompatibleMessageRequestProcessor.kt:347)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$processExecuteRequest$1$response$1.invoke(IdeCompatibleMessageRequestProcessor.kt:158)", "\tat org.jetbrains.kotlinx.jupyter.messaging.IdeCompatibleMessageRequestProcessor$processExecuteRequest$1$response$1.invoke(IdeCompatibleMessageRequestProcessor.kt:157)", "\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl$Task.execute(JupyterExecutorImpl.kt:41)", "\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl$executorThread$1.invoke(JupyterExecutorImpl.kt:83)", "\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl$executorThread$1.invoke(JupyterExecutorImpl.kt:80)", "\tat kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)", "Caused by: java.lang.AbstractMethodError: Receiver class dev.johnoreilly.climatetrace.remote.CountryAssetEmissionsInfo$$serializer does not define or inherit an implementation of the resolved method 'abstract kotlinx.serialization.KSerializer[] typeParametersSerializers()' of interface kotlinx.serialization.internal.GeneratedSerializer.", "\tat kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$typeParameterDescriptors$2.invoke(PluginGeneratedSerialDescriptor.kt:40)", "\tat kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$typeParameterDescriptors$2.invoke(PluginGeneratedSerialDescriptor.kt:39)", "\tat kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)", "\tat kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.getTypeParameterDescriptors$kotlinx_serialization_core(PluginGeneratedSerialDescriptor.kt:39)", "\tat kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$_hashCode$2.invoke(PluginGeneratedSerialDescriptor.kt:44)", "\tat kotlinx.serialization.internal.PluginGeneratedSerialDescriptor$_hashCode$2.invoke(PluginGeneratedSerialDescriptor.kt:44)", "\tat kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:107)", "\tat kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.get_hashCode(PluginGeneratedSerialDescriptor.kt:44)", "\tat kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.hashCode(PluginGeneratedSerialDescriptor.kt:97)", "\tat java.base/java.util.concurrent.ConcurrentHashMap.get(Unknown Source)", "\tat kotlinx.serialization.json.internal.DescriptorSchemaCache.get(SchemaCache.kt:37)", "\tat kotlinx.serialization.json.internal.DescriptorSchemaCache.getOrPut(SchemaCache.kt:29)", "\tat kotlinx.serialization.json.internal.JsonNamesMapKt.deserializationNamesMap(JsonNamesMap.kt:54)", "\tat kotlinx.serialization.json.internal.JsonNamesMapKt.getJsonNameIndexSlowPath(JsonNamesMap.kt:73)", "\tat kotlinx.serialization.json.internal.JsonNamesMapKt.getJsonNameIndex(JsonNamesMap.kt:97)", "\tat kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeObjectIndex(StreamingJsonDecoder.kt:229)", "\tat kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeElementIndex(StreamingJsonDecoder.kt:178)", "\tat dev.johnoreilly.climatetrace.remote.CountryAssetEmissionsInfo$$serializer.deserialize(ClimateTraceApi.kt:43)", "\tat dev.johnoreilly.climatetrace.remote.CountryAssetEmissionsInfo$$serializer.deserialize(ClimateTraceApi.kt:43)", "\tat kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)", "\tat kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)", "\tat kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)", "\tat kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)", "\tat kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:538)", "\tat kotlinx.serialization.internal.CollectionLikeSerializer.readElement(CollectionSerializers.kt:80)", "\tat kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)", "\tat kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)", "\tat kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)", "\tat kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)", "\tat kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:43)", "\tat kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableElement(AbstractDecoder.kt:70)", "\tat kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableElement(StreamingJsonDecoder.kt:168)", "\tat kotlinx.serialization.encoding.CompositeDecoder$DefaultImpls.decodeSerializableElement$default(Decoding.kt:538)", "\tat kotlinx.serialization.internal.MapLikeSerializer.readElement(CollectionSerializers.kt:111)", "\tat kotlinx.serialization.internal.MapLikeSerializer.readElement(CollectionSerializers.kt:84)", "\tat kotlinx.serialization.internal.AbstractCollectionSerializer.readElement$default(CollectionSerializers.kt:51)", "\tat kotlinx.serialization.internal.AbstractCollectionSerializer.merge(CollectionSerializers.kt:36)", "\tat kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:43)", "\tat kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)", "\tat kotlinx.serialization.json.Json.decodeFromString(Json.kt:107)", "\tat io.ktor.serialization.kotlinx.KotlinxSerializationConverter.deserialize(KotlinxSerializationConverter.kt:71)", "\t... 91 more", "", "io.ktor.serialization.JsonConvertException: Illegal input: Receiver class dev.johnoreilly.climatetrace.remote.CountryAssetEmissionsInfo$$serializer does not define or inherit an implementation of the resolved method 'abstract kotlinx.serialization.KSerializer[] typeParametersSerializers()' of interface kotlinx.serialization.internal.GeneratedSerializer.", "at Cell In[2], line 17", "" ] } ], "execution_count": 2 }, { "metadata": {}, "cell_type": "code", "source": [ "val countries = runBlocking { api.fetchCountries() }.toDataFrame()\n", "countries\n", "//countries.toDataFrame().plot {\n", "// layout.size = 600 to 400\n", "// points {\n", "// x(\"longitude\")\n", "// y(\"latitude\")\n", "// }\n", "//}\n", "//val points =\n", "\n", "\n", "//GeoDataFrame.readGeoJson(\"europe.geojson\")" ], "outputs": [], "execution_count": null }, { "cell_type": "code", "source": [], "metadata": { "collapsed": false }, "outputs": [], "execution_count": null }, { "metadata": {}, "cell_type": "code", "source": "", "outputs": [], "execution_count": null } ], "metadata": { "kernelspec": { "display_name": "Kotlin", "language": "kotlin", "name": "kotlin" }, "language_info": { "name": "kotlin", "version": "1.9.0", "mimetype": "text/x-kotlin", "file_extension": ".kt", "pygments_lexer": "kotlin", "codemirror_mode": "text/x-kotlin", "nbconvert_exporter": "" }, "ktnbPluginMetadata": { "projectDependencies": [ "ClimateTraceKMP.composeApp.desktopMain" ], "projectLibraries": false } }, "nbformat": 4, "nbformat_minor": 0 }