问:
Python WMI Module - Get Root Class Property Values
I am trying to get specific property values stored in WMI on a remote computer. The properties I am looking for are not in one of the normal namespaces such as Win32_ComputerSystem nor Win32_DesktopMonitor. It's stored inside root\wmi WmiMonitorBasicDisplayParams.

The specific properties I need are MaxHorizontalImageSize and MaxVerticalImageSize for each connected monitor on the remote computer.

The closest i can get with the WMI module is:

```<code>monitor_data = wmi.WMI(moniker="//./root/wmi:WmiMonitorBasicDisplayParams")
</code>```

This gives me the type "<class 'wmi.wmi_class'> and looks like this:

```<code>{
        [key, read] string InstanceName;
        [read] boolean Active;
        [WmiDataId(1), read] uint8 VideoInputType;
        [WmiDataId(2), read] uint8 MaxHorizontalImageSize;
        [WmiDataId(3), read] uint8 MaxVerticalImageSize;
        [WmiDataId(4), read, WmiScale(-2)] uint8 DisplayTransferCharacteristic;
        [WmiDataId(5), read] WmiMonitorSupportedDisplayFeatures SupportedDisplayFeatures;
};
</code>```

If I try to access the MaxHorizontalImageSize property, i get the type "<class 'wmi.wmi_property'> and printing it directly gives "<wmi_property: MaxHorizontalImageSize>"

```<code>print(monitor_data.MaxHorizontalImageSize)
</code>```

This property should have 2 numbers in it from the 2 connected displays but i cant figure out how to actually access the values.

The above solution also only works on the local machine, i need to get it from remote machines. Typically with WMI, i can get remote info by doing this:

```<code>pc = wmi.WMI('ComputerName')
data_i_want = pc.Win32_Processor()
</code>```

But I don't know how this would be done when using a moniker like above. I know I could create and call a powershell script and read the return value, but i would prefer to keep everything within Python and not have to call powershell. I imagine this can be access via the WMI module, i just dont know what's missing.

Body:
I am trying to get specific property values stored in WMI on a remote computer. The properties I am looking for are not in one of the normal namespaces such as Win32_ComputerSystem nor Win32_DesktopMonitor. It's stored inside root\wmi WmiMonitorBasicDisplayParams.

The specific properties I need are MaxHorizontalImageSize and MaxVerticalImageSize for each connected monitor on the remote computer.

The closest i can get with the WMI module is:

monitor_data = wmi.WMI(moniker="//./root/wmi:WmiMonitorBasicDisplayParams")

This gives me the type "<class 'wmi.wmi_class'> and looks like this:

{
        [key, read] string InstanceName;
        [read] boolean Active;
        [WmiDataId(1), read] uint8 VideoInputType;
        [WmiDataId(2), read] uint8 MaxHorizontalImageSize;
        [WmiDataId(3), read] uint8 MaxVerticalImageSize;
        [WmiDataId(4), read, WmiScale(-2)] uint8 DisplayTransferCharacteristic;
        [WmiDataId(5), read] WmiMonitorSupportedDisplayFeatures SupportedDisplayFeatures;
};

If I try to access the MaxHorizontalImageSize property, i get the type "<class 'wmi.wmi_property'> and printing it directly gives "<wmi_property: MaxHorizontalImageSize>"

print(monitor_data.MaxHorizontalImageSize)

This property should have 2 numbers in it from the 2 connected displays but i cant figure out how to actually access the values.

The above solution also only works on the local machine, i need to get it from remote machines. Typically with WMI, i can get remote info by doing this:

pc = wmi.WMI('ComputerName')
data_i_want = pc.Win32_Processor()

But I don't know how this would be done when using a moniker like above. I know I could create and call a powershell script and read the return value, but i would prefer to keep everything within Python and not have to call powershell. I imagine this can be access via the WMI module, i just dont know what's missing.


来源: stackexchange

问:
webdriverIO: locating (user-agent) a shadow-root element
Can anyone help me to figure out how to click on the element Nyregistrering from a dropdown with 2 other elements?

I tried something like this below:

```<code>When(/^user click on Nyregistrering$/, async () => {
    await browser.pause(1000);

    const element = await browser.$('#Tjenestevariant').$('#Tjenestevariant_input_text').shadow$('Nyregistrering');

    await element.click();

    await browser.pause(3000);

});
</code>```

But getting the following error:

```<code>Error: Can't call click on element with selector "function() {
Error: Can't call click on element with selector "function() {
     // element has a shadowRoot property
      if (this.shadowRoot) {
        return this.shadowRoot.querySelector('Nyregistrering')
      }
      // fall back to querying the element directly if not
      return this.querySelector('Nyregistrering')
    }" because element wasn't found
    at async World.<anonymous>
</code>```

Using WebdriverIO, Selenium-Standalone, with:

```<code>"license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.20.2",
    "@babel/preset-env": "^7.20.2",
    "@babel/register": "^7.18.9",
    "@wdio/allure-reporter": "^7.26.0",
    "@wdio/cli": "^7.26.0",
    "@wdio/cucumber-framework": "^7.26.0",
    "@wdio/local-runner": "^7.26.0",
    "@wdio/selenium-standalone-service": "^7.26.0",
    "@wdio/spec-reporter": "^7.26.0",
    "wdio-wait-for": "^3.0.0"
  },
  "dependencies": {
    "path": "^0.12.7"
</code>```

Attached image showing the HTML DOM

Before I tried the following:

```<code>    const innerEl = await $('aria/Nyregistrering');

    await innerEl.click();
</code>```

But got the following error:

```<code> Error in "0: user click on Nyregistrering"
element click intercepted: element click intercepted: Element <div class="table__Table_body_cell-VK92s" role="cell">...</div> is not clickable at point (304, 345). Other element would receive the click: <div class="fluid-grid__Cell-pdlMm fluid-grid__SpanFullS-qYF3N" role="gridcell">...</div>
  (Session info: chrome=108.0.5359.94)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async World.<anonymous> (/home/
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Can anyone help me to figure out how to click on the element Nyregistrering from a dropdown with 2 other elements?

I tried something like this below:

When(/^user click on Nyregistrering$/, async () => {
    await browser.pause(1000);

    const element = await browser.$('#Tjenestevariant').$('#Tjenestevariant_input_text').shadow$('Nyregistrering');

    await element.click();

    await browser.pause(3000);

});

But getting the following error:

Error: Can't call click on element with selector "function() {
Error: Can't call click on element with selector "function() {
     // element has a shadowRoot property
      if (this.shadowRoot) {
        return this.shadowRoot.querySelector('Nyregistrering')
      }
      // fall back to querying the element directly if not
      return this.querySelector('Nyregistrering')
    }" because element wasn't found
    at async World.<anonymous>

Using WebdriverIO, Selenium-Standalone, with:

"license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.20.2",
    "@babel/preset-env": "^7.20.2",
    "@babel/register": "^7.18.9",
    "@wdio/allure-reporter": "^7.26.0",
    "@wdio/cli": "^7.26.0",
    "@wdio/cucumber-framework": "^7.26.0",
    "@wdio/local-runner": "^7.26.0",
    "@wdio/selenium-standalone-service": "^7.26.0",
    "@wdio/spec-reporter": "^7.26.0",
    "wdio-wait-for": "^3.0.0"
  },
  "dependencies": {
    "path": "^0.12.7"

Attached image showing the HTML DOM

Before I tried the following:

    const innerEl = await $('aria/Nyregistrering');

    await innerEl.click();

But got the following error:

 Error in "0: user click on Nyregistrering"
element click intercepted: element click intercepted: Element
...
 is not clickable at point (304, 345). Other element would receive the click:
...

  (Session info: chrome=108.0.5359.94)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async World.<anonymous> (/home/


问:
discord.py and mongodb removing a document with _id or all the documents with user id
So I've been making a warning system in d.py and I'm finally on my last command is a clearwarn command which will.. Clear a warn of a user. However I want to be able to delete the document with the mongodb document's _id or if none is provided, then it'll delete all the warns that matches the user's id

```<code>@client.hybrid_command(name = "clearwarn", with_app_command=True, description="Delete a warn or all warns of a member", aliases=["clearwarns"])
@commands.guild_only()
@commands.has_permissions(moderate_members=True)
async def clearwarn(ctx, member: discord.Member = None, caseid = None):
    if member == None:
        await ctx.reply("A member is required")
    else:
        if caseid == None:
            check = list(warndb.warn_logs.deleteMany({"user_id": member.id}))
            if check is None:
                await ctx.reply("This user doesn't have any warns to clear")
            else:
                await ctx.reply(f"Removed all warnings from **{member.name}**")
                return
        else:
            try:
                warndb.warn_logs.deleteOne({_id:ObjectId(caseid)}, True)
                await ctx.reply(f"Removed 1 warning from **{member.name}**")
                return
            except:
                await ctx.reply("The case id you provided is invalid")
                return
</code>```

caseid would be the _id from mongodb, I also don't know how to delete a document.

```<code>Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/container/main.py", line 418, in clearwarn
    check = list(warndb.warn_logs.deleteMany({"user_id": member.id}))
  File "/home/container/.local/lib/python3.9/site-packages/pymongo/collection.py", line 3213, in __call__
    raise TypeError(
TypeError: 'Collection' object is not callable. If you meant to call the 'deleteMany' method on a 'Collection' object it is failing because no such method exists.
</code>```

Body:
So I've been making a warning system in d.py and I'm finally on my last command is a clearwarn command which will.. Clear a warn of a user. However I want to be able to delete the document with the mongodb document's _id or if none is provided, then it'll delete all the warns that matches the user's id

@client.hybrid_command(name = "clearwarn", with_app_command=True, description="Delete a warn or all warns of a member", aliases=["clearwarns"])
@commands.guild_only()
@commands.has_permissions(moderate_members=True)
async def clearwarn(ctx, member: discord.Member = None, caseid = None):
    if member == None:
        await ctx.reply("A member is required")
    else:
        if caseid == None:
            check = list(warndb.warn_logs.deleteMany({"user_id": member.id}))
            if check is None:
                await ctx.reply("This user doesn't have any warns to clear")
            else:
                await ctx.reply(f"Removed all warnings from **{member.name}**")
                return
        else:
            try:
                warndb.warn_logs.deleteOne({_id:ObjectId(caseid)}, True)
                await ctx.reply(f"Removed 1 warning from **{member.name}**")
                return
            except:
                await ctx.reply("The case id you provided is invalid")
                return

caseid would be the _id from mongodb, I also don't know how to delete a document.

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 190, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/container/main.py", line 418, in clearwarn
    check = list(warndb.warn_logs.deleteMany({"user_id": member.id}))
  File "/home/container/.local/lib/python3.9/site-packages/pymongo/collection.py", line 3213, in __call__
    raise TypeError(
TypeError: 'Collection' object is not callable. If you meant to call the 'deleteMany' method on a 'Collection' object it is failing because no such method exists.


问:
How can I get previous Date from Timer publisher?
I'm trying to simplify this code

```<code>var sampleTimer:AnyCancellable?
var lastSampleUpdate:Date!

func startSampling(on date:Date) {
    lastSampleUpdate = date
    sampleTimer = Timer.publish(every: 20, on: .main, in: .default)
        .autoconnect()
        .receive(on: RunLoop.main)
        .sink(receiveValue: newDate(endDate:))
}

func newDate(endDate:Date)  {
    let timeDifference = endDate - lastSampleUpdate
    print("\(timeDifference) seconds passed")
    lastSampleUpdate = endDate
}
</code>```

I am sure this is common, but I also know that CurrentvalueSubject provides a previous value without storing it explicitly. How would I alter this to lose the lastSampleUpdate variable?

Body:
I'm trying to simplify this code

var sampleTimer:AnyCancellable?
var lastSampleUpdate:Date!

func startSampling(on date:Date) {
    lastSampleUpdate = date
    sampleTimer = Timer.publish(every: 20, on: .main, in: .default)
        .autoconnect()
        .receive(on: RunLoop.main)
        .sink(receiveValue: newDate(endDate:))
}

func newDate(endDate:Date)  {
    let timeDifference = endDate - lastSampleUpdate
    print("\(timeDifference) seconds passed")
    lastSampleUpdate = endDate
}

I am sure this is common, but I also know that CurrentvalueSubject provides a previous value without storing it explicitly. How would I alter this to lose the lastSampleUpdate variable?


问:
GCP Dataproc - unable to access GCP Cloud storage
I have a Dataproc(Spark Structured Streaming) job which takes data from Kafka, and does some processing. The checkpoint is a GCP Cloud storage, and it is somehow unable to list the objects in  GCP Storage

Here is the error :

```<code>Traceback (most recent call last):
  File "/tmp/3c930be06f4242378251aa6760390f8d/main-v1-test.py", line 352, in <module>
    sys.exit(main())
  File "/tmp/3c930be06f4242378251aa6760390f8d/main-v1-test.py", line 348, in main
    ss.readData()
  File "/tmp/3c930be06f4242378251aa6760390f8d/main-v1-test.py", line 301, in readData
    query = df_stream.selectExpr("CAST(value AS STRING)", "timestamp", "topic").writeStream \
  File "/usr/lib/spark/python/lib/pyspark.zip/pyspark/sql/streaming.py", line 1491, in start
  File "/usr/lib/spark/python/lib/py4j-0.10.9-src.zip/py4j/java_gateway.py", line 1304, in __call__
  File "/usr/lib/spark/python/lib/pyspark.zip/pyspark/sql/utils.py", line 111, in deco
  File "/usr/lib/spark/python/lib/py4j-0.10.9-src.zip/py4j/protocol.py", line 326, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o96.start.
: java.io.IOException: Error accessing gs://ss-checkpoint-10m-test-v1/metadata
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.getObject(GoogleCloudStorageImpl.java:2221)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.getItemInfo(GoogleCloudStorageImpl.java:2108)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageFileSystem.getFileInfoInternal(GoogleCloudStorageFileSystem.java:1091)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageFileSystem.getFileInfo(GoogleCloudStorageFileSystem.java:1065)
    at com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystemBase.getFileStatus(GoogleHadoopFileSystemBase.java:955)
    at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1691)
    at org.apache.spark.sql.execution.streaming.StreamMetadata$.read(StreamMetadata.scala:53)
    at org.apache.spark.sql.execution.streaming.StreamExecution.<init>(StreamExecution.scala:174)
    at org.apache.spark.sql.execution.streaming.MicroBatchExecution.<init>(MicroBatchExecution.scala:50)
    at org.apache.spark.sql.streaming.StreamingQueryManager.createQuery(StreamingQueryManager.scala:317)
    at org.apache.spark.sql.streaming.StreamingQueryManager.startQuery(StreamingQueryManager.scala:359)
    at org.apache.spark.sql.streaming.DataStreamWriter.startQuery(DataStreamWriter.scala:466)
    at org.apache.spark.sql.streaming.DataStreamWriter.startInternal(DataStreamWriter.scala:414)
    at org.apache.spark.sql.streaming.DataStreamWriter.start(DataStreamWriter.scala:301)
    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 py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at py4j.Gateway.invoke(Gateway.java:282)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Thread.java:750)
Caused by: com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
GET https://storage.googleapis.com/storage/v1/b/ss-checkpoint-10m-test-v1/o/metadata?fields=bucket,name,timeCreated,updated,generation,metageneration,size,contentType,contentEncoding,md5Hash,crc32c,metadata
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "939354532596-compute@developer.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object. Permission 'storage.objects.get' denied on resource (or it may not exist).",
    "reason" : "forbidden"
  } ],
  "message" : "939354532596-compute@developer.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object. Permission 'storage.objects.get' denied on resource (or it may not exist)."
}
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:428)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.getObject(GoogleCloudStorageImpl.java:2215)
    ... 24 more

</code>```

Additional details :

I'm using Service account kafka-admin@versa-sml-googl.iam.gserviceaccount.com to start the job, however the Dataproc VMs seem to be using  SA -> 939354532596-compute@developer.gserviceaccount.com to access the buckets :

```<code>(base) Karans-MacBook-Pro:Versa-StructuredStreaming karanalang$ gcloud auth list
                     Credentialed Accounts
ACTIVE  ACCOUNT
        dataproc-access@versa-kafka-poc.iam.gserviceaccount.com
*       kafka-admin@versa-sml-googl.iam.gserviceaccount.com
        karan.alang@gmail.com
        karan@versa-networks.com
        loki-748@versa-sml-googl.iam.gserviceaccount.com
        loki-storage@versa-sml-googl.iam.gserviceaccount.com

</code>```

Here is the list of roles in the above 2 Service Accounts:

kafka-admin@versa-sml-googl.iam.gserviceaccount.com

```<code>(base) Karans-MacBook-Pro:Versa-StructuredStreaming karanalang$ gcloud projects get-iam-policy versa-sml-googl  \
> --flatten="bindings[].members" \
> --format='table(bindings.role)' \
> --filter="bindings.members:kafka-admin@versa-sml-googl.iam.gserviceaccount.com"
ROLE
roles/compute.admin
roles/compute.storageAdmin
roles/container.admin
roles/container.clusterAdmin
roles/dataproc.admin
roles/dataproc.editor
roles/dataproc.worker
roles/iam.serviceAccountTokenCreator
roles/iam.serviceAccountUser
roles/metastore.editor
roles/owner
roles/storage.admin
roles/storage.objectAdmin
roles/storage.objectViewer

(base) Karans-MacBook-Pro:Versa-StructuredStreaming karanalang$ gcloud projects get-iam-policy versa-sml-googl  \
> --flatten="bindings[].members" \
> --format='table(bindings.role)' \
> --filter="939354532596-compute@developer.gserviceaccount.com"
ROLE
roles/compute.storageAdmin
roles/editor
roles/metastore.serviceAgent
roles/storage.objectAdmin
roles/storage.objectViewer

</code>```

The ServiceAccounts seem to have the required roles, so am not sure what the issue is ?
Any input on how to debug/fix this issue ?

tia!

Body:
I have a Dataproc(Spark Structured Streaming) job which takes data from Kafka, and does some processing. The checkpoint is a GCP Cloud storage, and it is somehow unable to list the objects in  GCP Storage

Here is the error :

Traceback (most recent call last):
  File "/tmp/3c930be06f4242378251aa6760390f8d/main-v1-test.py", line 352, in <module>
    sys.exit(main())
  File "/tmp/3c930be06f4242378251aa6760390f8d/main-v1-test.py", line 348, in main
    ss.readData()
  File "/tmp/3c930be06f4242378251aa6760390f8d/main-v1-test.py", line 301, in readData
    query = df_stream.selectExpr("CAST(value AS STRING)", "timestamp", "topic").writeStream \
  File "/usr/lib/spark/python/lib/pyspark.zip/pyspark/sql/streaming.py", line 1491, in start
  File "/usr/lib/spark/python/lib/py4j-0.10.9-src.zip/py4j/java_gateway.py", line 1304, in __call__
  File "/usr/lib/spark/python/lib/pyspark.zip/pyspark/sql/utils.py", line 111, in deco
  File "/usr/lib/spark/python/lib/py4j-0.10.9-src.zip/py4j/protocol.py", line 326, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o96.start.
: java.io.IOException: Error accessing gs://ss-checkpoint-10m-test-v1/metadata
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.getObject(GoogleCloudStorageImpl.java:2221)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.getItemInfo(GoogleCloudStorageImpl.java:2108)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageFileSystem.getFileInfoInternal(GoogleCloudStorageFileSystem.java:1091)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageFileSystem.getFileInfo(GoogleCloudStorageFileSystem.java:1065)
    at com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystemBase.getFileStatus(GoogleHadoopFileSystemBase.java:955)
    at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1691)
    at org.apache.spark.sql.execution.streaming.StreamMetadata$.read(StreamMetadata.scala:53)
    at org.apache.spark.sql.execution.streaming.StreamExecution.<init>(StreamExecution.scala:174)
    at org.apache.spark.sql.execution.streaming.MicroBatchExecution.<init>(MicroBatchExecution.scala:50)
    at org.apache.spark.sql.streaming.StreamingQueryManager.createQuery(StreamingQueryManager.scala:317)
    at org.apache.spark.sql.streaming.StreamingQueryManager.startQuery(StreamingQueryManager.scala:359)
    at org.apache.spark.sql.streaming.DataStreamWriter.startQuery(DataStreamWriter.scala:466)
    at org.apache.spark.sql.streaming.DataStreamWriter.startInternal(DataStreamWriter.scala:414)
    at org.apache.spark.sql.streaming.DataStreamWriter.start(DataStreamWriter.scala:301)
    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 py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at py4j.Gateway.invoke(Gateway.java:282)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Thread.java:750)
Caused by: com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
GET https://storage.googleapis.com/storage/v1/b/ss-checkpoint-10m-test-v1/o/metadata?fields=bucket,name,timeCreated,updated,generation,metageneration,size,contentType,contentEncoding,md5Hash,crc32c,metadata
{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "939354532596-compute@developer.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object. Permission 'storage.objects.get' denied on resource (or it may not exist).",
    "reason" : "forbidden"
  } ],
  "message" : "939354532596-compute@developer.gserviceaccount.com does not have storage.objects.get access to the Google Cloud Storage object. Permission 'storage.objects.get' denied on resource (or it may not exist)."
}
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:428)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)
    at com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.getObject(GoogleCloudStorageImpl.java:2215)
    ... 24 more

Additional details :

I'm using Service account kafka-admin@versa-sml-googl.iam.gserviceaccount.com to start the job, however the Dataproc VMs seem to be using  SA -> 939354532596-compute@developer.gserviceaccount.com to access the buckets :

(base) Karans-MacBook-Pro:Versa-StructuredStreaming karanalang$ gcloud auth list
                     Credentialed Accounts
ACTIVE  ACCOUNT
        dataproc-access@versa-kafka-poc.iam.gserviceaccount.com
*       kafka-admin@versa-sml-googl.iam.gserviceaccount.com
        karan.alang@gmail.com
        karan@versa-networks.com
        loki-748@versa-sml-googl.iam.gserviceaccount.com
        loki-storage@versa-sml-googl.iam.gserviceaccount.com

Here is the list of roles in the above 2 Service Accounts:

kafka-admin@versa-sml-googl.iam.gserviceaccount.com

(base) Karans-MacBook-Pro:Versa-StructuredStreaming karanalang$ gcloud projects get-iam-policy versa-sml-googl  \
> --flatten="bindings[].members" \
> --format='table(bindings.role)' \
> --filter="bindings.members:kafka-admin@versa-sml-googl.iam.gserviceaccount.com"
ROLE
roles/compute.admin
roles/compute.storageAdmin
roles/container.admin
roles/container.clusterAdmin
roles/dataproc.admin
roles/dataproc.editor
roles/dataproc.worker
roles/iam.serviceAccountTokenCreator
roles/iam.serviceAccountUser
roles/metastore.editor
roles/owner
roles/storage.admin
roles/storage.objectAdmin
roles/storage.objectViewer

(base) Karans-MacBook-Pro:Versa-StructuredStreaming karanalang$ gcloud projects get-iam-policy versa-sml-googl  \
> --flatten="bindings[].members" \
> --format='table(bindings.role)' \
> --filter="939354532596-compute@developer.gserviceaccount.com"
ROLE
roles/compute.storageAdmin
roles/editor
roles/metastore.serviceAgent
roles/storage.objectAdmin
roles/storage.objectViewer

The ServiceAccounts seem to have the required roles, so am not sure what the issue is ?
Any input on how to debug/fix this issue ?

tia!


问:
For every entity listed, I need an array listed for each account used in the current period
In Excel Files, I have raw data being sorted through with Vlookups and SUMIFs for a period of time.  The sort is through the owner entity. (i.e. Owner1, Owner2, Owner3...)  For this period, certain and same accounts will be used (can change for every different period) for every owner entity unless 0. So I have accounts 100,200,300,400,...,900.

I need to list an array by owner for every account number in column X while column Y has an entity owner name, for every owner.  I need a dynamic array as the # of accounts used for each period can fluctuate between 10-10,000+ (min/max) and I don't want to have cells blank or with no value given.

Perhaps my troubles could be solved with just making a Pivot Table setting up a template tab to pull from the certain PivT cells in.

Account
Owner

Account100
Owner1

Account200
Owner1

Account300
Owner1

Account100
Owner2

Account200
Owner2

Account300
Owner2

{=INDEX($C$31:$C$41,MATCH(0,COUNTIF($S$1:S1,$C$31:$C$41),0))}

I have this index array used for the accounts (use this function many times), but combining to list every owner entity is my troubles.


问:
Expressing constraints in scipy's linprog
Let's say we have a cloud of n points, m dimensional: x1(x1m1, x1m2...), x2, x3...
Now let's add an aditional point p(pm1, pm2...)

Point P needs to fulfill these 3 conditions:

P = a1x1 + a2x2 + a3*x3 ... Basically a dot product of [x1,x2,x3,x4...] and [a1,a2,a3,a4...]

Each a is a scalar positive coefficient, ak > 0

Sum of a must be equal or lower (since we are in floating point, lower works) than 1, a1 + a2 + a3... <= 1 (if =1, it means we are on the boundary)

The aim is not to know the coefficients themselves, but if the problem is feasible or possible to solve.

From what I understand, this is 1 equality and two inequality constraints, how would I input these in scipy's linprog?

P.S.: I'll leave this image in case it helps. Basically a convex hull membership problem. 2nd opinions would be very welcome, I have been working some time on this and found solutions online but to me they are not intuitive


问:
Unable to read a source file generated during annotation processing only when its in the test package
Banging my head against this for hours...

I have an annotation processor which outputs new java source files.

Those files are written to the standard Gradle (7.4.2) location e.g. build/sources/annotationProcessor/java

Files generated for classes annotated in the main package get put in annotationProcessor/java/main. Files generated for classes annotated in the test package get put into annotationProcessor/java/test

The problem: I can only use the java files output to annotationProcessor/main when compiling my tests. Any attempts to reference files generated in annotationProcessor/test cause cannot find symbol errors at build time.

Setup:

I'm using a completely stock Gradle 7.4.2 multi-projcest setup as created by init.

Directory Structure:

```<code>├── lib                           <-- this is where I'm using the annotation
│   ...
│   └── src/main/com/myproject
│         └── MyPojo.java         <-- this has an annotation on it
│   └── src/test/com/myproject
│         └── MyOtherPojo.java    <-- this has an annotation on it
│         └── MyTest.java         <-- Where I'm running the test
│   └── build.gradle.kts
├── processor                     <-- Where my annotation processor code lives
│   ...
│   └── build.gradle.kts
└── settings.gradle.kts
</code>```

The build.gradle for lib is similarly stock with one exception: I've manually added the build dirs to my source sets:

build.gradle:

```<code>plugins {
    // Apply the java-library plugin for API and implementation separation.
    id("java")
}

group = "myproject"
version = "0.1"

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")

    compileOnly("org.projectlombok:lombok:1.18.24")
    annotationProcessor("org.projectlombok:lombok:1.18.24")

    testCompileOnly("org.projectlombok:lombok:1.18.24")
    testAnnotationProcessor("org.projectlombok:lombok:1.18.24")

    // this is my annotation processor
    implementation(project(":processor"))
    annotationProcessor(project(":processor"))
    testAnnotationProcessor(project(":processor"))
}

// NEW!
// To read the annotation generated files at all, I've had
// to manually add the build dir to my source sets.
sourceSets {
    main {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java\\main")
        }

    }
    test {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java")
        }
    }
}

tasks.named<Test>("test") {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
}
</code>```

What's happening:

When I run a test: my annotation processor kicks in. Finds the MyPojo (from main) and MyOtherPOJO (from test) classes that are annotated with my annotation, and generates a new helper files for each. They're put into annotationProcessor/main and annotationProcessor/test respectively.

Like this:

```<code>├── lib
│   ...
│   └── build/generated/sources/annotationProcessor/java
│         └── MyPojoHelper.java         <-- my generated class
│   └── build/generated/sources/annotationProcessor/test
│         └── MyOtherPojoHelper.java    <-- my generated class
│   └── src
│       ...
</code>```

So far so good.

I can use the generated files in annotationProcessor/main with no issue in my test file.

```<code>@Test
public void myTest() {
    generated.myproject.MyPojoHelper.someMethod("foo"); // works!
}
</code>```

However, if I try to do the exact same thing, but referencing a generated file in annotationProcessor/test, I fail while compiling the test package.

```<code>@Test
public void myTest() {
    generated.myproject.MyOtherPojoHelper.someMethod("foo"); // compile failure!
}
</code>```

Error:

```<code>error: package gen.myproj does not exist
        gen.myproj.MyOtherPojoHelper.someMethood("foo");
                  ^
</code>```

Explicitly adding the annotationProcessor/test to source sets does not fix the problem:

This is the recommended solution in this SO Question.

```<code>sourceSets {
    main {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java\\main")
        }

    }
    test {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java")
        }
    }
    // NEW!
    // Adding the test path explicitly
    test {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java\\test")
        }
    }
}
</code>```

Same behavior while running the tests. For some reason, these files cannot be recognized.

I am completely stumped.

Body:
Banging my head against this for hours...

I have an annotation processor which outputs new java source files.

Those files are written to the standard Gradle (7.4.2) location e.g. build/sources/annotationProcessor/java

Files generated for classes annotated in the main package get put in annotationProcessor/java/main. Files generated for classes annotated in the test package get put into annotationProcessor/java/test

The problem: I can only use the java files output to annotationProcessor/main when compiling my tests. Any attempts to reference files generated in annotationProcessor/test cause cannot find symbol errors at build time.

Setup:

I'm using a completely stock Gradle 7.4.2 multi-projcest setup as created by init.

Directory Structure:

├── lib                           <-- this is where I'm using the annotation
│   ...
│   └── src/main/com/myproject
│         └── MyPojo.java         <-- this has an annotation on it
│   └── src/test/com/myproject
│         └── MyOtherPojo.java    <-- this has an annotation on it
│         └── MyTest.java         <-- Where I'm running the test
│   └── build.gradle.kts
├── processor                     <-- Where my annotation processor code lives
│   ...
│   └── build.gradle.kts
└── settings.gradle.kts

The build.gradle for lib is similarly stock with one exception: I've manually added the build dirs to my source sets:

build.gradle:

plugins {
    // Apply the java-library plugin for API and implementation separation.
    id("java")
}

group = "myproject"
version = "0.1"

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")

    compileOnly("org.projectlombok:lombok:1.18.24")
    annotationProcessor("org.projectlombok:lombok:1.18.24")

    testCompileOnly("org.projectlombok:lombok:1.18.24")
    testAnnotationProcessor("org.projectlombok:lombok:1.18.24")

    // this is my annotation processor
    implementation(project(":processor"))
    annotationProcessor(project(":processor"))
    testAnnotationProcessor(project(":processor"))
}

// NEW!
// To read the annotation generated files at all, I've had
// to manually add the build dir to my source sets.
sourceSets {
    main {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java\\main")
        }

    }
    test {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java")
        }
    }
}

tasks.named<Test>("test") {
    // Use JUnit Platform for unit tests.
    useJUnitPlatform()
}

What's happening:

When I run a test: my annotation processor kicks in. Finds the MyPojo (from main) and MyOtherPOJO (from test) classes that are annotated with my annotation, and generates a new helper files for each. They're put into annotationProcessor/main and annotationProcessor/test respectively.

Like this:

├── lib
│   ...
│   └── build/generated/sources/annotationProcessor/java
│         └── MyPojoHelper.java         <-- my generated class
│   └── build/generated/sources/annotationProcessor/test
│         └── MyOtherPojoHelper.java    <-- my generated class
│   └── src
│       ...

So far so good.

I can use the generated files in annotationProcessor/main with no issue in my test file.

@Test
public void myTest() {
    generated.myproject.MyPojoHelper.someMethod("foo"); // works!
}

However, if I try to do the exact same thing, but referencing a generated file in annotationProcessor/test, I fail while compiling the test package.

@Test
public void myTest() {
    generated.myproject.MyOtherPojoHelper.someMethod("foo"); // compile failure!
}

Error:

error: package gen.myproj does not exist
        gen.myproj.MyOtherPojoHelper.someMethood("foo");
                  ^

Explicitly adding the annotationProcessor/test to source sets does not fix the problem:

This is the recommended solution in this SO Question.

sourceSets {
    main {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java\\main")
        }

    }
    test {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java")
        }
    }
    // NEW!
    // Adding the test path explicitly
    test {
        java {
            srcDir("path\\to\\lib\\build\\generated\\sources\\annotationProcessor\\java\\test")
        }
    }
}

Same behavior while running the tests. For some reason, these files cannot be recognized.

I am completely stumped.


问:
How to post on a Facebook group as a Page, using the Graph API Explorer?
I am the administrator of website, a Facebook group, a Page and a Facebook API. I would like to create, once a day, a post on my Facebook group using my Page name as author AND using the Graph API Explorer. Is it even possible?

To start simply, I use the Graph API Explorer directly but it fails to create the post.
https://developers.facebook.com/tools/explorer/

For the moment, I have tested the Graph Explorer with these data and parameters:

Request:
post/v15.0/{my_group_id}/feed?message=test

Settings:

Application Meta: My app

User or Page: My Page

Permissions: pages_show_list, publish_to_groups, pages_read_engagement, pages_manage_posts, public_profile

```<code>{
  "error": {
    "message": "Permissions error",
    "type": "OAuthException",
    "code": 200,
    "error_subcode": 1376025,
    "is_transient": false,
    "error_user_title" => "No Permission to Post"
    "error_user_msg" => "You do not have permission to post in this group."
    "fbtrace_id": "xxx"
  }
}
</code>```

I'm not sure if I'm doing something wrong or if it's just impossible?

Body:
I am the administrator of website, a Facebook group, a Page and a Facebook API. I would like to create, once a day, a post on my Facebook group using my Page name as author AND using the Graph API Explorer. Is it even possible?

To start simply, I use the Graph API Explorer directly but it fails to create the post.
https://developers.facebook.com/tools/explorer/

For the moment, I have tested the Graph Explorer with these data and parameters:

Request:
post/v15.0/{my_group_id}/feed?message=test

Settings:

Application Meta: My app

User or Page: My Page

Permissions: pages_show_list, publish_to_groups, pages_read_engagement, pages_manage_posts, public_profile

{
  "error": {
    "message": "Permissions error",
    "type": "OAuthException",
    "code": 200,
    "error_subcode": 1376025,
    "is_transient": false,
    "error_user_title" => "No Permission to Post"
    "error_user_msg" => "You do not have permission to post in this group."
    "fbtrace_id": "xxx"
  }
}

I'm not sure if I'm doing something wrong or if it's just impossible?


问:
How can I install/embed Google Project Sunroof on my site?
I tried to create a form where users  fill the street address field/element on my form,  I want that data to fill this form https://sunroof.withgoogle.com with that same address, submit, retrieve and then display the resulting submission data within my forms submission window for reference and manipulation. Two examples of this are: https://roofingcalculator.com/ and https://estimate.sunstorm.energy/get-estimate/

I searched and could not find an API to do this with and I'm not tech savvy enough to go another route without instructions. I also tried to embed the page within my own page, but couldn't get that to work, either.


问:
What's the correct parameter to use on tf.keras.models.load_model
I'm new using Pyhton and I'm kinda lost trying setup keras save model and weights, someone with more experience could help me please?

I'm folloing this guide to learn how predict system works and would give advices in lottery games:

https://medium.com/@polanitzer/predicting-the-israeli-lottery-results-for-the-november-29-2022-game-using-an-artificial-191489eb2c10

On my Jurassic computer this is frozing in random epochs above 900, then reading tensorflow docs have see about possibility to use save weights on every epoch and continue from previous one if it fails / computer frozen.

I have did to checkpoint:

```<code>    checkpoint_filepath="/home/ubuntu/Downloads/Lottery/checkpoints/lottery/"
model_checkpoint_callback = ModelCheckpoint(
    filepath=os.path.join(checkpoint_filepath,"weights-improvement.hd5"),
    monitor='val_accuracy',
    verbose=1,
    save_best_only=True,
    save_weights_only=True,
    save_freq='epoch',
    mode='max')
es = EarlyStopping(monitor='val_accuracy', patience=5)
callbacks_list = [model_checkpoint_callback, es]
</code>```

And to load model:

```<code>model.load_weights("/home/ubuntu/Downloads/Lottery/checkpoints/lottery/weights-improvement.hd5")
loss, acc = model.evaluate(train_samples, train_labels, verbose=2)
print("Restored model, accuracy: {:5.2f}%".format(100 * acc))
load_model('/home/ubuntu/Downloads/Lottery/lottery/')
</code>```

Tried use train_samples / train_labels and x_train / y_train, no luck restoring then, runing all code in jupyter notebook, this start from begin everytime (0.08% accuracy even previous run have get 60% before frozen).

And at training model I have did:

```<code>model.fit(x=x_train, y=y_train, batch_size=32, epochs=1200, verbose=2, callbacks=[model_checkpoint_callback], validation_split=0.22)

model.save('lottery')
</code>```

I was reading docs from here:

https://www.tensorflow.org/tutorials/keras/save_and_load

What I'm doing wrong?

Thanks in advice to all able to try help me!!!

Body:
I'm new using Pyhton and I'm kinda lost trying setup keras save model and weights, someone with more experience could help me please?

I'm folloing this guide to learn how predict system works and would give advices in lottery games:

https://medium.com/@polanitzer/predicting-the-israeli-lottery-results-for-the-november-29-2022-game-using-an-artificial-191489eb2c10

On my Jurassic computer this is frozing in random epochs above 900, then reading tensorflow docs have see about possibility to use save weights on every epoch and continue from previous one if it fails / computer frozen.

I have did to checkpoint:

    checkpoint_filepath="/home/ubuntu/Downloads/Lottery/checkpoints/lottery/"
model_checkpoint_callback = ModelCheckpoint(
    filepath=os.path.join(checkpoint_filepath,"weights-improvement.hd5"),
    monitor='val_accuracy',
    verbose=1,
    save_best_only=True,
    save_weights_only=True,
    save_freq='epoch',
    mode='max')
es = EarlyStopping(monitor='val_accuracy', patience=5)
callbacks_list = [model_checkpoint_callback, es]

And to load model:

model.load_weights("/home/ubuntu/Downloads/Lottery/checkpoints/lottery/weights-improvement.hd5")
loss, acc = model.evaluate(train_samples, train_labels, verbose=2)
print("Restored model, accuracy: {:5.2f}%".format(100 * acc))
load_model('/home/ubuntu/Downloads/Lottery/lottery/')

Tried use train_samples / train_labels and x_train / y_train, no luck restoring then, runing all code in jupyter notebook, this start from begin everytime (0.08% accuracy even previous run have get 60% before frozen).

And at training model I have did:

model.fit(x=x_train, y=y_train, batch_size=32, epochs=1200, verbose=2, callbacks=[model_checkpoint_callback], validation_split=0.22)

model.save('lottery')

I was reading docs from here:

https://www.tensorflow.org/tutorials/keras/save_and_load

What I'm doing wrong?

Thanks in advice to all able to try help me!!!


问:
GridsearchCV(): Penalty term must be positive; got array
I am building a Logistic Regression model and am implementing GridSearchCV() in order to find the best parameters.

```<code>param_grid = [
    {'solver': ['lbfgs'], 'penalty':['l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver': ['liblinear'], 'penalty':['l1', 'l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver':['newton-cg'], 'penalty':['l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver':['newton-cholesky'], 'penalty':['l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver':['sag'], 'penalty':['l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver':['saga'], 'penalty': ['elasticnet', 'l1', 'l2'], 'C':[np.logspace(-4, 4, 20)]}
]

clf60 = LogisticRegression()

gridCV60 = GridSearchCV(clf60, param_grid = param_grid)

gridCV60.fit(x_train60, y_train60)
</code>```

which returns

```<code>ValueError: Penalty term must be positive; got (C=array([1.00000000e-04, 2.63665090e-04, 6.95192796e-04, 1.83298071e-03,
       4.83293024e-03, 1.27427499e-02, 3.35981829e-02, 8.85866790e-02,
       2.33572147e-01, 6.15848211e-01, 1.62377674e+00, 4.28133240e+00,
       1.12883789e+01, 2.97635144e+01, 7.84759970e+01, 2.06913808e+02,
       5.45559478e+02, 1.43844989e+03, 3.79269019e+03, 1.00000000e+04]))
</code>```

I have multiple dictionaries for each solver as certain penalties/certain combinations of l1/l2 as not all solvers take both. Within each dictionary, I also include an array of possible penalty, or C, values created by np.logspace(-4, 4, 20).

I've previously looked at this post where one user suggest entering the C value via a loop, however I am not sure how to modify my param_grid with a different value of C each time?

Body:
I am building a Logistic Regression model and am implementing GridSearchCV() in order to find the best parameters.

param_grid = [
    {'solver': ['lbfgs'], 'penalty':['l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver': ['liblinear'], 'penalty':['l1', 'l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver':['newton-cg'], 'penalty':['l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver':['newton-cholesky'], 'penalty':['l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver':['sag'], 'penalty':['l2'], 'C':[np.logspace(-4, 4, 20)]}
    ,{'solver':['saga'], 'penalty': ['elasticnet', 'l1', 'l2'], 'C':[np.logspace(-4, 4, 20)]}
]

clf60 = LogisticRegression()

gridCV60 = GridSearchCV(clf60, param_grid = param_grid)

gridCV60.fit(x_train60, y_train60)

which returns

ValueError: Penalty term must be positive; got (C=array([1.00000000e-04, 2.63665090e-04, 6.95192796e-04, 1.83298071e-03,
       4.83293024e-03, 1.27427499e-02, 3.35981829e-02, 8.85866790e-02,
       2.33572147e-01, 6.15848211e-01, 1.62377674e+00, 4.28133240e+00,
       1.12883789e+01, 2.97635144e+01, 7.84759970e+01, 2.06913808e+02,
       5.45559478e+02, 1.43844989e+03, 3.79269019e+03, 1.00000000e+04]))

I have multiple dictionaries for each solver as certain penalties/certain combinations of l1/l2 as not all solvers take both. Within each dictionary, I also include an array of possible penalty, or C, values created by np.logspace(-4, 4, 20).

I've previously looked at this post where one user suggest entering the C value via a loop, however I am not sure how to modify my param_grid with a different value of C each time?


问:
Webflux + R2DBC return exception if element exists/breaks integrity constraint and return element otherwise
I have a spring r2dbc repository like:

```<code>Mono<Foo> findFooByString(String string);
Mono<Foo> save(Foo foo);
</code>```

I have a service class that currently does:

```<code>public Mono<Foo> createFoo(Foo foo) {
  repository.save(foo);
}
</code>```

This works fine, though I have a unique constraint on the foo table string column, such that I would like to proactively check that the string column uniqueness is not violated before calling save.  I have an exception: DataIntegrityViolationException that I would like to return in this case.  Currently, the db layer returns more information that I would like to return to the user in the exception (sql that violates the integrity constraint).  This is trivial in tradition java + jpa:

```<code>Optional<Foo> fooOpt = repository.findFooByString(foo.getString());
if (fooOpt.isPresent()) {
  //do not add another with string otherwise db exception will occur
  throw new DataIntegrityViolationException("Don't do this!");
}
</code>```

But given my lack of experience in webflux/reactive/non-blocking programming, I don't understand how to "chain" these two actions together appropriately.

This makes sense to me for the first part:

```<code>repository.findFooByString(foo.getString())
                .switchIfEmpty(Mono.error(new DataIntegrityViolationException("Don't do this!")))
</code>```

But not sure how to then do the "else" condition for normal cases and return the repository.save(foo);

Any help would be appreciated.

Edit 1:
So this seems to get me closer, though the return of Mono to the caller isn't the same (no data on response through controller, but http status code correct), previously with just repository.save(foo) the Foo was returned to the caller correctly:

```<code>return repository.findFooByString(foo.getString())
        .flatMap(foo1 -> repository.save(foo))
        .onErrorResume(e -> Mono.error(new DataIntegrityViolationException("Don't Do this!")));
</code>```

Body:
I have a spring r2dbc repository like:

Mono<Foo> findFooByString(String string);
Mono<Foo> save(Foo foo);

I have a service class that currently does:

public Mono<Foo> createFoo(Foo foo) {
  repository.save(foo);
}

This works fine, though I have a unique constraint on the foo table string column, such that I would like to proactively check that the string column uniqueness is not violated before calling save.  I have an exception: DataIntegrityViolationException that I would like to return in this case.  Currently, the db layer returns more information that I would like to return to the user in the exception (sql that violates the integrity constraint).  This is trivial in tradition java + jpa:

Optional<Foo> fooOpt = repository.findFooByString(foo.getString());
if (fooOpt.isPresent()) {
  //do not add another with string otherwise db exception will occur
  throw new DataIntegrityViolationException("Don't do this!");
}

But given my lack of experience in webflux/reactive/non-blocking programming, I don't understand how to "chain" these two actions together appropriately.

This makes sense to me for the first part:

repository.findFooByString(foo.getString())
                .switchIfEmpty(Mono.error(new DataIntegrityViolationException("Don't do this!")))

But not sure how to then do the "else" condition for normal cases and return the repository.save(foo);

Any help would be appreciated.

Edit 1:
So this seems to get me closer, though the return of Mono to the caller isn't the same (no data on response through controller, but http status code correct), previously with just repository.save(foo) the Foo was returned to the caller correctly:

return repository.findFooByString(foo.getString())
        .flatMap(foo1 -> repository.save(foo))
        .onErrorResume(e -> Mono.error(new DataIntegrityViolationException("Don't Do this!")));


问:
I am not getting the :placeholder to change in my PHP scripting?
I am having a problem with the execution of my SQL query. Here is my code snippet...

```<code>$db = phpmotorsConnect();
$sqlSearch = "'%" . $searchTxt . "%'";
$sql = "SELECT * FROM inventory WHERE invColor LIKE :sqlSearch OR invMake LIKE :sqlSearch OR invModel LIKE
:sqlSearch OR invDescription LIKE :sqlSearch OR invPrice LIKE :sqlSearch";
$stmt = $db->prepare($sql);
// THIS LINE:
$stmt->bindValue(':sqlSearch', $sqlSearch, PDO::PARAM_STR);
$stmt->execute();
</code>```

The line indicated is NOT replacing the placeholder value with the variable $sqlSearch, like we did on the account and vehicle models. Any ideas why? I've tested out the query and it works as long as there is a good value in there.

I was expecting the placeholder, :sqlSearch, to be replaced with '%%', having the search text in for the string.

Body:
I am having a problem with the execution of my SQL query. Here is my code snippet...

$db = phpmotorsConnect();
$sqlSearch = "'%" . $searchTxt . "%'";
$sql = "SELECT * FROM inventory WHERE invColor LIKE :sqlSearch OR invMake LIKE :sqlSearch OR invModel LIKE
:sqlSearch OR invDescription LIKE :sqlSearch OR invPrice LIKE :sqlSearch";
$stmt = $db->prepare($sql);
// THIS LINE:
$stmt->bindValue(':sqlSearch', $sqlSearch, PDO::PARAM_STR);
$stmt->execute();

The line indicated is NOT replacing the placeholder value with the variable $sqlSearch, like we did on the account and vehicle models. Any ideas why? I've tested out the query and it works as long as there is a good value in there.

I was expecting the placeholder, :sqlSearch, to be replaced with '%%', having the search text in for the string.


问:
Source mapping for error messages is broken

As you can see in the image the error is undefined reference to product_params_all, this is correct, but the source line is wrong, it should be line 166 not 163. This happens on every error message I get from NextJS. I did not change anything in NextJS, just installed it few weeks ago and do npm run dev that's it. I understand it's a source mapping problem, is there a way to fix this?

Chrome Version 107.0.5304.121 (Official Build) (64-bit) Linux

```<code>$ node --version
v19.1.0
</code>```

Body:
As you can see in the image the error is undefined reference to product_params_all, this is correct, but the source line is wrong, it should be line 166 not 163. This happens on every error message I get from NextJS. I did not change anything in NextJS, just installed it few weeks ago and do npm run dev that's it. I understand it's a source mapping problem, is there a way to fix this?

Chrome Version 107.0.5304.121 (Official Build) (64-bit) Linux

$ node --version
v19.1.0


问:
Spark Submit Does Not Fail If The SQL Added to Run It Has a Query That Fails
I have a spark submit command that is given a .sql file with 10 consecutive queries in it to run.

If one of the queries fails due to syntax error or table not found issue, the spark submit command still succeeds and doesn't throw any error.

When I give yarn application -status <application_id> command the output says:

Final-State : SUCCEEDED

How do I make spark submit fail if one of the queries fails so that it shows the job didn't actually complete successfully?

I tried using

```<code>spark-submit --rest of the jars and configs (This works fine and runs the sql file)
if $ -ne 0
      exit 1
else
  <send email commands>
</code>```

I also tried to generate yarn application -status <application_id>
to grep FAILED status indication from there so I could make the job exit 1 (fail).

Body:
I have a spark submit command that is given a .sql file with 10 consecutive queries in it to run.

If one of the queries fails due to syntax error or table not found issue, the spark submit command still succeeds and doesn't throw any error.

When I give yarn application -status <application_id> command the output says:

Final-State : SUCCEEDED

How do I make spark submit fail if one of the queries fails so that it shows the job didn't actually complete successfully?

I tried using

spark-submit --rest of the jars and configs (This works fine and runs the sql file)
if $ -ne 0
      exit 1
else
  <send email commands>

I also tried to generate yarn application -status <application_id>
to grep FAILED status indication from there so I could make the job exit 1 (fail).


问:
@PreAuthorize not working after upgrading to Spring 3.0
Upgraded our entire microservice to the latest Spring 3.0 release, updated our JWT and FilterChain implementations to the new syntax (e.g removing WebSecurityConfigurerAdapter). Most of our endpoints continued to work, but notably every endpoint containing a @PreAuthorize annotation are no longer working.

One endpoint we have contains the following expression, and it has failed:

```<code>@PreAuthorize(
    """
    hasAuthority('COGNITO_ADMIN')
    or ( hasAuthority('COGNITO_PMO')
      and @authorizationService.notBlacklistedFromClientBySalesforceId(#baseQuestionnaireCreateRequestV1.salesforceClientId)
    )
    or ( hasAuthority('COGNITO_RESEARCHER')
      and @authorizationService.notBlacklistedFromClientBySalesforceId(#baseQuestionnaireCreateRequestV1.salesforceClientId)
    )
""")
</code>```

However, I have reduced this down to just this, and it will fail as well.

```<code>@PreAuthorize("hasAuthority('COGNITO_ADMIN')")
</code>```

Each time this will fail with a AuthenticationCredentialsNotFoundException, as it appears the default AuthorizationManagerBeforeMethodInterceptor pulls out a null context here:

```<code>private Supplier<Authentication> getAuthentication(SecurityContextHolderStrategy strategy) {
  return () -> {
    Authentication authentication = strategy.getContext().getAuthentication();
    if (authentication == null) {
      throw new AuthenticationCredentialsNotFoundException("An Authentication object was not found in the SecurityContext");
    } else {
      return authentication;
    }
  };
}
</code>```

At a loss as to why this is failing only for @PreAuthorize annotated endpoints. All other endpoints authorize correctly and authentication is set correctly.

Current Implementations

AuthorizationService

```<code>@Aspect
@Component
@RequiredArgsConstructor
public class AuthorizationService {

  public boolean notBlacklistedFromClientBySalesforceId(String salesForceId) {

    var client = clientService.getClientBySalesforceId(salesForceId);

    return isUserBlacklistedForClient(client.getId());
  }

  ...
}

</code>```

SecurityConfig

```<code>@EnableWebSecurity
@Configuration
@ConfigurationProperties(prefix = "security")
@Setter
@Validated
public class OAuth2ResourceServerSecurityConfiguration {

  @NotNull private String jwkSetUri;

  @Bean
  public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
    String cognitoAdmin = ADMIN.toCognitoGroup();
    String cognitoPmo = PMO.toCognitoGroup();
    String cognitoResearcher = RESEARCHER.toCognitoGroup();
    String cognitoContractor = CONTRACTOR.toCognitoGroup();

    http.cors()
        .and()
        .authorizeHttpRequests()

        // Restrict client restriction endpoints to admins/pmo only
        .requestMatchers("/clientBlacklist", "/clientBlacklist/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo)

        // Restrict tag POST, PUT, DELETE endpoints to admins only
        .requestMatchers(HttpMethod.GET, "/tags")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher, cognitoContractor)
        .requestMatchers(HttpMethod.POST, "/tags")
        .hasAnyAuthority(cognitoAdmin)
        .requestMatchers(HttpMethod.PUT, "/tags/*")
        .hasAnyAuthority(cognitoAdmin)
        .requestMatchers(HttpMethod.DELETE, "/tags/*")
        .hasAnyAuthority(cognitoAdmin)

        // Restrict questionnaireWhitelist endpoint to admin, pmo, and researcher only
        .requestMatchers("/questionnaireWhitelist", "/questionnaireWhitelist/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher)

        // Restrict creating/deleting questionnaires to admin, pmo, and researcher only
        .requestMatchers(HttpMethod.POST, "/questionnaires")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher)
        .requestMatchers(HttpMethod.DELETE, "/questionnaires/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher)

        // Restrict updating/deleting templates to admins/pmo only
        .requestMatchers(HttpMethod.PUT, "/templates/*")
        .hasAnyAuthority(cognitoAdmin)
        .requestMatchers(HttpMethod.DELETE, "/templates/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo)

        // Restrict clients to admin, pmo, and researcher only
        .requestMatchers("/clients", "/clients/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher)

        // Allows only ADMIN, PMO, CONTRACTOR, AND RESEARCHER roles to hit endpoints (restricts
        // UNASSIGNED)
        .anyRequest()
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher, CONTRACTOR.toCognitoGroup())
        .and()
        .oauth2ResourceServer()
        .jwt()
        .jwtAuthenticationConverter(new CognitoJwtAuthenticationConverter());

    return http.build();
  }
</code>```

Application.java

```<code>@EnableCaching
@EnableMongoAuditing
@ConfigurationPropertiesScan
@EnableMethodSecurity
@SpringBootApplication
public class QnrBldrApplication {

  public static void main(String[] args) {
    SpringApplication.run(QnrBldrApplication.class, args);
  }
}
</code>```

Body:
Upgraded our entire microservice to the latest Spring 3.0 release, updated our JWT and FilterChain implementations to the new syntax (e.g removing WebSecurityConfigurerAdapter). Most of our endpoints continued to work, but notably every endpoint containing a @PreAuthorize annotation are no longer working.

One endpoint we have contains the following expression, and it has failed:

@PreAuthorize(
    """
    hasAuthority('COGNITO_ADMIN')
    or ( hasAuthority('COGNITO_PMO')
      and @authorizationService.notBlacklistedFromClientBySalesforceId(#baseQuestionnaireCreateRequestV1.salesforceClientId)
    )
    or ( hasAuthority('COGNITO_RESEARCHER')
      and @authorizationService.notBlacklistedFromClientBySalesforceId(#baseQuestionnaireCreateRequestV1.salesforceClientId)
    )
""")

However, I have reduced this down to just this, and it will fail as well.

@PreAuthorize("hasAuthority('COGNITO_ADMIN')")

Each time this will fail with a AuthenticationCredentialsNotFoundException, as it appears the default AuthorizationManagerBeforeMethodInterceptor pulls out a null context here:

private Supplier<Authentication> getAuthentication(SecurityContextHolderStrategy strategy) {
  return () -> {
    Authentication authentication = strategy.getContext().getAuthentication();
    if (authentication == null) {
      throw new AuthenticationCredentialsNotFoundException("An Authentication object was not found in the SecurityContext");
    } else {
      return authentication;
    }
  };
}

At a loss as to why this is failing only for @PreAuthorize annotated endpoints. All other endpoints authorize correctly and authentication is set correctly.

Current Implementations

AuthorizationService

@Aspect
@Component
@RequiredArgsConstructor
public class AuthorizationService {

  public boolean notBlacklistedFromClientBySalesforceId(String salesForceId) {

    var client = clientService.getClientBySalesforceId(salesForceId);

    return isUserBlacklistedForClient(client.getId());
  }

  ...
}

SecurityConfig

@EnableWebSecurity
@Configuration
@ConfigurationProperties(prefix = "security")
@Setter
@Validated
public class OAuth2ResourceServerSecurityConfiguration {

  @NotNull private String jwkSetUri;

  @Bean
  public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
    String cognitoAdmin = ADMIN.toCognitoGroup();
    String cognitoPmo = PMO.toCognitoGroup();
    String cognitoResearcher = RESEARCHER.toCognitoGroup();
    String cognitoContractor = CONTRACTOR.toCognitoGroup();

    http.cors()
        .and()
        .authorizeHttpRequests()

        // Restrict client restriction endpoints to admins/pmo only
        .requestMatchers("/clientBlacklist", "/clientBlacklist/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo)

        // Restrict tag POST, PUT, DELETE endpoints to admins only
        .requestMatchers(HttpMethod.GET, "/tags")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher, cognitoContractor)
        .requestMatchers(HttpMethod.POST, "/tags")
        .hasAnyAuthority(cognitoAdmin)
        .requestMatchers(HttpMethod.PUT, "/tags/*")
        .hasAnyAuthority(cognitoAdmin)
        .requestMatchers(HttpMethod.DELETE, "/tags/*")
        .hasAnyAuthority(cognitoAdmin)

        // Restrict questionnaireWhitelist endpoint to admin, pmo, and researcher only
        .requestMatchers("/questionnaireWhitelist", "/questionnaireWhitelist/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher)

        // Restrict creating/deleting questionnaires to admin, pmo, and researcher only
        .requestMatchers(HttpMethod.POST, "/questionnaires")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher)
        .requestMatchers(HttpMethod.DELETE, "/questionnaires/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher)

        // Restrict updating/deleting templates to admins/pmo only
        .requestMatchers(HttpMethod.PUT, "/templates/*")
        .hasAnyAuthority(cognitoAdmin)
        .requestMatchers(HttpMethod.DELETE, "/templates/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo)

        // Restrict clients to admin, pmo, and researcher only
        .requestMatchers("/clients", "/clients/*")
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher)

        // Allows only ADMIN, PMO, CONTRACTOR, AND RESEARCHER roles to hit endpoints (restricts
        // UNASSIGNED)
        .anyRequest()
        .hasAnyAuthority(cognitoAdmin, cognitoPmo, cognitoResearcher, CONTRACTOR.toCognitoGroup())
        .and()
        .oauth2ResourceServer()
        .jwt()
        .jwtAuthenticationConverter(new CognitoJwtAuthenticationConverter());

    return http.build();
  }

Application.java

@EnableCaching
@EnableMongoAuditing
@ConfigurationPropertiesScan
@EnableMethodSecurity
@SpringBootApplication
public class QnrBldrApplication {

  public static void main(String[] args) {
    SpringApplication.run(QnrBldrApplication.class, args);
  }
}


问:
How to determine why Bazel external dependencies are always downloaded when running sync using the Intellij Bazel plugin
I'm using Bazel 5.3.0 with the Intellij IDEA plugin. When running sync it's re-downloading things from the WORKSPACE, particularly nodejs packages which is taking a long time. This causes sync to take ~7mins every time it runs, but if I set bazel to not fetch external dependencies it runs in about ~1min. This doesn't occur when running the same bazel commands from the command line.

How do I debug this? I've tried the steps in https://bazel.build/remote/workspace and I've also tried looking at the various logs that bazel produces, however they only really tells me what happened, not why bazel is doing the things it's doing.


问:
Problems to Install Symfony on my ovh webspace :/
I try to install symfony only after i enter my things like database and smtp data then comes an error:

```<code>In Process.php line 143:

  [TypeError]
  Symfony\Component\Process\Process::__construct(): Argument #1 ($command) mu
  st be of type array, string given, called in /home/esbdkig/test.pluginstube
  .net/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Com
  poser/ScriptHandler.php on line 342

Exception trace:
  at phar:///home/esbdkig/composer.phar/vendor/symfony/process/Process.php:143
 Symfony\Component\Process\Process->__construct() at /home/esbdkig/test.pluginstube.net/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:342
 Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeBuildBootstrap() at /home/esbdkig/test.pluginstube.net/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:82
 Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:386
 Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:246
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:107
 Composer\EventDispatcher\EventDispatcher->dispatch() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:226
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:123
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///home/esbdkig/composer.phar/src/Composer/Installer.php:374
 Composer\Installer->run() at phar:///home/esbdkig/composer.phar/src/Composer/Command/CreateProjectCommand.php:263
 Composer\Command\CreateProjectCommand->installProject() at phar:///home/esbdkig/composer.phar/src/Composer/Command/CreateProjectCommand.php:171
 Composer\Command\CreateProjectCommand->execute() at phar:///home/esbdkig/composer.phar/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///home/esbdkig/composer.phar/vendor/symfony/console/Application.php:1028
 Symfony\Component\Console\Application->doRunCommand() at phar:///home/esbdkig/composer.phar/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///home/esbdkig/composer.phar/src/Composer/Console/Application.php:375
 Composer\Console\Application->doRun() at phar:///home/esbdkig/composer.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///home/esbdkig/composer.phar/src/Composer/Console/Application.php:139
 Composer\Console\Application->run() at phar:///home/esbdkig/composer.phar/bin/composer:88
 require() at /home/esbdkig/composer.phar:29

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--ask] [--] [<package> [<directory> [<version>]]]

</code>```

Console IMAGE

Can someone please help me

I have tried to install it as it is described here https://docs.ovh.com/de/hosting/composer-installieren-hosting/](https://docs.ovh.com/de/hosting/composer-installieren-hosting/)

Body:
I try to install symfony only after i enter my things like database and smtp data then comes an error:

In Process.php line 143:

  [TypeError]
  Symfony\Component\Process\Process::__construct(): Argument #1 ($command) mu
  st be of type array, string given, called in /home/esbdkig/test.pluginstube
  .net/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Com
  poser/ScriptHandler.php on line 342

Exception trace:
  at phar:///home/esbdkig/composer.phar/vendor/symfony/process/Process.php:143
 Symfony\Component\Process\Process->__construct() at /home/esbdkig/test.pluginstube.net/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:342
 Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeBuildBootstrap() at /home/esbdkig/test.pluginstube.net/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:82
 Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:386
 Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:246
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:107
 Composer\EventDispatcher\EventDispatcher->dispatch() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:226
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///home/esbdkig/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:123
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///home/esbdkig/composer.phar/src/Composer/Installer.php:374
 Composer\Installer->run() at phar:///home/esbdkig/composer.phar/src/Composer/Command/CreateProjectCommand.php:263
 Composer\Command\CreateProjectCommand->installProject() at phar:///home/esbdkig/composer.phar/src/Composer/Command/CreateProjectCommand.php:171
 Composer\Command\CreateProjectCommand->execute() at phar:///home/esbdkig/composer.phar/vendor/symfony/console/Command/Command.php:298
 Symfony\Component\Console\Command\Command->run() at phar:///home/esbdkig/composer.phar/vendor/symfony/console/Application.php:1028
 Symfony\Component\Console\Application->doRunCommand() at phar:///home/esbdkig/composer.phar/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///home/esbdkig/composer.phar/src/Composer/Console/Application.php:375
 Composer\Console\Application->doRun() at phar:///home/esbdkig/composer.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///home/esbdkig/composer.phar/src/Composer/Console/Application.php:139
 Composer\Console\Application->run() at phar:///home/esbdkig/composer.phar/bin/composer:88
 require() at /home/esbdkig/composer.phar:29

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--ask] [--] [<package> [<directory> [<version>]]]

Console IMAGE

Can someone please help me

I have tried to install it as it is described here https://docs.ovh.com/de/hosting/composer-installieren-hosting/](https://docs.ovh.com/de/hosting/composer-installieren-hosting/)


问:
How should I go about implementing socket-io for notifications on frontend app?
Technical part aside, what is the best way to implement socket-io for notifications? I have a backend that sends unique notifications to each user. Where is the best place to connect to the socket so I only connect once? Should I create a singleton service for it? Should I connect only once after the user logs in?</p>


问:
How to fix position of nodes in Dash Cytoscape while adding and removing nodes through callback?
I want to make a web app with an interactive network graph from the following example data source:

```<code>data = {'Source Node': ['a', 'a', 'b', 'b', 'c'],
     'Destination Node': ['b', 'c', 'c', 'd', 'd'],
     'Link': ['likes', 'likes', 'likes', 'likes', 'dislikes']
    }
</code>```

The desired network graph has the following criteria:

The nodes should be labelled with their name. (done)

The edges should have different colors based on whether 'Link' is 'likes' (green) or 'dislikes' (red). (done through Networkx edge attributes)

The nodes should be draggable by the user. (done - first tried Bokeh and then switched to Dash Cytoscape to make it possible)

The user should be able to select elements in a checklist in order to view only these elements in the network graph. (done in a not so optimal way, see note in the end for more details)

When adding or removing elements through the checklist, the existing nodes should stay in a fixed position, which is not the case by default because a new network graph is created at every callback.

So far, I made a draft app that meets criteria 1 through 4. However, I did not manage to keep the nodes in a fixed position while adding and removing nodes. I will provide more details after showing the code I have so far.

Below is a code that meets criteria 1 through 4.

```<code># Python v 3.9.13
# Importing libraries
import pandas as pd # v 1.4.4
import numpy as np # v 1.21.5
import networkx as nx # v 2.8.8
import dash_cytoscape as cyto # v 0.2.0
from dash import Dash, html, dcc, Input, Output # v 2.7.0

# Data source
data = {'Source Node': ['a', 'a', 'b', 'b', 'c'],
     'Destination Node': ['b', 'c', 'c', 'd', 'd'],
     'Link': ['likes', 'likes', 'likes', 'likes', 'dislikes']
    }

# Creating a DataFrame using Pandas
df = pd.DataFrame(data)

# Defining lists for dcc.Checklist
list_all_ids = ['a', 'b', 'c', 'd']
default_list_selected_ids = ['a', 'c']

# Creating Dash app
app = Dash(__name__)

app.layout = html.Div(
    [
        dcc.Checklist(list_all_ids, default_list_selected_ids, id='checklist-elements'),
        cyto.Cytoscape(
            id='cytoscape_layout',
            elements=[],
            style={"width": "100%", "height": "400px"},
            layout={"name": "preset"},
            stylesheet=[
                {
                    'selector': 'node',
                    'style': {
                        'content': 'data(label)'
                    }
                },
                {
                    'selector': 'edge',
                    'style': {
                        'line-color': 'data(edge_color)'
                    }
                }
            ]
        )
    ]
)

@app.callback(
    Output('cytoscape_layout', 'elements'),
    Input('checklist-elements', 'value')
)
def update_elements(selected_ids):

    # Making a new df
    df_temp = df[df['Source Node'].isin(selected_ids)]
    df_selected = df_temp[df_temp['Destination Node'].isin(selected_ids)]
    # MAKING A NETWORK GRAPH WITH NETWORKX

    # Creating a network graph from the DataFrame
    G = nx.from_pandas_edgelist(df_selected, 'Source Node', 'Destination Node', edge_attr='Link')

    # Setting edge colors (green or red based on whether the nodes "like" or "dislike" each other)
    list_colors = ['red' if a['Link']=='dislikes' else 'green' for u, v, a in G.edges(data=True)]
    dict_colors = {k:v for (k,v) in zip(G.edges(), list_colors)}
    nx.set_edge_attributes(G, dict_colors, 'edge_color')

    pos = nx.spring_layout(G, seed = 100)

    # CONVERTING NETWORKX GRAPH TO CYTOSCAPE FORMAT - Big thanks to Robert Alexander and canbax
    # https://stackoverflow.com/questions/71428375/dash-cytoscape-from-python-networks-graph-not-honouring-the-nodes-coordinates

    # Initial conversion
    cy = nx.cytoscape_data(G)

    # Replacing dictionary key 'value' with 'label' in the nodes list of cy
    for n in cy["elements"]["nodes"]:
        for k, v in n.items():
            v["label"] = v.pop("value")

    # Adding positions of nodes from pos
    SCALING_FACTOR = 100
    for n, p in zip(cy["elements"]["nodes"], pos.values()):
        n["position"] = {"x": int(p[0] * SCALING_FACTOR), "y": int(p[1] * SCALING_FACTOR)}

    elements=cy["elements"]["nodes"] + cy["elements"]["edges"]

    return elements

if __name__ == "__main__":
    app.run_server()
</code>```

As you can see if you run the code and play with the checklist, the nodes get a new position every time you click on a checkbox. This makes sense, since a new network graph is created every time. However, I want the nodes to stick to one position when you select or deselect other nodes. In order to achieve this, I tried two completely different approaches, which were both unsuccessful:

First approach:

Instead of using pos = nx.spring_layout(G, seed = 100), I created a dictionary of predefined positions (np.array() for the positions as it is the type found in  pos = nx.spring_layout(G, seed = 100) (below). I placed this code before defining the app.

```<code>dict_fixed_pos = {'a': np.array([-0.5, -0.5]),
 'b': np.array([-0.5, 0.5]),
 'c': np.array([0.5, 0.5]),
 'd': np.array([0.5, -0.5])}
</code>```

I replaced:

```<code>for n, p in zip(cy["elements"]["nodes"], pos.values()):
        n["position"] = {"x": int(p[0] * SCALING_FACTOR), "y": int(p[1] * SCALING_FACTOR)}
</code>```

with:

```<code>for n in cy["elements"]["nodes"]:
        if n['data']['id'] in selected_ids:
            n['position'] = dict_fixed_pos[n['data']['id']]
</code>```

With this, I was hoping that every time a network graph is created, each given node gets its specified own position from dict_fixed_pos. But instead, all nodes overlap on the same position. It looks like Cytoscape does not recognize the specified positions, but I can't figure out how to solve this. Any idea?

Second approach:

Instead of a callback that adds and removes elements, I tried to see if I could create a callback that changes the style of the nodes. So, the nodes would be invisible by default, and the selected nodes would be set as visible.
As a test to see if this would be possible, I made the following changes in the callback function:

I removed the part that redefines the dataframe, in order to use the original df as such.

Inside the loop:

```<code>for n, p in zip(cy["elements"]["nodes"], pos.values()):
        n["position"] = {"x": int(p[0] * SCALING_FACTOR), "y": int(p[1] * SCALING_FACTOR)}
</code>```

I added the following code in order to add the key 'selected' to each node. The value of 'selected' would be 'yes' or 'no' based on whether the corresponding 'id' is selected in dcc.Checklist:

```<code>if n['data']['id'] in selected_ids:
            n['selected'] = "yes"
        else:
            n['selected'] = "no"
</code>```

And I added the following in the stylesheet of cyto.Cytoscape() (just changing the background color instead of the visibility as I haven't figured out yet how to change the visibility (just seen it is possible):

```<code>{
                    'selector': '[selected = "yes"]',
                    'style': {
                        'background-color': '#FF4136'
                    }
</code>```

However, these changes resulted in all nodes becoming blue (instead of selected nodes becoming red).

So, do you think one of these two approaches could work after making some changes? Or do you have something completely different to suggest? Thank you in advance for your time.

Note on the 4th criterion, being able to add or remove nodes based on a selection in a checklist: initially, I wanted to create a df, network graph and list of elements once, at the start of the app; then, inside the callback function, based on the checklist value, the elements to display would be selected from the list of elements. Because this did not work, I decided to re-create the network graph from scratch in the callback function. However, this is far from ideal, so if anyone knows how to update only the list of elements in the callback function, help would be much appreciated for this as well.

Body:
I want to make a web app with an interactive network graph from the following example data source:

data = {'Source Node': ['a', 'a', 'b', 'b', 'c'],
     'Destination Node': ['b', 'c', 'c', 'd', 'd'],
     'Link': ['likes', 'likes', 'likes', 'likes', 'dislikes']
    }

The desired network graph has the following criteria:

The nodes should be labelled with their name. (done)

The edges should have different colors based on whether 'Link' is 'likes' (green) or 'dislikes' (red). (done through Networkx edge attributes)

The nodes should be draggable by the user. (done - first tried Bokeh and then switched to Dash Cytoscape to make it possible)

The user should be able to select elements in a checklist in order to view only these elements in the network graph. (done in a not so optimal way, see note in the end for more details)

When adding or removing elements through the checklist, the existing nodes should stay in a fixed position, which is not the case by default because a new network graph is created at every callback.

So far, I made a draft app that meets criteria 1 through 4. However, I did not manage to keep the nodes in a fixed position while adding and removing nodes. I will provide more details after showing the code I have so far.

Below is a code that meets criteria 1 through 4.

# Python v 3.9.13
# Importing libraries
import pandas as pd # v 1.4.4
import numpy as np # v 1.21.5
import networkx as nx # v 2.8.8
import dash_cytoscape as cyto # v 0.2.0
from dash import Dash, html, dcc, Input, Output # v 2.7.0

# Data source
data = {'Source Node': ['a', 'a', 'b', 'b', 'c'],
     'Destination Node': ['b', 'c', 'c', 'd', 'd'],
     'Link': ['likes', 'likes', 'likes', 'likes', 'dislikes']
    }

# Creating a DataFrame using Pandas
df = pd.DataFrame(data)

# Defining lists for dcc.Checklist
list_all_ids = ['a', 'b', 'c', 'd']
default_list_selected_ids = ['a', 'c']

# Creating Dash app
app = Dash(__name__)

app.layout = html.Div(
    [
        dcc.Checklist(list_all_ids, default_list_selected_ids, id='checklist-elements'),
        cyto.Cytoscape(
            id='cytoscape_layout',
            elements=[],
            style={"width": "100%", "height": "400px"},
            layout={"name": "preset"},
            stylesheet=[
                {
                    'selector': 'node',
                    'style': {
                        'content': 'data(label)'
                    }
                },
                {
                    'selector': 'edge',
                    'style': {
                        'line-color': 'data(edge_color)'
                    }
                }
            ]
        )
    ]
)

@app.callback(
    Output('cytoscape_layout', 'elements'),
    Input('checklist-elements', 'value')
)
def update_elements(selected_ids):

    # Making a new df
    df_temp = df[df['Source Node'].isin(selected_ids)]
    df_selected = df_temp[df_temp['Destination Node'].isin(selected_ids)]
    # MAKING A NETWORK GRAPH WITH NETWORKX

    # Creating a network graph from the DataFrame
    G = nx.from_pandas_edgelist(df_selected, 'Source Node', 'Destination Node', edge_attr='Link')

    # Setting edge colors (green or red based on whether the nodes "like" or "dislike" each other)
    list_colors = ['red' if a['Link']=='dislikes' else 'green' for u, v, a in G.edges(data=True)]
    dict_colors = {k:v for (k,v) in zip(G.edges(), list_colors)}
    nx.set_edge_attributes(G, dict_colors, 'edge_color')

    pos = nx.spring_layout(G, seed = 100)

    # CONVERTING NETWORKX GRAPH TO CYTOSCAPE FORMAT - Big thanks to Robert Alexander and canbax
    # https://stackoverflow.com/questions/71428375/dash-cytoscape-from-python-networks-graph-not-honouring-the-nodes-coordinates

    # Initial conversion
    cy = nx.cytoscape_data(G)

    # Replacing dictionary key 'value' with 'label' in the nodes list of cy
    for n in cy["elements"]["nodes"]:
        for k, v in n.items():
            v["label"] = v.pop("value")

    # Adding positions of nodes from pos
    SCALING_FACTOR = 100
    for n, p in zip(cy["elements"]["nodes"], pos.values()):
        n["position"] = {"x": int(p[0] * SCALING_FACTOR), "y": int(p[1] * SCALING_FACTOR)}

    elements=cy["elements"]["nodes"] + cy["elements"]["edges"]

    return elements

if __name__ == "__main__":
    app.run_server()

As you can see if you run the code and play with the checklist, the nodes get a new position every time you click on a checkbox. This makes sense, since a new network graph is created every time. However, I want the nodes to stick to one position when you select or deselect other nodes. In order to achieve this, I tried two completely different approaches, which were both unsuccessful:

First approach:

Instead of using pos = nx.spring_layout(G, seed = 100), I created a dictionary of predefined positions (np.array() for the positions as it is the type found in  pos = nx.spring_layout(G, seed = 100) (below). I placed this code before defining the app.

dict_fixed_pos = {'a': np.array([-0.5, -0.5]),
 'b': np.array([-0.5, 0.5]),
 'c': np.array([0.5, 0.5]),
 'd': np.array([0.5, -0.5])}

I replaced:

for n, p in zip(cy["elements"]["nodes"], pos.values()):
        n["position"] = {"x": int(p[0] * SCALING_FACTOR), "y": int(p[1] * SCALING_FACTOR)}

with:

for n in cy["elements"]["nodes"]:
        if n['data']['id'] in selected_ids:
            n['position'] = dict_fixed_pos[n['data']['id']]

With this, I was hoping that every time a network graph is created, each given node gets its specified own position from dict_fixed_pos. But instead, all nodes overlap on the same position. It looks like Cytoscape does not recognize the specified positions, but I can't figure out how to solve this. Any idea?

Second approach:

Instead of a callback that adds and removes elements, I tried to see if I could create a callback that changes the style of the nodes. So, the nodes would be invisible by default, and the selected nodes would be set as visible.
As a test to see if this would be possible, I made the following changes in the callback function:

I removed the part that redefines the dataframe, in order to use the original df as such.

Inside the loop:

for n, p in zip(cy["elements"]["nodes"], pos.values()):
        n["position"] = {"x": int(p[0] * SCALING_FACTOR), "y": int(p[1] * SCALING_FACTOR)}

I added the following code in order to add the key 'selected' to each node. The value of 'selected' would be 'yes' or 'no' based on whether the corresponding 'id' is selected in dcc.Checklist:

if n['data']['id'] in selected_ids:
            n['selected'] = "yes"
        else:
            n['selected'] = "no"

And I added the following in the stylesheet of cyto.Cytoscape() (just changing the background color instead of the visibility as I haven't figured out yet how to change the visibility (just seen it is possible):

{
                    'selector': '[selected = "yes"]',
                    'style': {
                        'background-color': '#FF4136'
                    }

However, these changes resulted in all nodes becoming blue (instead of selected nodes becoming red).

So, do you think one of these two approaches could work after making some changes? Or do you have something completely different to suggest? Thank you in advance for your time.

Note on the 4th criterion, being able to add or remove nodes based on a selection in a checklist: initially, I wanted to create a df, network graph and list of elements once, at the start of the app; then, inside the callback function, based on the checklist value, the elements to display would be selected from the list of elements. Because this did not work, I decided to re-create the network graph from scratch in the callback function. However, this is far from ideal, so if anyone knows how to update only the list of elements in the callback function, help would be much appreciated for this as well.


问:
Softerra LDAP SQL Query for duplicate values failing
I am using Softerra LDAP Browser 4.5 and it is failing on the most basic SQL Query. I cannot figure out any mistakes in the query. I am sure it is correct.

It is throwing an unexpected COUNT error which is super strange as it doesn't make any sense at all.

SELECT COUNT(*) Queries work fine with same ldap path.

I have tried with and without the $ symbol. Didn't help.

Do the Wizards of Stack Overflow see what exactly the problem here might be?

Regards


问:
Why Cannot assign Google DNS adress to Android VPN service only local DNS server?
-In this method i am trying to add google dns server to vpn interface but it doesnt work at all.It
work only local dns which is default dns server of gsm.

@Override
public int onStartCommand(Intent intent, int flags, int startId){
localAddress = CommonMethods.ipStringToInt(ipAddress);

```<code>    packet = new byte[20000];
    ipHeader = new IPHeader(packet, 0);
    tcpHeader = new TCPHeader(packet, 20);
    udpHeader = new UDPHeader(packet, 20);
    dnsBuffer = ((ByteBuffer) ByteBuffer.wrap(packet).position(28)).slice();

    proxy = new Proxy(this, 0);
    proxy.start();
    dnsProxy = new DnsProxy(this);
    dnsProxy.start();

    vpnThread = new Thread(new Runnable(){
        @Override
        public void run(){
            mInterface = builder.setSession("VPNtoSocket")
                    .addAddress(ipAddress,32)
                    .addRoute("0.0.0.0", 0)
                    .addDnsServer("8.8.8.8");
                    //.addRoute("194.163.43.216", 32)
                    .establish();

            FileInputStream vpnin = new FileInputStream(mInterface.getFileDescriptor());
            vpnout = new FileOutputStream(mInterface.getFileDescriptor());

            onStatusChanged(true);

            try{
                int size = 0;
                while(size != -1 && !vpnThread.isInterrupted()){
                    while((size = vpnin.read(packet)) > 0 && !vpnThread.isInterrupted()){
                        if(dnsProxy.isInterrupted() || proxy.isInterrupted()){ //KILL SWITCH
                            vpnin.close();
                            throw new Exception("Server stopped.");
                        }
                        onIPPacketReceived(ipHeader, size);
                    }
                }
            }catch(Exception e){
                e.printStackTrace();
            }finally{
                try{
                    vpnin.close();
                    vpnout.close();
                    if(mInterface != null){
                        mInterface.close();
                        mInterface = null;
                    }

                    kill();
                }catch(Exception e){
                }
            }
        }

    }, "VPNtoSocket");
    vpnThread.start();

    return super.onStartCommand(intent, flags, startId);//START_STICKY;
}
</code>```

Body:
-In this method i am trying to add google dns server to vpn interface but it doesnt work at all.It
work only local dns which is default dns server of gsm.

@Override
public int onStartCommand(Intent intent, int flags, int startId){
localAddress = CommonMethods.ipStringToInt(ipAddress);

    packet = new byte[20000];
    ipHeader = new IPHeader(packet, 0);
    tcpHeader = new TCPHeader(packet, 20);
    udpHeader = new UDPHeader(packet, 20);
    dnsBuffer = ((ByteBuffer) ByteBuffer.wrap(packet).position(28)).slice();

    proxy = new Proxy(this, 0);
    proxy.start();
    dnsProxy = new DnsProxy(this);
    dnsProxy.start();

    vpnThread = new Thread(new Runnable(){
        @Override
        public void run(){
            mInterface = builder.setSession("VPNtoSocket")
                    .addAddress(ipAddress,32)
                    .addRoute("0.0.0.0", 0)
                    .addDnsServer("8.8.8.8");
                    //.addRoute("194.163.43.216", 32)
                    .establish();

            FileInputStream vpnin = new FileInputStream(mInterface.getFileDescriptor());
            vpnout = new FileOutputStream(mInterface.getFileDescriptor());

            onStatusChanged(true);

            try{
                int size = 0;
                while(size != -1 && !vpnThread.isInterrupted()){
                    while((size = vpnin.read(packet)) > 0 && !vpnThread.isInterrupted()){
                        if(dnsProxy.isInterrupted() || proxy.isInterrupted()){ //KILL SWITCH
                            vpnin.close();
                            throw new Exception("Server stopped.");
                        }
                        onIPPacketReceived(ipHeader, size);
                    }
                }
            }catch(Exception e){
                e.printStackTrace();
            }finally{
                try{
                    vpnin.close();
                    vpnout.close();
                    if(mInterface != null){
                        mInterface.close();
                        mInterface = null;
                    }

                    kill();
                }catch(Exception e){
                }
            }
        }

    }, "VPNtoSocket");
    vpnThread.start();

    return super.onStartCommand(intent, flags, startId);//START_STICKY;
}