问:
Pyflink error when I Try to read records from kafka cluster and then save them on S3 Location
I'm new working with pyflink.
I've developed a little solution with the purpose of consuming data from a kafka cluster with the topic and then write all those records on a S3 Location, but when I execute my code It always returns me an error.

Code

```<code>import os
from pyflink.datastream.stream_execution_environment import StreamExecutionEnvironment
from pyflink.table import TableEnvironment, EnvironmentSettings, environment_settings
from pyflink.table.table_environment import StreamTableEnvironment

KAFKA_SERVERS = 'MYBROKERS'
KAFKA_SINK_TOPIC = 'MYTOPIC'
OUTPUT_TABLE = 'sink_table'
INPUT_TABLE = 'source_table'

def log_processing():
    env_settings = EnvironmentSettings.in_streaming_mode()
    t_env = TableEnvironment.create(env_settings)
    t_env.get_config().get_configuration().set_string("pipeline.jars", "file:///././flink-python_2.12-1.15.0.jar;file:///././flink-sql-connector-kafka-1.15.1.jar;file:///././flink-connector-kafka_2.12-1.14.0.jar")

    ddl_source = f"""
            CREATE TABLE {INPUT_TABLE}(
                col1 INT,
                col2 TIMESTAMP,
                col3 TIMESTAMP,
                col4 STRING,
                col5 STRING,
                col6 STRING,
                col7 DECIMAL,
                col8 TIMESTAMP
            ) WITH (
              'connector' = 'kafka',
              'topic' = '{KAFKA_SINK_TOPIC}',
              'properties.bootstrap.servers' = '{KAFKA_SERVERS}',
              'scan.startup.mode' = 'latest-offset',
              'format' = 'json'
            )
            """

    ddl_sink = f"""
           CREATE TABLE {OUTPUT_TABLE} (
                col1 INT,
                col2 TIMESTAMP,
                col3 TIMESTAMP,
                col4 STRING,
                col5 STRING,
                col6 STRING,
                col7 DECIMAL,
                col8 TIMESTAMP
           ) WITH (
               'connector' = 'filesystem',
               'path' = 'MyS3BucketLocation',
               'format' = 'json'
           )
       """

    ddl_result = f"""SELECT * FROM {INPUT_TABLE} """

    t_env.execute_sql(ddl_source)
    t_env.execute_sql(ddl_sink)

    t_env.sql_query(ddl_result).execute_insert(OUTPUT_TABLE).wait()

if __name__ == '__main__':
    log_processing()
</code>```

The error:

```<code>2023-01-11 17:13:20,997 INFO  org.apache.hadoop.yarn.client.DefaultNoHARMFailoverProxyProvider [] - Connecting to ResourceManager at MYIP
2023-01-11 17:13:21,200 INFO  org.apache.hadoop.yarn.client.AHSProxy                       [] - Connecting to Application History server at MYIP
2023-01-11 17:13:21,210 INFO  org.apache.flink.yarn.YarnClusterDescriptor                  [] - No path for the flink jar passed. Using the location of class org.apache.flink.yarn.YarnClusterDescriptor to locate the jar
2023-01-11 17:13:21,340 INFO  org.apache.flink.yarn.YarnClusterDescriptor                  [] - Found Web Interface MYIP of application 'Application_ID'.
Job has been submitted with JobID ba7b16e865c893c05702995cc3a927f6
Traceback (most recent call last):
  File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/mnt/tmp/pyflink/00d82a6b-8889-4ed9-8941-88e6a3237d8c/80e86094-cfb6-410b-996e-39607a4ab667/flink.py", line 158, in <module>
    log_processing()
  File "/mnt/tmp/pyflink/00d82a6b-8889-4ed9-8941-88e6a3237d8c/80e86094-cfb6-410b-996e-39607a4ab667/flink.py", line 141, in log_processing
    t_env.sql_query(ddl_result).execute_insert(OUTPUT_TABLE).wait()
  File "/usr/lib/flink/opt/python/pyflink.zip/pyflink/table/table_result.py", line 76, in wait
  File "/usr/lib/flink/opt/python/py4j-0.10.9.3-src.zip/py4j/java_gateway.py", line 1322, in __call__
  File "/usr/lib/flink/opt/python/pyflink.zip/pyflink/util/exceptions.py", line 146, in deco
  File "/usr/lib/flink/opt/python/py4j-0.10.9.3-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o112.await.
: java.util.concurrent.ExecutionException: org.apache.flink.table.api.TableException: Failed to wait job finish
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
    at org.apache.flink.table.api.internal.TableResultImpl.awaitInternal(TableResultImpl.java:118)
    at org.apache.flink.table.api.internal.TableResultImpl.await(TableResultImpl.java:81)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.flink.api.python.shaded.py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at org.apache.flink.api.python.shaded.py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at org.apache.flink.api.python.shaded.py4j.Gateway.invoke(Gateway.java:282)
    at org.apache.flink.api.python.shaded.py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at org.apache.flink.api.python.shaded.py4j.commands.CallCommand.execute(CallCommand.java:79)
    at org.apache.flink.api.python.shaded.py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Thread.java:750)
Caused by: org.apache.flink.table.api.TableException: Failed to wait job finish
    at org.apache.flink.table.api.internal.InsertResultProvider.hasNext(InsertResultProvider.java:85)
    at org.apache.flink.table.api.internal.InsertResultProvider.isFirstRowReady(InsertResultProvider.java:71)
    at org.apache.flink.table.api.internal.TableResultImpl.lambda$awaitInternal$1(TableResultImpl.java:105)
    at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    ... 1 more
Caused by: java.util.concurrent.ExecutionException: org.apache.flink.client.program.ProgramInvocationException: Job failed (JobID: ba7b16e865c893c05702995cc3a927f6)
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
    at org.apache.flink.table.api.internal.InsertResultProvider.hasNext(InsertResultProvider.java:83)
    ... 6 more
Caused by: org.apache.flink.client.program.ProgramInvocationException: Job failed (JobID: ba7b16e865c893c05702995cc3a927f6)
    at org.apache.flink.client.deployment.ClusterClientJobClientAdapter.lambda$null$6(ClusterClientJobClientAdapter.java:130)
    at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616)
    at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
    at org.apache.flink.util.concurrent.FutureUtils.lambda$retryOperationWithDelay$9(FutureUtils.java:403)
    at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
    at org.apache.flink.client.program.rest.RestClusterClient.lambda$pollResourceAsync$26(RestClusterClient.java:708)
    at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
    at org.apache.flink.util.concurrent.FutureUtils.lambda$retryOperationWithDelay$9(FutureUtils.java:403)
    at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:575)
    at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:943)
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456)
    ... 3 more
Caused by: org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
    at org.apache.flink.runtime.jobmaster.JobResult.toJobExecutionResult(JobResult.java:144)
    at org.apache.flink.client.deployment.ClusterClientJobClientAdapter.lambda$null$6(ClusterClientJobClientAdapter.java:128)
    ... 24 more
Caused by: org.apache.flink.runtime.JobException: Recovery is suppressed by NoRestartBackoffTimeStrategy
    at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.handleFailure(ExecutionFailureHandler.java:138)
    at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.getFailureHandlingResult(ExecutionFailureHandler.java:82)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.handleTaskFailure(DefaultScheduler.java:301)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.maybeHandleTaskFailure(DefaultScheduler.java:291)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.updateTaskExecutionStateInternal(DefaultScheduler.java:282)
    at org.apache.flink.runtime.scheduler.SchedulerBase.updateTaskExecutionState(SchedulerBase.java:739)
    at org.apache.flink.runtime.scheduler.SchedulerNG.updateTaskExecutionState(SchedulerNG.java:78)
    at org.apache.flink.runtime.jobmaster.JobMaster.updateTaskExecutionState(JobMaster.java:443)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.lambda$handleRpcInvocation$1(AkkaRpcActor.java:304)
    at org.apache.flink.runtime.concurrent.akka.ClassLoadingUtils.runWithContextClassLoader(ClassLoadingUtils.java:83)
    at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRpcInvocation(AkkaRpcActor.java:302)
    at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRpcMessage(AkkaRpcActor.java:217)
    at org.apache.flink.runtime.rpc.akka.FencedAkkaRpcActor.handleRpcMessage(FencedAkkaRpcActor.java:78)
    at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleMessage(AkkaRpcActor.java:163)
    at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:24)
    at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:20)
    at scala.PartialFunction.applyOrElse(PartialFunction.scala:123)
    at scala.PartialFunction.applyOrElse$(PartialFunction.scala:122)
    at akka.japi.pf.UnitCaseStatement.applyOrElse(CaseStatements.scala:20)
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:171)
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:172)
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:172)
    at akka.actor.Actor.aroundReceive(Actor.scala:537)
    at akka.actor.Actor.aroundReceive$(Actor.scala:535)
    at akka.actor.AbstractActor.aroundReceive(AbstractActor.scala:220)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:580)
    at akka.actor.ActorCell.invoke(ActorCell.scala:548)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
    at akka.dispatch.Mailbox.run(Mailbox.scala:231)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)
Caused by: java.lang.UnsupportedOperationException: Recoverable writers on Hadoop are only supported for HDFS
    at org.apache.flink.runtime.fs.hdfs.HadoopRecoverableWriter.<init>(HadoopRecoverableWriter.java:60)
    at org.apache.flink.runtime.fs.hdfs.HadoopFileSystem.createRecoverableWriter(HadoopFileSystem.java:215)
    at org.apache.flink.core.fs.SafetyNetWrapperFileSystem.createRecoverableWriter(SafetyNetWrapperFileSystem.java:70)
    at org.apache.flink.streaming.api.functions.sink.filesystem.StreamingFileSink$RowFormatBuilder.createBucketWriter(StreamingFileSink.java:288)
    at org.apache.flink.streaming.api.functions.sink.filesystem.StreamingFileSink$RowFormatBuilder.createBuckets(StreamingFileSink.java:298)
    at org.apache.flink.connector.file.table.stream.AbstractStreamingWriter.initializeState(AbstractStreamingWriter.java:96)
    at org.apache.flink.connector.file.table.stream.StreamingFileWriter.initializeState(StreamingFileWriter.java:81)
    at org.apache.flink.streaming.api.operators.StreamOperatorStateHandler.initializeOperatorState(StreamOperatorStateHandler.java:122)
    at org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:286)
    at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.initializeStateAndOpenOperators(RegularOperatorChain.java:106)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:700)
    at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreInternal(StreamTask.java:676)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:643)
    at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:948)
    at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:917)
    at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:741)
    at org.apache.flink.runtime.taskmanager.Task.run(Task.java:563)
    at java.lang.Thread.run(Thread.java:750)
</code>```

Could someone help me with this?

I try to read a topic from my kafka cluster and save all those records in a S3 Location.

Body:
I'm new working with pyflink.
I've developed a little solution with the purpose of consuming data from a kafka cluster with the topic and then write all those records on a S3 Location, but when I execute my code It always returns me an error.

Code

import os
from pyflink.datastream.stream_execution_environment import StreamExecutionEnvironment
from pyflink.table import TableEnvironment, EnvironmentSettings, environment_settings
from pyflink.table.table_environment import StreamTableEnvironment

KAFKA_SERVERS = 'MYBROKERS'
KAFKA_SINK_TOPIC = 'MYTOPIC'
OUTPUT_TABLE = 'sink_table'
INPUT_TABLE = 'source_table'

def log_processing():
    env_settings = EnvironmentSettings.in_streaming_mode()
    t_env = TableEnvironment.create(env_settings)
    t_env.get_config().get_configuration().set_string("pipeline.jars", "file:///././flink-python_2.12-1.15.0.jar;file:///././flink-sql-connector-kafka-1.15.1.jar;file:///././flink-connector-kafka_2.12-1.14.0.jar")

    ddl_source = f"""
            CREATE TABLE {INPUT_TABLE}(
                col1 INT,
                col2 TIMESTAMP,
                col3 TIMESTAMP,
                col4 STRING,
                col5 STRING,
                col6 STRING,
                col7 DECIMAL,
                col8 TIMESTAMP
            ) WITH (
              'connector' = 'kafka',
              'topic' = '{KAFKA_SINK_TOPIC}',
              'properties.bootstrap.servers' = '{KAFKA_SERVERS}',
              'scan.startup.mode' = 'latest-offset',
              'format' = 'json'
            )
            """

    ddl_sink = f"""
           CREATE TABLE {OUTPUT_TABLE} (
                col1 INT,
                col2 TIMESTAMP,
                col3 TIMESTAMP,
                col4 STRING,
                col5 STRING,
                col6 STRING,
                col7 DECIMAL,
                col8 TIMESTAMP
           ) WITH (
               'connector' = 'filesystem',
               'path' = 'MyS3BucketLocation',
               'format' = 'json'
           )
       """

    ddl_result = f"""SELECT * FROM {INPUT_TABLE} """

    t_env.execute_sql(ddl_source)
    t_env.execute_sql(ddl_sink)

    t_env.sql_query(ddl_result).execute_insert(OUTPUT_TABLE).wait()

if __name__ == '__main__':
    log_processing()

The error:

2023-01-11 17:13:20,997 INFO  org.apache.hadoop.yarn.client.DefaultNoHARMFailoverProxyProvider [] - Connecting to ResourceManager at MYIP
2023-01-11 17:13:21,200 INFO  org.apache.hadoop.yarn.client.AHSProxy                       [] - Connecting to Application History server at MYIP
2023-01-11 17:13:21,210 INFO  org.apache.flink.yarn.YarnClusterDescriptor                  [] - No path for the flink jar passed. Using the location of class org.apache.flink.yarn.YarnClusterDescriptor to locate the jar
2023-01-11 17:13:21,340 INFO  org.apache.flink.yarn.YarnClusterDescriptor                  [] - Found Web Interface MYIP of application 'Application_ID'.
Job has been submitted with JobID ba7b16e865c893c05702995cc3a927f6
Traceback (most recent call last):
  File "/usr/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/mnt/tmp/pyflink/00d82a6b-8889-4ed9-8941-88e6a3237d8c/80e86094-cfb6-410b-996e-39607a4ab667/flink.py", line 158, in <module>
    log_processing()
  File "/mnt/tmp/pyflink/00d82a6b-8889-4ed9-8941-88e6a3237d8c/80e86094-cfb6-410b-996e-39607a4ab667/flink.py", line 141, in log_processing
    t_env.sql_query(ddl_result).execute_insert(OUTPUT_TABLE).wait()
  File "/usr/lib/flink/opt/python/pyflink.zip/pyflink/table/table_result.py", line 76, in wait
  File "/usr/lib/flink/opt/python/py4j-0.10.9.3-src.zip/py4j/java_gateway.py", line 1322, in __call__
  File "/usr/lib/flink/opt/python/pyflink.zip/pyflink/util/exceptions.py", line 146, in deco
  File "/usr/lib/flink/opt/python/py4j-0.10.9.3-src.zip/py4j/protocol.py", line 328, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o112.await.
: java.util.concurrent.ExecutionException: org.apache.flink.table.api.TableException: Failed to wait job finish
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
    at org.apache.flink.table.api.internal.TableResultImpl.awaitInternal(TableResultImpl.java:118)
    at org.apache.flink.table.api.internal.TableResultImpl.await(TableResultImpl.java:81)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.flink.api.python.shaded.py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at org.apache.flink.api.python.shaded.py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at org.apache.flink.api.python.shaded.py4j.Gateway.invoke(Gateway.java:282)
    at org.apache.flink.api.python.shaded.py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at org.apache.flink.api.python.shaded.py4j.commands.CallCommand.execute(CallCommand.java:79)
    at org.apache.flink.api.python.shaded.py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Thread.java:750)
Caused by: org.apache.flink.table.api.TableException: Failed to wait job finish
    at org.apache.flink.table.api.internal.InsertResultProvider.hasNext(InsertResultProvider.java:85)
    at org.apache.flink.table.api.internal.InsertResultProvider.isFirstRowReady(InsertResultProvider.java:71)
    at org.apache.flink.table.api.internal.TableResultImpl.lambda$awaitInternal$1(TableResultImpl.java:105)
    at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    ... 1 more
Caused by: java.util.concurrent.ExecutionException: org.apache.flink.client.program.ProgramInvocationException: Job failed (JobID: ba7b16e865c893c05702995cc3a927f6)
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
    at org.apache.flink.table.api.internal.InsertResultProvider.hasNext(InsertResultProvider.java:83)
    ... 6 more
Caused by: org.apache.flink.client.program.ProgramInvocationException: Job failed (JobID: ba7b16e865c893c05702995cc3a927f6)
    at org.apache.flink.client.deployment.ClusterClientJobClientAdapter.lambda$null$6(ClusterClientJobClientAdapter.java:130)
    at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616)
    at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
    at org.apache.flink.util.concurrent.FutureUtils.lambda$retryOperationWithDelay$9(FutureUtils.java:403)
    at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
    at org.apache.flink.client.program.rest.RestClusterClient.lambda$pollResourceAsync$26(RestClusterClient.java:708)
    at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
    at org.apache.flink.util.concurrent.FutureUtils.lambda$retryOperationWithDelay$9(FutureUtils.java:403)
    at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:575)
    at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:943)
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456)
    ... 3 more
Caused by: org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
    at org.apache.flink.runtime.jobmaster.JobResult.toJobExecutionResult(JobResult.java:144)
    at org.apache.flink.client.deployment.ClusterClientJobClientAdapter.lambda$null$6(ClusterClientJobClientAdapter.java:128)
    ... 24 more
Caused by: org.apache.flink.runtime.JobException: Recovery is suppressed by NoRestartBackoffTimeStrategy
    at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.handleFailure(ExecutionFailureHandler.java:138)
    at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.getFailureHandlingResult(ExecutionFailureHandler.java:82)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.handleTaskFailure(DefaultScheduler.java:301)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.maybeHandleTaskFailure(DefaultScheduler.java:291)
    at org.apache.flink.runtime.scheduler.DefaultScheduler.updateTaskExecutionStateInternal(DefaultScheduler.java:282)
    at org.apache.flink.runtime.scheduler.SchedulerBase.updateTaskExecutionState(SchedulerBase.java:739)
    at org.apache.flink.runtime.scheduler.SchedulerNG.updateTaskExecutionState(SchedulerNG.java:78)
    at org.apache.flink.runtime.jobmaster.JobMaster.updateTaskExecutionState(JobMaster.java:443)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.lambda$handleRpcInvocation$1(AkkaRpcActor.java:304)
    at org.apache.flink.runtime.concurrent.akka.ClassLoadingUtils.runWithContextClassLoader(ClassLoadingUtils.java:83)
    at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRpcInvocation(AkkaRpcActor.java:302)
    at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRpcMessage(AkkaRpcActor.java:217)
    at org.apache.flink.runtime.rpc.akka.FencedAkkaRpcActor.handleRpcMessage(FencedAkkaRpcActor.java:78)
    at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleMessage(AkkaRpcActor.java:163)
    at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:24)
    at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:20)
    at scala.PartialFunction.applyOrElse(PartialFunction.scala:123)
    at scala.PartialFunction.applyOrElse$(PartialFunction.scala:122)
    at akka.japi.pf.UnitCaseStatement.applyOrElse(CaseStatements.scala:20)
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:171)
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:172)
    at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:172)
    at akka.actor.Actor.aroundReceive(Actor.scala:537)
    at akka.actor.Actor.aroundReceive$(Actor.scala:535)
    at akka.actor.AbstractActor.aroundReceive(AbstractActor.scala:220)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:580)
    at akka.actor.ActorCell.invoke(ActorCell.scala:548)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
    at akka.dispatch.Mailbox.run(Mailbox.scala:231)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)
Caused by: java.lang.UnsupportedOperationException: Recoverable writers on Hadoop are only supported for HDFS
    at org.apache.flink.runtime.fs.hdfs.HadoopRecoverableWriter.<init>(HadoopRecoverableWriter.java:60)
    at org.apache.flink.runtime.fs.hdfs.HadoopFileSystem.createRecoverableWriter(HadoopFileSystem.java:215)
    at org.apache.flink.core.fs.SafetyNetWrapperFileSystem.createRecoverableWriter(SafetyNetWrapperFileSystem.java:70)
    at org.apache.flink.streaming.api.functions.sink.filesystem.StreamingFileSink$RowFormatBuilder.createBucketWriter(StreamingFileSink.java:288)
    at org.apache.flink.streaming.api.functions.sink.filesystem.StreamingFileSink$RowFormatBuilder.createBuckets(StreamingFileSink.java:298)
    at org.apache.flink.connector.file.table.stream.AbstractStreamingWriter.initializeState(AbstractStreamingWriter.java:96)
    at org.apache.flink.connector.file.table.stream.StreamingFileWriter.initializeState(StreamingFileWriter.java:81)
    at org.apache.flink.streaming.api.operators.StreamOperatorStateHandler.initializeOperatorState(StreamOperatorStateHandler.java:122)
    at org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:286)
    at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.initializeStateAndOpenOperators(RegularOperatorChain.java:106)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:700)
    at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreInternal(StreamTask.java:676)
    at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:643)
    at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:948)
    at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:917)
    at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:741)
    at org.apache.flink.runtime.taskmanager.Task.run(Task.java:563)
    at java.lang.Thread.run(Thread.java:750)

Could someone help me with this?

I try to read a topic from my kafka cluster and save all those records in a S3 Location.


来源: stackexchange

问:
How to Configure WEBrick to Display XHTML and its CSS
I cannot make WEBrick display an XHTML page and its associated CSS - the exact same file with an 'html' extension works perfectly, but it fails with an 'xhtml' extension. How can I configure WEBrick to display XHTML and its CSS?.

I've tried this:

```<code>require 'webrick'

def start_webrick(config = {})
  config.update(:Port => 5000, :DocumentRoot => '\path\to\my\file\')
  server = WEBrick::HTTPServer.new(config)
  yield server if block_given?
  ['INT', 'TERM'].each {|signal|
    trap(signal) {server.shutdown}
  }
  server.start
end

start_webrick
</code>```

I've also tried this:

```<code>require 'webrick'

# WEBrick::HTTPUtils::DefaultMimeTypes['xhtml'] = 'application/xhtml+xml'

# var = File.read('/PD/Dev/Data/Web/Public/index.xhtml')
server = WEBrick::HTTPServer.new(:Port => 5000, :DocumentRoot => '\path\to\my\file\')
server.mount_proc('/') {|request, response| response.body}
trap("INT") {server.shutdown}
server.start
</code>```

I'm using Ruby 2.7, and I've also changed the default Mime type as in the above comment. If I uncomment the 'File.read...' above and change the 'response.body' to 'response = var', I get the file displayed but not as expected.

I'm very new to this and would appreciate any help. Thank you.

ContentLicense: CC BY-SA 4.0

Body:
I cannot make WEBrick display an XHTML page and its associated CSS - the exact same file with an 'html' extension works perfectly, but it fails with an 'xhtml' extension. How can I configure WEBrick to display XHTML and its CSS?.

I've tried this:

require 'webrick'

def start_webrick(config = {})
  config.update(:Port => 5000, :DocumentRoot => '\path\to\my\file\')
  server = WEBrick::HTTPServer.new(config)
  yield server if block_given?
  ['INT', 'TERM'].each {|signal|
    trap(signal) {server.shutdown}
  }
  server.start
end

start_webrick

I've also tried this:

require 'webrick'

# WEBrick::HTTPUtils::DefaultMimeTypes['xhtml'] = 'application/xhtml+xml'

# var = File.read('/PD/Dev/Data/Web/Public/index.xhtml')
server = WEBrick::HTTPServer.new(:Port => 5000, :DocumentRoot => '\path\to\my\file\')
server.mount_proc('/') {|request, response| response.body}
trap("INT") {server.shutdown}
server.start

I'm using Ruby 2.7, and I've also changed the default Mime type as in the above comment. If I uncomment the 'File.read...' above and change the 'response.body' to 'response = var', I get the file displayed but not as expected.

I'm very new to this and would appreciate any help. Thank you.


问:
How to create environment variable that executes Python script?
I have python script that I want to run from command prompt. I don't want to write python myProgram.py every time. I want to run it just by running command mp on command prompt. I also want to be able to give command line arguments when I execute the environment variable, like mp param1 when without environment variable it would be python myProgram.py param1. How to do all this?

I tried to create local environment variable with value C:\Users\Username\myScripts\myProgram.py and name mp, but when i try to run it, it doesn't work. Says 'mp' is not recognized as an internal or external command, operable program or batch file. I have rebooted cmd.exe. Do I have to create a .exe file? I have Windows 10 and Python 3.10.4.


问:
How to get rid of "Keras weights file saving" message
Im currently working with Keras and creating Convolutional NN. I have been always creating an architecture using Sequential() and now I tried to do it in another way another way of creating an architecture. And now, whenever I execute my code it always outputs annoying message annoying message and I dont know how to get rid of this

There is no info about such problem on the internet, but I have tried to do this

```<code>import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
</code>```

but it doesnt work

UPDATE:
I have figured out that this message appears after I do this:

```<code>model = Model(input_, output)
</code>```

And now I dont know why this message appears

Body:
Im currently working with Keras and creating Convolutional NN. I have been always creating an architecture using Sequential() and now I tried to do it in another way another way of creating an architecture. And now, whenever I execute my code it always outputs annoying message annoying message and I dont know how to get rid of this

There is no info about such problem on the internet, but I have tried to do this

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

but it doesnt work

UPDATE:
I have figured out that this message appears after I do this:

model = Model(input_, output)

And now I dont know why this message appears


问:
How to create a function in UE5 that can only be called from widget blueprint
How to create a function in UE5 that can only be called from widget blueprint
I tried deriving class from UUserWidget But that doesnt seem to work as i can still call function from otherbl;ueprints


问:
Find all the verbs after "that" and highlight them
Basically I am trying to change the past tense into present tense in a word document by finding verbs after the word "that" and replace them with present participle(-ing). The following code working correctly with regular verbs but cannot handle other type of verbs.

The code uses a wildcard search to find instances of "that" followed by a verb in the past tense, and highlights those instances. if I use

```<code>.TEXT = "that [a-z]@ed>"
</code>```

it only matches regular verbs in the past tense (verbs that end in "-ed"), so it won't match irregular verbs, which can have different forms in the past tense.

To handle irregular verbs, I need to add additional wildcard search patterns to account for the different ways that irregular verbs can be spelled in the past tense. For example, a search pattern for "-t" (for verbs like "left" and "slept"), "-d" (for verbs like "bend" and "send"), "-en" (for verbs like "broken" and "eaten"), etc.

Here is an example of modified code to handle both regular and irregular verbs, This code now search for different past-tense suffixes as well like "-t", "-d" and "-en" and not just "-ed" and this way it can handle all type of verbs.

so to accommodate all the verbs I uses OR with find.

```<code>    Sub Hi_That_Word_AI()
    Dim AD As Range
    Dim CR As Range
    Dim t, x
    Dim pText$
    Application.ScreenUpdating = False
    t = Timer
    x = 0
    Set AD = ActiveDocument.Range
    With AD.Find
        .MatchWildcards = True
        .TEXT = "that [a-z]@ed|that [a-z]@t|that [a-z]@d|that [a-z]@en>"
        Do While .Execute
            If Not AD.Sentences(1).TEXT Like "*[.?]”*" Then
                .Parent.Select
                AD.HighlightColorIndex = wdYellow
                x = x + 1
            End If
            .Parent.Collapse wdCollapseEnd
        Loop
    End With
    MsgBox Round(Timer - t, 2) & " Seconds. There are " & x & " instances HighLighted in " & AD.Parent.Name, vbOKOnly + vbInformation
    Application.ScreenUpdating = True
End Sub
</code>```

Above code does not return any instances due to use of OR with Find method. what is the right way of doing that kind of searched what are the alternate methods?

Body:
Basically I am trying to change the past tense into present tense in a word document by finding verbs after the word "that" and replace them with present participle(-ing). The following code working correctly with regular verbs but cannot handle other type of verbs.

The code uses a wildcard search to find instances of "that" followed by a verb in the past tense, and highlights those instances. if I use

.TEXT = "that [a-z]@ed>"

it only matches regular verbs in the past tense (verbs that end in "-ed"), so it won't match irregular verbs, which can have different forms in the past tense.

To handle irregular verbs, I need to add additional wildcard search patterns to account for the different ways that irregular verbs can be spelled in the past tense. For example, a search pattern for "-t" (for verbs like "left" and "slept"), "-d" (for verbs like "bend" and "send"), "-en" (for verbs like "broken" and "eaten"), etc.

Here is an example of modified code to handle both regular and irregular verbs, This code now search for different past-tense suffixes as well like "-t", "-d" and "-en" and not just "-ed" and this way it can handle all type of verbs.

so to accommodate all the verbs I uses OR with find.

    Sub Hi_That_Word_AI()
    Dim AD As Range
    Dim CR As Range
    Dim t, x
    Dim pText$
    Application.ScreenUpdating = False
    t = Timer
    x = 0
    Set AD = ActiveDocument.Range
    With AD.Find
        .MatchWildcards = True
        .TEXT = "that [a-z]@ed|that [a-z]@t|that [a-z]@d|that [a-z]@en>"
        Do While .Execute
            If Not AD.Sentences(1).TEXT Like "*[.?]”*" Then
                .Parent.Select
                AD.HighlightColorIndex = wdYellow
                x = x + 1
            End If
            .Parent.Collapse wdCollapseEnd
        Loop
    End With
    MsgBox Round(Timer - t, 2) & " Seconds. There are " & x & " instances HighLighted in " & AD.Parent.Name, vbOKOnly + vbInformation
    Application.ScreenUpdating = True
End Sub

Above code does not return any instances due to use of OR with Find method. what is the right way of doing that kind of searched what are the alternate methods?


问:
Trying to understand and debug ETCDv2 Memory usage
I’m trying to understand ETCD’s memory and disk usage within a deployed system using the ETCDv2 API.  The system has a file being saved on a regular basis, each time under a new key, and we’re concerned that long-term there’s no clean-up of state leading to both memory and disk usage growing unbounded on each VM in the etcd cluster.  We’ve also emulated this, using a large file (several MB) being saved every few minutes.

From the etcd docs, I expected the following:

Each insertion would save the file to disk, causing disk usage to grow unbounded.

This matches what I am seeing.

In memory, etcd would save a key-value pair where the value is a lookup address for the file on disk (taking up a very small amount of memory) and a cached version of the file (taking a large amount of memory).

I would then expect that rebooting an etcd pod after several file writes would cause the cache to be (mostly) cleared, meaning a consistently up pod would have memory growing unbounded but if the pod rebooted, the cache would be cleared of all but the active entry (and any specifically requested by e.g. attempted rollbacks) and the memory usage would (mostly) reset with each reboot.

However, in practice we see a very small memory drop with a reboot which is almost immediately returned after the pod recovers (as though all the cache is restored from the peers).

Is my understanding correct? And if so:

Why does the memory usage reset fully after an etcd pod reboot?  Does the etcd cache get synced with its cluster, as well as the main key-value table and file storage?

Is there a recommended way to keep etcd’s memory and disk usage within bounded limits?

Additional notes:

I’ve tried reducing the snapshot_count configuration setting - this doesn’t seem to have had any impact (unless I’ve reduced it too far - I cut it right down to 5 from the default of 100,000).

I’ve attempted changing our file saving to overwrite a single file with a new version each time, instead of storing a new file.  This doesn’t appear to have had any impact (although this may be due to issues in my prototype; I’m still investigating).

We can’t migrate existing deployments to etcd v3 file-systems, so are specifically looking at etcd v2 solutions.  I think this rules out compact and defrag steps, which seem to be a core part of the answer to this problem in v3.

Any help or insight very gratefully appreciated.

Thanks!


问:
Kotlin's StateFlow.asLiveData() isn't updating observers when it changes quickly
I have a ViewModel that uses StateFlow.asLiveData() to expose a Repository class's StateFlow items and I'm trying to write a test for the ViewModel. My tests are configured with a Mock of an Observer<LoadingStatus> on the ViewModel's exposed LiveData.

The code I'm testing calls this method to update its loading status:

```<code>suspend fun MutableStateFlow<LoadingStatus>.performWithStatusUpdates(operation: suspend () -> Unit) {
  this.value = LoadingStatus.Loading()
  try {
    operation.invoke()
    this.value = LoadingStatus.Success()
  } catch (e: Throwable) {
    this.value = LoadingStatus.Error(e)
  }
}
</code>```

My tests look something like this:

```<code>fun testSomething() = runTest {
  viewModel.doSomething()
  advanceUntilIdle()
  argumentCaptor<LoadingStatus>().apply {
    verify(loadingStatusObserver, atLeast(2)).onChanged(capture())
    assertTrue(allValues.any { it is LoadingStatus.Loading })
    assertTrue(allValues.any { it is LoadingStatus.Success })
  }
}
</code>```

The ViewModel contains code like this:

```<code>val loadingStatus = repository.loadingStatusObservable.asLiveData(
  viewModelScope.coroutineContext + ioDispatcher
) // when running tests, ioDispatcher is a StandardTestDispatcher passed into the viewModel

fun doSomething() {
  viewModelScope.launch(ioDispatcher) {
    repository.doSomething()
  }
}
</code>```

And the repository does something like this:

```<code>val loadingStatusObservable = MutableStateFlow<LoadingStatus>(LoadingStatus.Idle())

suspend fun doSomething() {
  loadingStatusObservable.performWithStatusUpdates {
    apiService.doSomethingElse()
  }
}
</code>```

The repository has similar tests that call doSomething() and verify that the status goes to loading and then success, and they pass, but the view model ones fail to pick up the Loading status. If I comment out the line in performWithStatusUpdates that sets the status to success after the operation, the tests do pick up the Loading status, so I'm convinced it's something to do with timing. I have run this code with print statements and debuggers and verified that the status is updating correctly, but the change isn't getting picked up by the observers.

How can I make an observer on a StateFlow.asLiveData() detect all changes, even when they're quickly followed by another, different change?

Body:
I have a ViewModel that uses StateFlow.asLiveData() to expose a Repository class's StateFlow items and I'm trying to write a test for the ViewModel. My tests are configured with a Mock of an Observer<LoadingStatus> on the ViewModel's exposed LiveData.

The code I'm testing calls this method to update its loading status:

suspend fun MutableStateFlow<LoadingStatus>.performWithStatusUpdates(operation: suspend () -> Unit) {
  this.value = LoadingStatus.Loading()
  try {
    operation.invoke()
    this.value = LoadingStatus.Success()
  } catch (e: Throwable) {
    this.value = LoadingStatus.Error(e)
  }
}

My tests look something like this:

fun testSomething() = runTest {
  viewModel.doSomething()
  advanceUntilIdle()
  argumentCaptor<LoadingStatus>().apply {
    verify(loadingStatusObserver, atLeast(2)).onChanged(capture())
    assertTrue(allValues.any { it is LoadingStatus.Loading })
    assertTrue(allValues.any { it is LoadingStatus.Success })
  }
}

The ViewModel contains code like this:

val loadingStatus = repository.loadingStatusObservable.asLiveData(
  viewModelScope.coroutineContext + ioDispatcher
) // when running tests, ioDispatcher is a StandardTestDispatcher passed into the viewModel

fun doSomething() {
  viewModelScope.launch(ioDispatcher) {
    repository.doSomething()
  }
}

And the repository does something like this:

val loadingStatusObservable = MutableStateFlow<LoadingStatus>(LoadingStatus.Idle())

suspend fun doSomething() {
  loadingStatusObservable.performWithStatusUpdates {
    apiService.doSomethingElse()
  }
}

The repository has similar tests that call doSomething() and verify that the status goes to loading and then success, and they pass, but the view model ones fail to pick up the Loading status. If I comment out the line in performWithStatusUpdates that sets the status to success after the operation, the tests do pick up the Loading status, so I'm convinced it's something to do with timing. I have run this code with print statements and debuggers and verified that the status is updating correctly, but the change isn't getting picked up by the observers.

How can I make an observer on a StateFlow.asLiveData() detect all changes, even when they're quickly followed by another, different change?


问:
react-native-print - customize default selection of Papersize & orientation
While using react native library - react-native-print the default selection of papersize and orientation is not changing if user would like to have some document in landscape mode & paper size. Is there any options to change default selections.


问:
Doing MCA with prince package but inertia values seem incorrect
```<code>mca_cols = df.select_dtypes(['category']).columns
# instantiate MCA class
mca = prince.MCA(n_components = 3)
# get principal components
mca = mca.fit(df[mca_cols])
mca.explained_inertia_
mca.total_inertia_
</code>```

I am attempting to do MCA with intention to feed the components into a clustering algorithm. However, when I look at the total_inertia_ I get a value of appx 70 and the explained inertia values for the 3 components are as follows:

[0.004080415064925553, 0.0035643891792985346, 0.003260362150059927]

The total inertia seems higher than what I've seen in examples for this library and the explained inertia values seem much lower. Can someone please explain what the reason might be and how I should interpret the total inertia value?

I was expecting total inertia to be around 1 and expected inertia values to add up to 1.

And another question, how do I find the ideal number of components for MCA?

Body:
mca_cols = df.select_dtypes(['category']).columns
# instantiate MCA class
mca = prince.MCA(n_components = 3)
# get principal components
mca = mca.fit(df[mca_cols])
mca.explained_inertia_
mca.total_inertia_

I am attempting to do MCA with intention to feed the components into a clustering algorithm. However, when I look at the total_inertia_ I get a value of appx 70 and the explained inertia values for the 3 components are as follows:

[0.004080415064925553, 0.0035643891792985346, 0.003260362150059927]

The total inertia seems higher than what I've seen in examples for this library and the explained inertia values seem much lower. Can someone please explain what the reason might be and how I should interpret the total inertia value?

I was expecting total inertia to be around 1 and expected inertia values to add up to 1.

And another question, how do I find the ideal number of components for MCA?


问:
Lookup join or enrichment join against a changelog stream in Apache Flink Table API
I'm interested in doing a "lookup join" or "enrichment join" against a "changelog stream" read by "upsert-kafka". I am wondering if this is possible against the table API. I found https://github.com/fhueske/flink-sql-demo#enrichment-join-against-temporal-table however when I read up on https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/concepts/temporal_table_function/ it says that it does not work on changelog inputs.

Then it appears that I specifically can't perform the "enrichment join".

Is there a technique I am missing?

Is there a reason why we should not perform the join that I am missing?


问:
(React-native) undefined is not a function
In the process of receiving "argument value parameter" and adding data, "undefined is not a function error occurred in the insert (text) part. I tried to solve this, but I couldn't solve it. What is the cause?

app.js

```<code>import React, {useState} from 'react';
import {
  StyleSheet,
  StatusBar,
  KeyboardAvoidingView,
  Platform,
} from 'react-native';

import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
import Title from './components/title';
import AddText from './components/addText';

function App() {
  const [todos, setTodo] = useState([
  ]);

  const onInsert = text => {

    const todo = {
      id: 10,
      text,
      done: false,
    };
    setTodo(todos.concat(todo));
  };

  return (
    <SafeAreaProvider>
      <SafeAreaView style={styles.backView}>
        <KeyboardAvoidingView style={styles.avoid}>
          <StatusBar backgroundColor="#8b4513" />
          <Title />
          <AddText todo={onInsert} />
        </KeyboardAvoidingView>
      </SafeAreaView>
    </SafeAreaProvider>
  );
}

const styles = StyleSheet.create({
  backView: {
    flex: 1,
    backgroundColor: '#8b4513',
  },

  avoid: {
    flex: 1,
  },
});

export default App;
</code>```

addText.js

```<code>import React, {useState} from 'react';
import {
  TextInput,
  StyleSheet,
  Dimensions,
  Button,
  View,
  Platform,
  TouchableOpacity,
  TouchableHighlight,
  Keyboard,
  Image,
  Text,
} from 'react-native';

function AddText({onInsert}) {
  const [text, setText] = useState('');

  function onPress() {
    onInsert(text);
    setText('');
    Keyboard.dismiss();
  }

  return (
    <View style={styles.view}>
      <TextInput
        placeholder="할 일을 입력하세요"
        style={styles.input}
        maxLength={10}
        value={text}
        onChangeText={setText}
        returnKeyType="done"
      />

      <TouchableOpacity onPress={onPress}>
        <Image source={require('../components/plus.png')} style={styles.img} />
      </TouchableOpacity>
      <Text>null</Text>
    </View>
  );
}
const styles = StyleSheet.create({
  view: {
    height: 50,
    justifyContent: 'center',
    flexDirection: 'row',
    paddingHorizontal: 16,
    backgroundColor: '#deb887',
    borderRadius: 20,
    margin: 25,
  },
  input: {
    justifyContent: 'center',
    alignItems: 'center',
    fontSize: 20,
    borderRadius: 15,
    borderColor: '#800000',
    color: '#000000',
    paddingVertical: 8,
    flex: 1,
  },

  img_view: {
    width: 30,
    height: 30,
  },

  img: {
    width: 40,
    height: 40,
    marginLeft: 30,
    marginTop: 5,
  },
});

export default AddText;
</code>```

I created a new project and ran it, but it was still the same. I searched in another way, but couldn't come up with a suitable way. Is there any way to solve it?

Body:
In the process of receiving "argument value parameter" and adding data, "undefined is not a function error occurred in the insert (text) part. I tried to solve this, but I couldn't solve it. What is the cause?

app.js

import React, {useState} from 'react';
import {
  StyleSheet,
  StatusBar,
  KeyboardAvoidingView,
  Platform,
} from 'react-native';

import {SafeAreaView, SafeAreaProvider} from 'react-native-safe-area-context';
import Title from './components/title';
import AddText from './components/addText';

function App() {
  const [todos, setTodo] = useState([
  ]);

  const onInsert = text => {

    const todo = {
      id: 10,
      text,
      done: false,
    };
    setTodo(todos.concat(todo));
  };

  return (
    <SafeAreaProvider>
      <SafeAreaView style={styles.backView}>
        <KeyboardAvoidingView style={styles.avoid}>
          <StatusBar backgroundColor="#8b4513" />
          <Title />
          <AddText todo={onInsert} />
        </KeyboardAvoidingView>
      </SafeAreaView>
    </SafeAreaProvider>
  );
}

const styles = StyleSheet.create({
  backView: {
    flex: 1,
    backgroundColor: '#8b4513',
  },

  avoid: {
    flex: 1,
  },
});

export default App;

addText.js

import React, {useState} from 'react';
import {
  TextInput,
  StyleSheet,
  Dimensions,
  Button,
  View,
  Platform,
  TouchableOpacity,
  TouchableHighlight,
  Keyboard,
  Image,
  Text,
} from 'react-native';

function AddText({onInsert}) {
  const [text, setText] = useState('');

  function onPress() {
    onInsert(text);
    setText('');
    Keyboard.dismiss();
  }

  return (
    <View style={styles.view}>
      <TextInput
        placeholder="할 일을 입력하세요"
        style={styles.input}
        maxLength={10}
        value={text}
        onChangeText={setText}
        returnKeyType="done"
      />

      <TouchableOpacity onPress={onPress}>
        <Image source={require('../components/plus.png')} style={styles.img} />
      </TouchableOpacity>
      <Text>null</Text>
    </View>
  );
}
const styles = StyleSheet.create({
  view: {
    height: 50,
    justifyContent: 'center',
    flexDirection: 'row',
    paddingHorizontal: 16,
    backgroundColor: '#deb887',
    borderRadius: 20,
    margin: 25,
  },
  input: {
    justifyContent: 'center',
    alignItems: 'center',
    fontSize: 20,
    borderRadius: 15,
    borderColor: '#800000',
    color: '#000000',
    paddingVertical: 8,
    flex: 1,
  },

  img_view: {
    width: 30,
    height: 30,
  },

  img: {
    width: 40,
    height: 40,
    marginLeft: 30,
    marginTop: 5,
  },
});

export default AddText;

I created a new project and ran it, but it was still the same. I searched in another way, but couldn't come up with a suitable way. Is there any way to solve it?


问:
Assign new values to table without considering where its inserted in postgres
I have table
students_to_assign

Students

12

15

18

and table for chairs_arrangement

Chair
Assigned_Student

5a
12

6b
24

10z
null

10v
null

I want to assign chairs to the students:

Chair can be assigned only if Assigned_Student is null.

If the student was already assigned a chair he will not assign it to a new chair.

If there are more students than chairs we will assign chairs until the table is full

the student list is the size of 1 million records

can you help with a query that can run in parallel with other queries or to do it in 1 batch

I was trying to create students_to_assign with column chairs and when creating add to the table students_to_assign but that says that I need to lock the table and the process takes a very long time and resources (about 30 sec).

I would like, if possible, a solution that inserts directly into chairs_arrangement with no consideration what chair is assigned as long as it answer the rules i said above (not assigned before, no duplicate students)


问:
How to use where clause to compare 2 columns in mongoDB?
How many products have discount % greater than 30%?
On pymongo (MongoDB driver library for Python),
I have

original_price [store as float] and

sale_price [store as float]

in mongoDB, I am using:

# question 10:-How many products have discount % greater than 30%?
count=0
for x in db.leclerc_fr.find():
    if((x['sale_price']/x['original_price']<.7)):
        print(x)
        count+=1
print(count)
```


问:
How can I fix a longitude/latitude to (x, y) convertor to not give me impossible coordinates for only a specific case
For a school project, I am creating a visual map that maps the location of where a random dinosaur in North America was found. The locations that I get from a dataset are in latitude, longitude so I have a convertor function to convert it into (x, y) coordinates on a Mercator map where 0 >= x >= 320 and 0 >= y >= 250 (320, 250 is the aspect ratio of the map image and the top left corner is (0, 0)). I got the formulas from here: https://medium.com/@suverov.dmitriy/how-to-convert-latitude-and-longitude-coordinates-into-pixel-offsets-8461093cb9f5. The convertor works for all coordinates in my dataset except for one. That coordinate is in Nunavut, Canada and the coordinates are 80.91 N, -89.25 in latitude, longitude and my convertor gives me 60.66, -43.95 which is completely off the screen. All of the other coordinates are on the west coast and are the convertor does a very good job which getting the right place. Does anyone know what is happening.

This is my code (it is javascript):

```<code>// function to convert input in degrees to output in radians
function degreesToRadians(degrees){
  return degrees * (Math.PI/180);
}

// function to find (x, y) cartesian coords for a planar map from spherical (latitude, longitude)
function findCartesians(latitude, longitude, mapWidth, mapHeight, xDisp, yDisp) {
  var radius = mapWidth / (2 * Math.PI); // radius of spherical projection of map
  var FE = 180; // false easting

  var lonRad = degreesToRadians(longitude + FE); // longitude in radians
  var x = lonRad * radius; // x cartesian coord for planar map

  var latRad = degreesToRadians(latitude); // latitude in radians
  var verticalOffsetFromEquator =
    radius * Math.log(Math.tan(Math.PI / 4 + latRad / 2)); //vertical offset from equator
  var y = mapHeight / 2 - verticalOffsetFromEquator; // y cartesian coord for planar map

  var coords = [x, y]; // list with x, y coords
  return coords; // return the coords to calling object
}
</code>```

This is how it looks like with Nunavut:
Nunavut image

This is how it looks like with a normal coord:
Normal coord image

I looked over my code multiple times but I couldn't find anything that could fix my problem. I didn't try any other map types.

Body:
For a school project, I am creating a visual map that maps the location of where a random dinosaur in North America was found. The locations that I get from a dataset are in latitude, longitude so I have a convertor function to convert it into (x, y) coordinates on a Mercator map where 0 >= x >= 320 and 0 >= y >= 250 (320, 250 is the aspect ratio of the map image and the top left corner is (0, 0)). I got the formulas from here: https://medium.com/@suverov.dmitriy/how-to-convert-latitude-and-longitude-coordinates-into-pixel-offsets-8461093cb9f5. The convertor works for all coordinates in my dataset except for one. That coordinate is in Nunavut, Canada and the coordinates are 80.91 N, -89.25 in latitude, longitude and my convertor gives me 60.66, -43.95 which is completely off the screen. All of the other coordinates are on the west coast and are the convertor does a very good job which getting the right place. Does anyone know what is happening.

This is my code (it is javascript):

// function to convert input in degrees to output in radians
function degreesToRadians(degrees){
  return degrees * (Math.PI/180);
}

// function to find (x, y) cartesian coords for a planar map from spherical (latitude, longitude)
function findCartesians(latitude, longitude, mapWidth, mapHeight, xDisp, yDisp) {
  var radius = mapWidth / (2 * Math.PI); // radius of spherical projection of map
  var FE = 180; // false easting

  var lonRad = degreesToRadians(longitude + FE); // longitude in radians
  var x = lonRad * radius; // x cartesian coord for planar map

  var latRad = degreesToRadians(latitude); // latitude in radians
  var verticalOffsetFromEquator =
    radius * Math.log(Math.tan(Math.PI / 4 + latRad / 2)); //vertical offset from equator
  var y = mapHeight / 2 - verticalOffsetFromEquator; // y cartesian coord for planar map

  var coords = [x, y]; // list with x, y coords
  return coords; // return the coords to calling object
}

This is how it looks like with Nunavut:
Nunavut image

This is how it looks like with a normal coord:
Normal coord image

I looked over my code multiple times but I couldn't find anything that could fix my problem. I didn't try any other map types.


问:
Unconditionally disabling a function with SFINAE
Is the following code valid? If it depends on the C++ version, I would also be interested in the corresponding differences (starting from C++14).

#include <type_traits>

struct S {
    template< typename ... Args >
    void foo() const {
        static_assert( sizeof...(Args) == 0, "" );
    }

    template< typename ... Args, bool B = false, typename std::enable_if::type = false >
    void foo() {
        static_assert( sizeof...(Args) == 0, "" );
    }
};

int main() {
    S s{};
    s.foo();
}
```

I am asking because of the following things in the cpp standard (I do not know whether this is the actual version):

The validity of a template may be checked prior to any instantiation.

The program is ill-formed, no diagnostic required, if
no valid specialization can be generated for a template or a substatement of a constexpr if statement within a template and the template is not instantiated, ...

My goal:  I am trying to remove the non-const version from overload resolution, when some macros are defined during compilation.

Body:
Is the following code valid? If it depends on the C++ version, I would also be interested in the corresponding differences (starting from C++14).

#include <type_traits>

struct S {
    template< typename ... Args >
    void foo() const {
        static_assert( sizeof...(Args) == 0, "" );
    }

    template< typename ... Args, bool B = false, typename std::enable_if::type = false >
    void foo() {
        static_assert( sizeof...(Args) == 0, "" );
    }
};

int main() {
    S s{};
    s.foo();
}

I am asking because of the following things in the cpp standard (I do not know whether this is the actual version):

The validity of a template may be checked prior to any instantiation.

The program is ill-formed, no diagnostic required, if
no valid specialization can be generated for a template or a substatement of a constexpr if statement within a template and the template is not instantiated, ...

My goal:  I am trying to remove the non-const version from overload resolution, when some macros are defined during compilation.


问:
Firebase customized reports with customized cards
Firebase shows default dashboard of analytics so ask is can we replace default firebase dashboard with customised report while can be created from below option:-

Another ask is these custom report says published but how to share with end user from firebase?


问:
Can't attach solidity-lsp for .sol files in neovim
Firtsble solidity-ls installed by mason via neovim command

```<code>:LspInstall solidity-ls
</code>```

wasn't executable from terminal, altough it was shown as an executable one when typing :LspInfo in .sol file. After I installed it manually via npm

```<code>npm i solidity-ls -g
</code>```

This is configuration for solidity-ls

```<code>require'lspconfig'.solidity.setup({
    on_attach = on_attach,
})
</code>```

With this empty configuration however root directory is not found, also solidity-ls is not attached to the file which I guess is just a consequence.

After adding root_dir manually in a following way and checking the file via luafile %

```<code>require'lspconfig'.solidity.setup({
    on_attach = on_attach,
    root_dir = function(fname)
        return vim.fn.getcwd()
    end,
})
</code>```

I get this error

```<code>LSP[solidity]: Error SERVER_REQUEST_HANDLER_ERROR: "/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:86: bad argument #1 to 'ipairs' (table expected, got nil)"
</code>```

Although :LspInfo shows root_dir is set up solidity-ls still is not attached

LspInfo from .sol file after

Any suggestion how to solve this?

Ubuntu 20.04.3 LTS
NVIM v0.7.2

I am new in vim, neovim and lua programming so apologizes in advance in case the question is too silly. Thanks.

Body:
Firtsble solidity-ls installed by mason via neovim command

:LspInstall solidity-ls

wasn't executable from terminal, altough it was shown as an executable one when typing :LspInfo in .sol file. After I installed it manually via npm

npm i solidity-ls -g

This is configuration for solidity-ls

require'lspconfig'.solidity.setup({
    on_attach = on_attach,
})

With this empty configuration however root directory is not found, also solidity-ls is not attached to the file which I guess is just a consequence.

After adding root_dir manually in a following way and checking the file via luafile %

require'lspconfig'.solidity.setup({
    on_attach = on_attach,
    root_dir = function(fname)
        return vim.fn.getcwd()
    end,
})

I get this error

LSP[solidity]: Error SERVER_REQUEST_HANDLER_ERROR: "/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:86: bad argument #1 to 'ipairs' (table expected, got nil)"

Although :LspInfo shows root_dir is set up solidity-ls still is not attached

LspInfo from .sol file after

Any suggestion how to solve this?

Ubuntu 20.04.3 LTS
NVIM v0.7.2

I am new in vim, neovim and lua programming so apologizes in advance in case the question is too silly. Thanks.


问:
How to Query Wikivoyage Destinations
I am trying to get a JSON list of all destinations listed on Wikivoyage: https://en.wikivoyage.org/wiki/Destinations

I have tried using the wikivoyage API sandbox but I have been unable to identify how a "destination" is differentiated in the code.

I have searched the Wikivoyage API sandbox for a couple of days but I have not found any datapoint relating to destination. https://en.wikivoyage.org/wiki/Special:ApiSandbox

The closest thing I have found is that on the destinations page (https://en.wikivoyage.org/wiki/Destinations) a summary count of 31,721 is listed, which, when clicked on, appears to list all content pages(https://en.wikivoyage.org/wiki/Special:Statistics).

But I have yet to discover how to list all content pages via the API as this too seems not to be an internal datapoint against which one can filter.

I would be very appreciative of any help!

Title: How to Query Wikivoyage Destinations


问:
How to offset polygon edges at different values?
I have a list of point2D that makes a closed polygon. I can offset the edges outside or inside of the polygon. But i wanna offset the edges with different values. For example this is my polygon:

```<code>[[ 25   0]
 [  0  25]
 [  0  75]
 [ 25 100]
 [ 75 100]
 [100  75]
 [100  25]
 [ 75   0]
 [ 25   0]]
</code>```

5 units offset from the edge formed by (25.0) and (75.0) coordinates;
4 units offset from the edge formed by (25.100) and (75.100) coordinates;
and 3 units offset from remaining edges. (all inwards)

how can i do this? what should i do?

Body:
I have a list of point2D that makes a closed polygon. I can offset the edges outside or inside of the polygon. But i wanna offset the edges with different values. For example this is my polygon:

[[ 25   0]
 [  0  25]
 [  0  75]
 [ 25 100]
 [ 75 100]
 [100  75]
 [100  25]
 [ 75   0]
 [ 25   0]]

5 units offset from the edge formed by (25.0) and (75.0) coordinates;
4 units offset from the edge formed by (25.100) and (75.100) coordinates;
and 3 units offset from remaining edges. (all inwards)

how can i do this? what should i do?


问:
@nestjs/mongoose, virtual populate with 2 databases
I'm trying to populate userId field which exists in database 1 from user document which exists in database 2.

I've already defined connectionName parameter in MongooseModule.ForRootAsync() I can't find out where the problem is. Also it works if I request info from db1 and db2 individually.

Actually on console.log(commentPopulated) userId field is just the objectId without populated fields from User schema and also sometimes with certain @Prop() and .populate() parameters app throw me this error:

MissingSchemaError: Schema hasn't been registered for model "User".
```
<p>Using <code>@nestjs/mongoose</code> decorators how do I achieve this?</p>
<p><code>app.module.ts</code></p>
<pre class="lang-js prettyprint-override"><code>MongooseModule.forRootAsync({
  connectionName: 'db1',
  useFactory: () => ({
    uri: process.env.DB1,
    connectionFactory: (connection: { plugin: (arg0: unknown) => void }) => {
      connection.plugin(_)
      connection.plugin(autoPopulate)
      return connection
    },
  }),
}),
MongooseModule.forRootAsync({
  connectionName: 'db2',
  useFactory: () => ({
    uri: process.env.DB2,
    connectionFactory: (connection: { plugin: (arg0: unknown) => void }) => {
      connection.plugin(_)
      connection.plugin(autoPopulate)
      return connection
    },
  }),
}),
</code>```

comment.module.ts

const commentModule: DynamicModule = MongooseModule.forFeatureAsync([
    {
        name: Comment.name,
        useFactory: () => {
            return CommentSchema
        }
    }
], 'db1')

@Module({
    imports: [commentModule],
    providers: [CommentService, CommentResolver]
})
export class CommentModule { }
```
<p><code>comment.schema.ts</code></p>
<pre class="lang-js prettyprint-override"><code>@Schema({ toJSON: { virtuals: true, getters: true }, toObject: { virtuals: true, getters: true } })
@ObjectType()
export class Comment extends Document {
    @Prop()
    @Field(() => String)
    readonly _id: MongooseSchema.Types.ObjectId

    @Prop({ required: true })
    @Field(() => String)
    text: string

    //TODO: Reference User document from DB2, Comment document exists in DB1
    @Prop({ type: MongooseSchema.Types.ObjectId, ref: User.name})
    @Field(() => User, { nullable: true })
    userId: MongooseSchema.Types.ObjectId

    @Prop({ type: String, enum: UserType, required: true, default: UserType.Regular })
    @Field(() => UserType, { defaultValue: UserType.Regular })
    userType: UserType

    @Prop({ default: Date.now })
    @Field(() => Date)
    created: Date
}

export const CommentSchema = SchemaFactory.createForClass(Comment)
</code>```

user.module.ts

const userModule: DynamicModule = MongooseModule.forFeatureAsync([
  {
    name: User.name,
    useFactory: () => {
      return UserSchema
    },
  },
], 'db2')

@Module({
  imports: [userModule],
  providers: [UserService, UserResolver]
})
export class UserModule { }
```
<p><code>user.schema.ts</code></p>
<pre class="lang-js prettyprint-override"><code>@Schema()
@ObjectType()
export class User extends Document {
    @Prop()
    @Field(() => String)
    readonly _id: MongooseSchema.Types.ObjectId

    @Prop({ required: true })
    @Field(() => String)
    firstName: string

    @Prop({ required: true })
    @Field(() => String)
    lastName: string

    @Prop({ required: true })
    @Field(() => String)
    email: string
}

export const UserSchema = SchemaFactory.createForClass(User)
</code>```

comment.service.ts

@Injectable()
export class CommentService {
    constructor(@InjectModel(Comment.name, 'db1') private readonly model: Model<Comment>) { }
    async getComments() {
        const commentPopulated = await this.model.findById('63b8608c7d4f880cba028bfe').populate('userId')
        console.log(commentPopulated)
        return commentPopulated
    }
}
```

I have tried randomly playing with parameters on @Prop() decorator with no success, I think there is the problem, also played with .populate() function parameters.

Body:
I'm trying to populate userId field which exists in database 1 from user document which exists in database 2.

I've already defined connectionName parameter in MongooseModule.ForRootAsync() I can't find out where the problem is. Also it works if I request info from db1 and db2 individually.

Actually on console.log(commentPopulated) userId field is just the objectId without populated fields from User schema and also sometimes with certain @Prop() and .populate() parameters app throw me this error:

MissingSchemaError: Schema hasn't been registered for model "User".

Using @nestjs/mongoose decorators how do I achieve this?

app.module.ts

MongooseModule.forRootAsync({
  connectionName: 'db1',
  useFactory: () => ({
    uri: process.env.DB1,
    connectionFactory: (connection: { plugin: (arg0: unknown) => void }) => {
      connection.plugin(_)
      connection.plugin(autoPopulate)
      return connection
    },
  }),
}),
MongooseModule.forRootAsync({
  connectionName: 'db2',
  useFactory: () => ({
    uri: process.env.DB2,
    connectionFactory: (connection: { plugin: (arg0: unknown) => void }) => {
      connection.plugin(_)
      connection.plugin(autoPopulate)
      return connection
    },
  }),
}),

comment.module.ts

const commentModule: DynamicModule = MongooseModule.forFeatureAsync([
    {
        name: Comment.name,
        useFactory: () => {
            return CommentSchema
        }
    }
], 'db1')

@Module({
    imports: [commentModule],
    providers: [CommentService, CommentResolver]
})
export class CommentModule { }

comment.schema.ts

@Schema({ toJSON: { virtuals: true, getters: true }, toObject: { virtuals: true, getters: true } })
@ObjectType()
export class Comment extends Document {
    @Prop()
    @Field(() => String)
    readonly _id: MongooseSchema.Types.ObjectId

    @Prop({ required: true })
    @Field(() => String)
    text: string

    //TODO: Reference User document from DB2, Comment document exists in DB1
    @Prop({ type: MongooseSchema.Types.ObjectId, ref: User.name})
    @Field(() => User, { nullable: true })
    userId: MongooseSchema.Types.ObjectId

    @Prop({ type: String, enum: UserType, required: true, default: UserType.Regular })
    @Field(() => UserType, { defaultValue: UserType.Regular })
    userType: UserType

    @Prop({ default: Date.now })
    @Field(() => Date)
    created: Date
}

export const CommentSchema = SchemaFactory.createForClass(Comment)

user.module.ts

const userModule: DynamicModule = MongooseModule.forFeatureAsync([
  {
    name: User.name,
    useFactory: () => {
      return UserSchema
    },
  },
], 'db2')

@Module({
  imports: [userModule],
  providers: [UserService, UserResolver]
})
export class UserModule { }

user.schema.ts

@Schema()
@ObjectType()
export class User extends Document {
    @Prop()
    @Field(() => String)
    readonly _id: MongooseSchema.Types.ObjectId

    @Prop({ required: true })
    @Field(() => String)
    firstName: string

    @Prop({ required: true })
    @Field(() => String)
    lastName: string

    @Prop({ required: true })
    @Field(() => String)
    email: string
}

export const UserSchema = SchemaFactory.createForClass(User)

comment.service.ts

@Injectable()
export class CommentService {
    constructor(@InjectModel(Comment.name, 'db1') private readonly model: Model<Comment>) { }
    async getComments() {
        const commentPopulated = await this.model.findById('63b8608c7d4f880cba028bfe').populate('userId')
        console.log(commentPopulated)
        return commentPopulated
    }
}

I have tried randomly playing with parameters on @Prop() decorator with no success, I think there is the problem, also played with .populate() function parameters.


问:
How do I add AppService IAM Roles to access_token for Managed Identity in Azure?
I'm trying to use Managed Identities to authenticate and authorize endpoints on a controller of an API hosted in Azure (single-tenant).

Via the Azure portal, I have the IAM roles defined on the target AppService and have assigned the roles to the managed identity I'm using.  I also have the managed identity assigned to the calling application.  Is there a way I can have these IAM roles appear in the token retrieved by the identity_endpoint that is created with the inclusion of the managed identity?

I've tried doing this with an app registration using app roles and I've tried using the IAM roles directly on the AppService and haven't been able to come up with a working combination.

Any advice is appreciated.  Thanks.

Edit: Adding image of role assignment that doesn't seem to have gone as intended:
App Role Assignment missing Role
Role id source


问:
Multiple users connected to one ODBC DSN
I am trying to connect Power BI to a third party database, i have created a system DSN and connected Power BI through the DSN to an ODBC driver. This works locally as long everything is on the same machine.
However, how can i configure the DSN so that it can be accessed by multiple users on many other different machines.

I have considered creating a DSN on the machine of each user but this seems redundant.
This question can be asked this way: is there a method that allows me to create one ODBC driver, one DSN, on the machine that holds the database and connect multiple users remotely to that ODBC driver using that one DSN ?


问:
YugabyteDB xCluster replication issues with WAL
Create two new Cluster (NYC and FRA) — fresh (1 node per region)
Create a new table in each NYC and FRA
Create a bi-directional replication for the table (xCluster)
All works
Delete replication (1 and 2) both direction
Alter table (add column) in each cluster (NYC and FRA)
Create replication (1 and 2) both direction. One direction works, the opposite will fail with error unable to change the WAL retention time for table)

recreate the full cluster


问:
Is there a way to query the Shipping Zone on a Woocommerce checkout page?
I need to hide/show a WooCommerce checkout field based on the Shipping Zone AND Total Cart weight. I've got the following code working when its just querying the cart weight I just need to get it to check the Zone first. See my failed code below...

```<code>add_action( 'wp_footer', 'hide_fieldset_based_on_zone_and_cart_weight', 9999 );

function hide_fieldset_based_on_zone_and_cart_weight() {

    // THIS IS WHERE I NEED TO QUERY THE SHIPPING ZONE
    $shipping_zone = WC_Shipping_Zones::get_zones();

    // Get the total weight of the cart
    $cart_weight = WC()->cart->get_cart_contents_weight();

    // If the Zone is Blue Zone and the cart weight is less than 500, add some jQuery to hide the fieldset element
      if ($shipping_zone == 'Blue Zone' && $cart_weight < 500) {
        ?>
        <script>
            jQuery( document ).ready( function( $ ) {
                // Find the fieldset element and hide it
                $( 'fieldset#review_order_before_payment_tester_group_field' ).hide();
            } );
        </script>
        <?php
    }
}
</code>```

Any ideas?

Thanks in advance.

Body:
I need to hide/show a WooCommerce checkout field based on the Shipping Zone AND Total Cart weight. I've got the following code working when its just querying the cart weight I just need to get it to check the Zone first. See my failed code below...

add_action( 'wp_footer', 'hide_fieldset_based_on_zone_and_cart_weight', 9999 );

function hide_fieldset_based_on_zone_and_cart_weight() {

    // THIS IS WHERE I NEED TO QUERY THE SHIPPING ZONE
    $shipping_zone = WC_Shipping_Zones::get_zones();

    // Get the total weight of the cart
    $cart_weight = WC()->cart->get_cart_contents_weight();

    // If the Zone is Blue Zone and the cart weight is less than 500, add some jQuery to hide the fieldset element
      if ($shipping_zone == 'Blue Zone' && $cart_weight < 500) {
        ?>

        <?php
    }
}

Any ideas?

Thanks in advance.


问:
How do I Regex this Facebook fbclid?
I migrated a clients site from a Movable Type site with posts that ended in ".php" to a WordPress site that ends in a slash "/". All my 301 redirects are working great but i found out from the client he has links in his websites Facebook page. Those links end in ".php?fbclid=InsertRandomParamsHere". What I need to do is replace the ".php" with "/" and the pages will redirect correctly while maintaining the Facebook tracking parameters at the end.

I've been using a regular expression for the 301 and here is what my regex looks like so far (I'm using Rank Math plugin for redirects):

The Source URL regex is:

```<code>^(.*)\.php(.*)
</code>```

The Destination URL is:

https://www.beachwoodreporter.com/

What I get right now is, for an example link:

http://www.beachwoodreporter.com/music/you_turn_me_on_again.php?fbclid=IwAR37SDAQdPrxMqwHQEY6dcs5rle1Mt0b0WubR9dL8WbaX3zoKNqjW0J84p0

which should redirect to:

http://www.beachwoodreporter.com/music/you_turn_me_on_again/?fbclid=IwAR37SDAQdPrxMqwHQEY6dcs5rle1Mt0b0WubR9dL8WbaX3zoKNqjW0J84p0

is instead redirecting to:

http://www.beachwoodreporter.com/?fbclid=IwAR37SDAQdPrxMqwHQEY6dcs5rle1Mt0b0WubR9dL8WbaX3zoKNqjW0J84p0

so it's basically stripping out the slug portion of the URL:

/music/you_turn_me_on_again/

And the client has many links like this on their Facebook site trying to do one at a time is out of the question. All I need is to replace the ".php" with "/" and it should fix all these problems. Can what I want be done or should I tell the client I can't do it?

Image of the Rank Math regex settings:

Title: How do I Regex this Facebook fbclid?

Body:
I migrated a clients site from a Movable Type site with posts that ended in ".php" to a WordPress site that ends in a slash "/". All my 301 redirects are working great but i found out from the client he has links in his websites Facebook page. Those links end in ".php?fbclid=InsertRandomParamsHere". What I need to do is replace the ".php" with "/" and the pages will redirect correctly while maintaining the Facebook tracking parameters at the end.

I've been using a regular expression for the 301 and here is what my regex looks like so far (I'm using Rank Math plugin for redirects):

The Source URL regex is:

^(.*)\.php(.*)

The Destination URL is:

https://www.beachwoodreporter.com/

What I get right now is, for an example link:

http://www.beachwoodreporter.com/music/you_turn_me_on_again.php?fbclid=IwAR37SDAQdPrxMqwHQEY6dcs5rle1Mt0b0WubR9dL8WbaX3zoKNqjW0J84p0

which should redirect to:

http://www.beachwoodreporter.com/music/you_turn_me_on_again/?fbclid=IwAR37SDAQdPrxMqwHQEY6dcs5rle1Mt0b0WubR9dL8WbaX3zoKNqjW0J84p0

is instead redirecting to:

http://www.beachwoodreporter.com/?fbclid=IwAR37SDAQdPrxMqwHQEY6dcs5rle1Mt0b0WubR9dL8WbaX3zoKNqjW0J84p0

so it's basically stripping out the slug portion of the URL:

/music/you_turn_me_on_again/

And the client has many links like this on their Facebook site trying to do one at a time is out of the question. All I need is to replace the ".php" with "/" and it should fix all these problems. Can what I want be done or should I tell the client I can't do it?

Image of the Rank Math regex settings:


问:
Error while write the acceptance test with newman Rest APi
I am new to docker and testing through newman
while running test cases  the service of /services/c/d/docker/docker-compose.yml
getting following error
getaddrinfo ENOTFOUND
Error while write the acceptance test with newman
I am new to docker and testing through newman
while running test cases  the service of /services/c/d/docker/docker-compose.yml
getting following error
getaddrinfo ENOTFOUND

Following is the Snippet

```<code>runAcceptanceTests.sh
#!/bin/bash

set -e
if [ "${ENVIRONMENT}" == 'localhost' ]; then
    ../gradlew --project-dir ../ --build-cache assemble
        docker-compose -f docker-compose.yml \
      -f docker-compose.localhost.yml \
      -f ../services/a/b/docker/docker-compose.yml \
      -f ../services/c/d/docker/docker-compose.yml \
    build --force-rm api
docker-compose -f docker-compose.yml \
        -f docker-compose.localhost.yml \
        -f ../services/a/b/docker/docker-compose.yml \
        -f ../services/c/d/docker/docker-compose.yml \
         kill api
docker-compose -f docker-compose.yml \
  -f docker-compose.localhost.yml \
  -f ../services/a/b/docker/docker-compose.yml \
    -f ../services/c/d/docker/docker-compose.yml \
  run --rm \
  -e a="${a}" \
  -w /opt/code/api \
  apibuild ./acceptance-tests/newman/wait-for-api.sh ./acceptance-tests/newman/a.sh
else
docker-compose -f docker-compose.yml \
  run --rm \
  -e a="${a}" \
  -w /opt/code/api \
apibuild ./acceptance-tests/newman/a.sh
fi

a.sh
#!/bin/bash
set -e
readonly NEWMAN_COLLECTION_PATH=${ACCEPTANCE_TEST_PATH:-./acceptance-tests/newman}
readonly CI=${CI:-false}

if $CI && [[ "${ENVIRONMENT,,}" == "abc" ]]; then
  echo "Acceptance tests are disabled ."
  exit 0
fi

echo "Running :" && \
newman run "${NEWMAN_COLLECTION_PATH}/abc.postman_collection.json" \
--folder=ccc \
-e "${NEWMAN_COLLECTION_PATH}/zzz-${ENVIRONMENT}-acceptance-test.postman_environment.json" \
--global-var="config_key=${a}" -k

wait-for-api.sh

!/bin/sh

set -e

until curl -q -f --max-time 5 'http://localhost:8080/health/ping' &>/dev/null; do
  >&2 echo "API is unavailable yet - sleep 5s"
  sleep 5
done

>&2 echo " API is up - executing command $@"
exec "$@

docker-compose.yml

version: '3.2'
services:
  apibuild:
    build: ../ci-cd-pipeline/docker/build-agent
    image: api-build-agent:develop
    hostname: buildagent
    container_name: apibuildagent
    volumes:
      # mount entire folder
      - api/:/opt/code/api/:delegated
    environment:
      - a=${a:-int}
      - JAVA_hostname=`hostname`
    security_opt:
      - apparmor:unconfined

docker-compose.localhost.yml

version: '3.2'
services:
  apibuild:
    depends_on:
      - api
</code>```

Trying to add newman test for 2nd service my component consist of two services as follow
1  https://localhost:8080
2 https://localhost:8081enter image description here
i am trying to write the test for 2nd service but getting the error

❏ flow
↳ CheckFlow
POST https://localhost:8081/key/check [errored]
getaddrinfo ENOTFOUND service

could any one help me out regarding it

Body:
I am new to docker and testing through newman
while running test cases  the service of /services/c/d/docker/docker-compose.yml
getting following error
getaddrinfo ENOTFOUND
Error while write the acceptance test with newman
I am new to docker and testing through newman
while running test cases  the service of /services/c/d/docker/docker-compose.yml
getting following error
getaddrinfo ENOTFOUND

Following is the Snippet

runAcceptanceTests.sh
#!/bin/bash

set -e
if [ "${ENVIRONMENT}" == 'localhost' ]; then
    ../gradlew --project-dir ../ --build-cache assemble
        docker-compose -f docker-compose.yml \
      -f docker-compose.localhost.yml \
      -f ../services/a/b/docker/docker-compose.yml \
      -f ../services/c/d/docker/docker-compose.yml \
    build --force-rm api
docker-compose -f docker-compose.yml \
        -f docker-compose.localhost.yml \
        -f ../services/a/b/docker/docker-compose.yml \
        -f ../services/c/d/docker/docker-compose.yml \
         kill api
docker-compose -f docker-compose.yml \
  -f docker-compose.localhost.yml \
  -f ../services/a/b/docker/docker-compose.yml \
    -f ../services/c/d/docker/docker-compose.yml \
  run --rm \
  -e a="${a}" \
  -w /opt/code/api \
  apibuild ./acceptance-tests/newman/wait-for-api.sh ./acceptance-tests/newman/a.sh
else
docker-compose -f docker-compose.yml \
  run --rm \
  -e a="${a}" \
  -w /opt/code/api \
apibuild ./acceptance-tests/newman/a.sh
fi

a.sh
#!/bin/bash
set -e
readonly NEWMAN_COLLECTION_PATH=${ACCEPTANCE_TEST_PATH:-./acceptance-tests/newman}
readonly CI=${CI:-false}

if $CI && [[ "${ENVIRONMENT,,}" == "abc" ]]; then
  echo "Acceptance tests are disabled ."
  exit 0
fi

echo "Running :" && \
newman run "${NEWMAN_COLLECTION_PATH}/abc.postman_collection.json" \
--folder=ccc \
-e "${NEWMAN_COLLECTION_PATH}/zzz-${ENVIRONMENT}-acceptance-test.postman_environment.json" \
--global-var="config_key=${a}" -k

wait-for-api.sh

!/bin/sh

set -e

until curl -q -f --max-time 5 'http://localhost:8080/health/ping' &>/dev/null; do
  >&2 echo "API is unavailable yet - sleep 5s"
  sleep 5
done

>&2 echo " API is up - executing command $@"
exec "$@

docker-compose.yml

version: '3.2'
services:
  apibuild:
    build: ../ci-cd-pipeline/docker/build-agent
    image: api-build-agent:develop
    hostname: buildagent
    container_name: apibuildagent
    volumes:
      # mount entire folder
      - api/:/opt/code/api/:delegated
    environment:
      - a=${a:-int}
      - JAVA_hostname=`hostname`
    security_opt:
      - apparmor:unconfined

docker-compose.localhost.yml

version: '3.2'
services:
  apibuild:
    depends_on:
      - api

Trying to add newman test for 2nd service my component consist of two services as follow
1  https://localhost:8080
2 https://localhost:8081enter image description here
i am trying to write the test for 2nd service but getting the error

❏ flow
↳ CheckFlow
POST https://localhost:8081/key/check [errored]
getaddrinfo ENOTFOUND service

could any one help me out regarding it


问:
Plaid API not functioning: Claims I'm missing my client_id and secret
I am trying to run the Plaid API Quickstart. I have tried following these steps (https://plaid.com/docs/quickstart/) in Python, and these steps (https://www.youtube.com/watch?v=sGBvKDGgPjc) in Node. The video steps in Node are working much better for me, although I know nothing about Node.

When the server is launched (please excuse me if I'm using incorrect jargon, I've spent the last 6 months learning Python and mostly have no idea wtf I'm talking about), I get this image. As you can see, it says client_id, secret are missing fields.

However, in the file, they are clearly present (of course I've replaced them with x's). The code in the ".env" file is pasted below:

```<code># Get your Plaid API keys from the dashboard: https://dashboard.plaid.com/team/keys
PLAID_CLIENT_ID=xxxxxxxxxxxxxxxxxxxx
PLAID_SECRET=xxxxxxxxxxxxxxxxxxxx

# Use 'sandbox' to test with fake credentials in Plaid's Sandbox environment
# Use 'development' to test with real credentials while developing
# Use 'production' to go live with real users
PLAID_ENV=sandbox

# PLAID_PRODUCTS is a comma-separated list of products to use when
# initializing Link, e.g. PLAID_PRODUCTS=auth,transactions.
# see https://plaid.com/docs/api/tokens/#link-token-create-request-products for a complete list.
# Only institutions that support ALL listed products will be displayed in Link.
# If you don't see the institution you want in Link, remove any products you aren't using.
# Important:
# When moving to Production, make sure to update this list with only the products
# you plan to use. Otherwise, you may be billed for unneeded products.
# NOTE:
# - 'income_verification' has to be used separately from all other products due to the specific flow.
# - 'payment_initiation' has to be used separately from all other products due to the specific flow.
PLAID_PRODUCTS=auth,transactions,identity

# PLAID_COUNTRY_CODES is a comma-separated list of countries to use when
# initializing Link, e.g. PLAID_COUNTRY_CODES=US,CA.
# Institutions from all listed countries will be shown. If Link is launched with multiple country codes,
# only products that you are enabled for in all countries will be used by Link.
# See https://plaid.com/docs/api/tokens/#link-token-create-request-country-codes for a complete list
PLAID_COUNTRY_CODES=US,CA

# Only required for OAuth:
# For sandbox, set PLAID_REDIRECT_URI to 'http://localhost:3000/'
# The OAuth redirect flow requires an endpoint on the developer's website
# that the bank website should redirect to. You will need to configure
# this redirect URI for your client ID through the Plaid developer dashboard
# at https://dashboard.plaid.com/team/api.
# For development or production, you will need to use an https:// url
# Instructions to create a self-signed certificate for localhost can be found at https://github.com/plaid/quickstart/blob/master/README.md#testing-oauth
# If you are not set up to use localhost with https:// on your system, you will be unable to test OAuth in development or production.
# In this case you can leave the PLAID_REDIRECT_URI blank.
PLAID_REDIRECT_URI=http://localhost:3000/
</code>```

Would someone please explain?

I've tried re-adding these keys and making sure they're in all of the files that they need to be.

Body:
I am trying to run the Plaid API Quickstart. I have tried following these steps (https://plaid.com/docs/quickstart/) in Python, and these steps (https://www.youtube.com/watch?v=sGBvKDGgPjc) in Node. The video steps in Node are working much better for me, although I know nothing about Node.

When the server is launched (please excuse me if I'm using incorrect jargon, I've spent the last 6 months learning Python and mostly have no idea wtf I'm talking about), I get this image. As you can see, it says client_id, secret are missing fields.

However, in the file, they are clearly present (of course I've replaced them with x's). The code in the ".env" file is pasted below:

# Get your Plaid API keys from the dashboard: https://dashboard.plaid.com/team/keys
PLAID_CLIENT_ID=xxxxxxxxxxxxxxxxxxxx
PLAID_SECRET=xxxxxxxxxxxxxxxxxxxx

# Use 'sandbox' to test with fake credentials in Plaid's Sandbox environment
# Use 'development' to test with real credentials while developing
# Use 'production' to go live with real users
PLAID_ENV=sandbox

# PLAID_PRODUCTS is a comma-separated list of products to use when
# initializing Link, e.g. PLAID_PRODUCTS=auth,transactions.
# see https://plaid.com/docs/api/tokens/#link-token-create-request-products for a complete list.
# Only institutions that support ALL listed products will be displayed in Link.
# If you don't see the institution you want in Link, remove any products you aren't using.
# Important:
# When moving to Production, make sure to update this list with only the products
# you plan to use. Otherwise, you may be billed for unneeded products.
# NOTE:
# - 'income_verification' has to be used separately from all other products due to the specific flow.
# - 'payment_initiation' has to be used separately from all other products due to the specific flow.
PLAID_PRODUCTS=auth,transactions,identity

# PLAID_COUNTRY_CODES is a comma-separated list of countries to use when
# initializing Link, e.g. PLAID_COUNTRY_CODES=US,CA.
# Institutions from all listed countries will be shown. If Link is launched with multiple country codes,
# only products that you are enabled for in all countries will be used by Link.
# See https://plaid.com/docs/api/tokens/#link-token-create-request-country-codes for a complete list
PLAID_COUNTRY_CODES=US,CA

# Only required for OAuth:
# For sandbox, set PLAID_REDIRECT_URI to 'http://localhost:3000/'
# The OAuth redirect flow requires an endpoint on the developer's website
# that the bank website should redirect to. You will need to configure
# this redirect URI for your client ID through the Plaid developer dashboard
# at https://dashboard.plaid.com/team/api.
# For development or production, you will need to use an https:// url
# Instructions to create a self-signed certificate for localhost can be found at https://github.com/plaid/quickstart/blob/master/README.md#testing-oauth
# If you are not set up to use localhost with https:// on your system, you will be unable to test OAuth in development or production.
# In this case you can leave the PLAID_REDIRECT_URI blank.
PLAID_REDIRECT_URI=http://localhost:3000/

Would someone please explain?

I've tried re-adding these keys and making sure they're in all of the files that they need to be.


问:
In CDP how to update OneViewofProfile Id through (VisitorId, browserID)?
anyone from CDP certified guide me on this. what is the better approach to update CDP profile id, and how these below use cases are same. When 2 user are using same device, do they got the same visitor Id ?

One CDP platform I visit there i saw
through VisitorId they are identifing update_or_create(OneViewofProfile Id) in CDP
here browser Id is not creating new in incognito mode.
Visitor id creating always new. in incognito

In Sitecore I saw
Through browserID they get refId(OneViewofProfile Id) and then update OneViewofProfile Id through refId
here browser Id is getting newly create in incognito mode
Visitor id creating always new. in incognito

your guidance will be highly appreciated

Thanks

I tried multiple CDP platforms.


问:
Glob pattern to exclude all subfolders from Explorer view in Code
In VS Code I'm trying to alter the files.exclude setting for a workspace so that all subfolders are excluded.

This is my current pattern - it only covers subfolder names up to 7 characters long - can I shorten to a single pattern that covers names of any length?

```<code>"settings": {
    "files.exclude": {
        "**/[A-Za-z][A-Za-z][A-Za-z ]": true,
        "**/[A-Za-z][A-Za-z][A-Za-z ][A-Za-z ]": true,
        "**/[A-Za-z][A-Za-z][A-Za-z ][A-Za-z ][A-Za-z ]": true,
        "**/[A-Za-z][A-Za-z][A-Za-z ][A-Za-z ][A-Za-z ][A-Za-z ]": true,
        "**/[A-Za-z][A-Za-z][A-Za-z ][A-Za-z ][A-Za-z ][A-Za-z ][A-Za-z ]": true
    }
</code>```

Body:
In VS Code I'm trying to alter the files.exclude setting for a workspace so that all subfolders are excluded.

This is my current pattern - it only covers subfolder names up to 7 characters long - can I shorten to a single pattern that covers names of any length?

"settings": {
    "files.exclude": {
        "**/[A-Za-z][A-Za-z][A-Za-z ]": true,
        "**/[A-Za-z][A-Za-z][A-Za-z ][A-Za-z ]": true,
        "**/[A-Za-z][A-Za-z][A-Za-z ][A-Za-z ][A-Za-z ]": true,
        "**/[A-Za-z][A-Za-z][A-Za-z ][A-Za-z ][A-Za-z ][A-Za-z ]": true,
        "**/[A-Za-z][A-Za-z][A-Za-z ][A-Za-z ][A-Za-z ][A-Za-z ][A-Za-z ]": true
    }