问:
Out of memory using mpirun and Python subprocess
I am writing a wrapper code in Python to synchronize the execution of multiple applications in a SLURM system.

When using SLURM directly with one application, the job runs without problem.
With the sacct command, I can determine that the maximum memory was (MaxRSS) 8.2 GB out of 96 GB available. The command used in the sbatch file was of the form:

```<code>mpirun -np 4 --map-by ppr:1:node:pe=20 executable
</code>```

Now, if I use a simple Python wrapper and pass python3 simple_wrapper.py, the wrapper being:

```<code>import subprocess
import sys
with open('log', 'w') as out:
    cmd = 'mpirun -np 4 --map-by ppr:1:node:pe=20 executable'
    subprocess.check_call(cmd.split(), bufsize=-1, stdout=out, stderr=subprocess.STDOUT)
</code>```

The executable throws me a problem of memory allocation.
However, checking with sacct the memory allocation is of 5 GB.

Is it a common issue that people have when executing a MPI application on a cluster with  Python3? How to solve that?

Thanks.

Body:
I am writing a wrapper code in Python to synchronize the execution of multiple applications in a SLURM system.

When using SLURM directly with one application, the job runs without problem.
With the sacct command, I can determine that the maximum memory was (MaxRSS) 8.2 GB out of 96 GB available. The command used in the sbatch file was of the form:

mpirun -np 4 --map-by ppr:1:node:pe=20 executable

Now, if I use a simple Python wrapper and pass python3 simple_wrapper.py, the wrapper being:

import subprocess
import sys
with open('log', 'w') as out:
    cmd = 'mpirun -np 4 --map-by ppr:1:node:pe=20 executable'
    subprocess.check_call(cmd.split(), bufsize=-1, stdout=out, stderr=subprocess.STDOUT)

The executable throws me a problem of memory allocation.
However, checking with sacct the memory allocation is of 5 GB.

Is it a common issue that people have when executing a MPI application on a cluster with  Python3? How to solve that?

Thanks.


来源: stackexchange

问:
Python Cubes OLAP Framework - How to sum a json column?
I started using Python Cubes Olap recently.

I'm trying to sum/avg a JSON postgres column, how can i do this?

my db structure:

events

id

object_type

sn_name

spectra

id

snx_wavelengths (json column)

event_id

my json:

```<code>{
    "dimensions": [
        {
            "name": "event",
            "levels": [
                {
                    "name": "object_type",
                    "label": "Object Type",
                    "attributes": [
                        "object_type"
                    ]
                },
                {
                    "name": "sn_name",
                    "label": "name",
                    "attributes": [
                        "sn_name"
                    ]
                }
            ]
        },
        {
            "name": "spectra",
            "levels": [
                {
                    "name": "catalog_name",
                    "label": "Catalog Name",
                    "attributes": [
                        "catalog_name"
                    ]
                },
                {
                    "name": "capture_date",
                    "label": "Capture Date",
                    "attributes": [
                        "capture_date"
                   ]
                }
            ]
        },
        {
            "name": "date"
        }
    ],
    "cubes": [
        {
            "id": "uid",
            "name": "14G31Yx98ZG8aEhFHjOWNNBmFOETg5APjZo5AiHaqog5YxLMK5",
            "dimensions": [
                "event",
                "spectra",
                "date"
            ],
            "aggregates": [
                {
                    "name": "event_snx_wavelengths_sum",
                    "function": "sum",
                    "measure": "event.snx_wavelengths"
                },
                {
                    "name": "record_count",
                    "function": "count"
                }
            ],
            "joins": [
                {
                    "master": "14G31Yx98ZG8aEhFHjOWNNBmFOETg5APjZo5AiHaqog5YxLMK5.id",
                    "detail": "spectra.event_id"
                },
            ],
            "mappings": {
                "event.sn_name": "sn_name",
                "event.object_type": "object_type",
                "spectra.catalog_name": "spectra.catalog_name",
                "spectra.capture_date": "spectra.capture_date",
                "event.snx_wavelengths": "spectra.snx_wavelengths",
                "date": "spectra.capture_date"
            },
        }
    ]
}
</code>```

I'm getting the follow error:

```<code>Unknown attribute ''event.snx_wavelengths''
</code>```

Anyone can help?

I already tried use mongodb to do the sum, i didnt had success.

ContentLicense: CC BY-SA 4.0

Body:
I started using Python Cubes Olap recently.

I'm trying to sum/avg a JSON postgres column, how can i do this?

my db structure:

events

id

object_type

sn_name

spectra

id

snx_wavelengths (json column)

event_id

my json:

{
    "dimensions": [
        {
            "name": "event",
            "levels": [
                {
                    "name": "object_type",
                    "label": "Object Type",
                    "attributes": [
                        "object_type"
                    ]
                },
                {
                    "name": "sn_name",
                    "label": "name",
                    "attributes": [
                        "sn_name"
                    ]
                }
            ]
        },
        {
            "name": "spectra",
            "levels": [
                {
                    "name": "catalog_name",
                    "label": "Catalog Name",
                    "attributes": [
                        "catalog_name"
                    ]
                },
                {
                    "name": "capture_date",
                    "label": "Capture Date",
                    "attributes": [
                        "capture_date"
                   ]
                }
            ]
        },
        {
            "name": "date"
        }
    ],
    "cubes": [
        {
            "id": "uid",
            "name": "14G31Yx98ZG8aEhFHjOWNNBmFOETg5APjZo5AiHaqog5YxLMK5",
            "dimensions": [
                "event",
                "spectra",
                "date"
            ],
            "aggregates": [
                {
                    "name": "event_snx_wavelengths_sum",
                    "function": "sum",
                    "measure": "event.snx_wavelengths"
                },
                {
                    "name": "record_count",
                    "function": "count"
                }
            ],
            "joins": [
                {
                    "master": "14G31Yx98ZG8aEhFHjOWNNBmFOETg5APjZo5AiHaqog5YxLMK5.id",
                    "detail": "spectra.event_id"
                },
            ],
            "mappings": {
                "event.sn_name": "sn_name",
                "event.object_type": "object_type",
                "spectra.catalog_name": "spectra.catalog_name",
                "spectra.capture_date": "spectra.capture_date",
                "event.snx_wavelengths": "spectra.snx_wavelengths",
                "date": "spectra.capture_date"
            },
        }
    ]
}

I'm getting the follow error:

Unknown attribute ''event.snx_wavelengths''

Anyone can help?

I already tried use mongodb to do the sum, i didnt had success.


问:
How do I Access Mediastore.images in Xamarin app
Attempting to write app that retrieves images from local storage (camera roll) on Android Mobile device.  All research suggests using MediaStore.Images to accomplish this.  Unable to get clean compile as keep getting error 'object cannot be found'

This is statement producing error : MediaStore.Images.Media.ExternalContentUri;
Also :

```<code> string path = cursor.GetString(cursor.GetColumnIndex(
                    MediaStore.Images.ImageColumns.Data));
</code>```

Tried declaring separate Interface declaration to no avail
I believe these classes are defined in Android dll which I have reference to.
Very frustrating to a long time C# developer looking to write cross-platform Mobile apps.

looked for sample code on net that would illustrate solution showing exactly how to access/declare/use MediaShow.Images to no avail.
Surprised there does not appear to be a single example of a full solution illustrating its use

Body:
Attempting to write app that retrieves images from local storage (camera roll) on Android Mobile device.  All research suggests using MediaStore.Images to accomplish this.  Unable to get clean compile as keep getting error 'object cannot be found'

This is statement producing error : MediaStore.Images.Media.ExternalContentUri;
Also :

 string path = cursor.GetString(cursor.GetColumnIndex(
                    MediaStore.Images.ImageColumns.Data));

Tried declaring separate Interface declaration to no avail
I believe these classes are defined in Android dll which I have reference to.
Very frustrating to a long time C# developer looking to write cross-platform Mobile apps.

looked for sample code on net that would illustrate solution showing exactly how to access/declare/use MediaShow.Images to no avail.
Surprised there does not appear to be a single example of a full solution illustrating its use


问:
AutoSys Job Running Java Application Does Not Set spring.java.profiles Value
I have a question regarding an Autosys job that I have been picking my head on but could not figure out. So, basically I have this AutoSys job that runs old spring boot application via a script File. When I say old, it uses spring.xml for dependency injection with context.getBean("beadIdFromSpringXml") as the process of generating bean as shown in below code:

```<code># This is spring.xml file context
<context:property-placeholder
     location="classpath:application-${spring.profiles.active}.properties" />

    <bean id="myBean" class="com.example.MyBean">
        <property name="propName1" value="${prop1}"/>
        <property name="propName2" value="${prop2}"/>
    </bean>
</code>```

The bean is generated like example below:

```<code>public static void main(String[] args)
    {
        MyBean beanVariable = (MyBean) context
                .getBean("myBean");
</code>```

Then we have a script file that is run by AutoSys that starts the java project as shown below:

```<code># If I echo ${PROFILE} here I do get "int" in logs
java -Dspring.profiles.active="${PROFILE}" .............
</code>```

When starting the Job, it always ends up in runtime error by saying it cannot create the bean "myBean" cause it cannot find the {prop1}. So my guess is that the ${spring.profiles.active} is not being fetched by the spring boot app correctly. Has anyone faced this error before?

Body:
I have a question regarding an Autosys job that I have been picking my head on but could not figure out. So, basically I have this AutoSys job that runs old spring boot application via a script File. When I say old, it uses spring.xml for dependency injection with context.getBean("beadIdFromSpringXml") as the process of generating bean as shown in below code:

# This is spring.xml file context
<context:property-placeholder
     location="classpath:application-${spring.profiles.active}.properties" />

    <bean id="myBean" class="com.example.MyBean">
        <property name="propName1" value="${prop1}"/>
        <property name="propName2" value="${prop2}"/>
    </bean>

The bean is generated like example below:

public static void main(String[] args)
    {
        MyBean beanVariable = (MyBean) context
                .getBean("myBean");

Then we have a script file that is run by AutoSys that starts the java project as shown below:

# If I echo ${PROFILE} here I do get "int" in logs
java -Dspring.profiles.active="${PROFILE}" .............

When starting the Job, it always ends up in runtime error by saying it cannot create the bean "myBean" cause it cannot find the {prop1}. So my guess is that the ${spring.profiles.active} is not being fetched by the spring boot app correctly. Has anyone faced this error before?


问:
This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php Installation failed
My WordPress site is running on Windows Server 2019. I'm having a hard time on how to change the permissions of my .php files does anyone know how to solve this dilemma? I would really appreciate a helping hand.

I'm not sure if I need to enable the FTP in Server Manager to be able to connect to FTP software like Filezilla. I tried to download an FTP plugin but still it's not working.


问:
How do i split the CJSON parsing or cJSON_Print
I have checked the documentation:
https://github.com/DaveGamble/cJSON#parsing-json and https://github.com/DaveGamble/cJSON#printing-json.

My question is I have a function void foo (char *JSON); that can only accept size_t JSON string representation at a time. The JSON String is larger than size_t.
Either I can parse the full JSON and print it in size_t chunks or I would have to split the JSON string into size_t and sanitize it to retain it in well-formed JSON format.

Is there a CJSON API that could help me in any of the scenarios?


问:
Spark Java Returns 404 For All Endpoints
I have configured this endpoint and many others just like it.  All endpoints return 404.  I packaged my .jar in a kubernetes container.  In the logs, I see "the requested route [/hello] has not been mapped in Spark".  It obviously has, though.

I've been googling like crazy trying to find answers to questions that sort of match.

I know that my server is up and running because it is returning the 404.  I also know that it runs long enough to have created the endpoint because of some additional information that shows up in my logs.

```<code>get("/hello", (req, res) -> {
    res.status(200);
    res.type("text/plain");
    return "Hello, World!  This is DataPeddler v1";
});
</code>```

Body:
I have configured this endpoint and many others just like it.  All endpoints return 404.  I packaged my .jar in a kubernetes container.  In the logs, I see "the requested route [/hello] has not been mapped in Spark".  It obviously has, though.

I've been googling like crazy trying to find answers to questions that sort of match.

I know that my server is up and running because it is returning the 404.  I also know that it runs long enough to have created the endpoint because of some additional information that shows up in my logs.

get("/hello", (req, res) -> {
    res.status(200);
    res.type("text/plain");
    return "Hello, World!  This is DataPeddler v1";
});


问:
Micro-assembly language how to do loop arithmetic shift right
```<code>ixor1   MAR = SP = SP - 1; rd       // takes next to word on stack
ixor2   OPC = TOS                  // OPC is number of bits to shift       2
ixor3   H = MDR                    // H is the number to be shifted       5
// What i need to do is arithmetic shift right value in H by TOS
// for example if my TOS stored in opc is 2 and H = 5 I am trying to do 5 >> 2
// however the architecture only allows arithmetic shift right >> by 1 . I was thinking of just looping
// H = H >> 1   5 times or OPC no. of times how would I implement that ?
ixor4   H = H >> 1
ixor5   MDR = TOS = H; wr; goto Main1  // sets MDR AND TOS as H and goes back to Main code

</code>```

What i need to do is arithmetic shift right value in H by TOS. for example if my TOS stored in opc is 2 and H = 5 I am trying to do 5 >> 2
however the architecture only allows arithmetic shift right >> by 1 . I was thinking of just looping
H = H >> 1   5 times or OPC no. of times how would I implement that ?

Body:
ixor1   MAR = SP = SP - 1; rd       // takes next to word on stack
ixor2   OPC = TOS                  // OPC is number of bits to shift       2
ixor3   H = MDR                    // H is the number to be shifted       5
// What i need to do is arithmetic shift right value in H by TOS
// for example if my TOS stored in opc is 2 and H = 5 I am trying to do 5 >> 2
// however the architecture only allows arithmetic shift right >> by 1 . I was thinking of just looping
// H = H >> 1   5 times or OPC no. of times how would I implement that ?
ixor4   H = H >> 1
ixor5   MDR = TOS = H; wr; goto Main1  // sets MDR AND TOS as H and goes back to Main code

What i need to do is arithmetic shift right value in H by TOS. for example if my TOS stored in opc is 2 and H = 5 I am trying to do 5 >> 2
however the architecture only allows arithmetic shift right >> by 1 . I was thinking of just looping
H = H >> 1   5 times or OPC no. of times how would I implement that ?


问:
"Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009" when running a Hadoop streaming job
This is driving me insane, I kid you not I debugged for like a million times so I can get to this point, but this one I couldn't solve in any way, I'm running a single node cluster, here is the command that I ran:

hadoop jar C:\Hadoop\hadoop-2.9.2\hadoop-streaming-2.9.2.jar -verbose -input /hadoop/data.csv -output /hadoop/output.txt -file C:\Hadoop\hadoop-2.9.2\mapper.py -mapper "python mapper.py" -reducer C:\Hadoop\hadoop-2.9.2\reducer.py

and here is the error:

```<code>22/12/09 01:15:45 WARN streaming.StreamJob: -file option is deprecated, please use generic option -files instead.
packageJobJar: [C:\Hadoop\hadoop-2.9.2\mapper.py, /C:/Users/matsu/AppData/Local/Temp/hadoop-unjar359085693376764278/] [] C:\Users\matsu\AppData\Local\Temp\streamjob5458220146420962625.jar tmpDir=null
22/12/09 01:15:46 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
22/12/09 01:15:47 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
22/12/09 01:15:48 INFO mapred.FileInputFormat: Total input files to process : 1
22/12/09 01:15:48 INFO mapreduce.JobSubmitter: number of splits:2
22/12/09 01:15:48 INFO Configuration.deprecation: yarn.resourcemanager.system-metrics-publisher.enabled is deprecated. Instead, use yarn.system-metrics-publisher.enabled
22/12/09 01:15:48 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1670535169635_0016
22/12/09 01:15:49 INFO impl.YarnClientImpl: Submitted application application_1670535169635_0016
22/12/09 01:15:49 INFO mapreduce.Job: The url to track the job: http://DESKTOP-IAB4BFI:8088/proxy/application_1670535169635_0016/
22/12/09 01:15:49 INFO mapreduce.Job: Running job: job_1670535169635_0016
22/12/09 01:15:56 INFO mapreduce.Job: Job job_1670535169635_0016 running in uber mode : false
22/12/09 01:15:56 INFO mapreduce.Job:  map 0% reduce 0%
22/12/09 01:16:01 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000001_0, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:01 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000000_0, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:06 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000001_1, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:06 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000000_1, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:11 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000001_2, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:12 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000000_2, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:17 INFO mapreduce.Job:  map 100% reduce 100%
22/12/09 01:16:18 INFO mapreduce.Job: Job job_1670535169635_0016 failed with state FAILED due to: Task failed task_1670535169635_0016_m_000001
Job failed as tasks failed. failedMaps:1 failedReduces:0

22/12/09 01:16:18 INFO mapreduce.Job: Counters: 14
        Job Counters
                Failed map tasks=7
                Killed map tasks=1
                Killed reduce tasks=1
                Launched map tasks=8
                Other local map tasks=6
                Data-local map tasks=2
                Total time spent by all maps in occupied slots (ms)=28036
                Total time spent by all reduces in occupied slots (ms)=0
                Total time spent by all map tasks (ms)=28036
                Total vcore-milliseconds taken by all map tasks=28036
                Total megabyte-milliseconds taken by all map tasks=28708864
        Map-Reduce Framework
                CPU time spent (ms)=0
                Physical memory (bytes) snapshot=0
                Virtual memory (bytes) snapshot=0
22/12/09 01:16:18 ERROR streaming.StreamJob: Job not successful!
Streaming Command Failed!
</code>```

When I try running the command with no -mapper argument it works fine, so that means that the script is what's probably the problem, here is my mapper script:

```<code>

import sys

# read input from stdin
for line in sys.stdin:
    # split the input line into user ID, movie ID, and rating
    user_id, movie_id, rating = line.strip().split(",")

    # emit the user ID and movie ID as key-value pairs
    print("{}\t{}".format(user_id, movie_id))
</code>```

I tried removing the first line, changing it, did everything, change what the script does just to test, but it always gives me the same error.
Any miniscule amount of help would be much much appreciated!

Body:
This is driving me insane, I kid you not I debugged for like a million times so I can get to this point, but this one I couldn't solve in any way, I'm running a single node cluster, here is the command that I ran:

hadoop jar C:\Hadoop\hadoop-2.9.2\hadoop-streaming-2.9.2.jar -verbose -input /hadoop/data.csv -output /hadoop/output.txt -file C:\Hadoop\hadoop-2.9.2\mapper.py -mapper "python mapper.py" -reducer C:\Hadoop\hadoop-2.9.2\reducer.py

and here is the error:

22/12/09 01:15:45 WARN streaming.StreamJob: -file option is deprecated, please use generic option -files instead.
packageJobJar: [C:\Hadoop\hadoop-2.9.2\mapper.py, /C:/Users/matsu/AppData/Local/Temp/hadoop-unjar359085693376764278/] [] C:\Users\matsu\AppData\Local\Temp\streamjob5458220146420962625.jar tmpDir=null
22/12/09 01:15:46 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
22/12/09 01:15:47 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
22/12/09 01:15:48 INFO mapred.FileInputFormat: Total input files to process : 1
22/12/09 01:15:48 INFO mapreduce.JobSubmitter: number of splits:2
22/12/09 01:15:48 INFO Configuration.deprecation: yarn.resourcemanager.system-metrics-publisher.enabled is deprecated. Instead, use yarn.system-metrics-publisher.enabled
22/12/09 01:15:48 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1670535169635_0016
22/12/09 01:15:49 INFO impl.YarnClientImpl: Submitted application application_1670535169635_0016
22/12/09 01:15:49 INFO mapreduce.Job: The url to track the job: http://DESKTOP-IAB4BFI:8088/proxy/application_1670535169635_0016/
22/12/09 01:15:49 INFO mapreduce.Job: Running job: job_1670535169635_0016
22/12/09 01:15:56 INFO mapreduce.Job: Job job_1670535169635_0016 running in uber mode : false
22/12/09 01:15:56 INFO mapreduce.Job:  map 0% reduce 0%
22/12/09 01:16:01 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000001_0, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:01 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000000_0, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:06 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000001_1, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:06 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000000_1, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:11 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000001_2, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:12 INFO mapreduce.Job: Task Id : attempt_1670535169635_0016_m_000000_2, Status : FAILED
Error: java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 9009
        at org.apache.hadoop.streaming.PipeMapRed.waitOutputThreads(PipeMapRed.java:325)
        at org.apache.hadoop.streaming.PipeMapRed.mapRedFinished(PipeMapRed.java:538)
        at org.apache.hadoop.streaming.PipeMapper.close(PipeMapper.java:130)
        at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:61)
        at org.apache.hadoop.streaming.PipeMapRunner.run(PipeMapRunner.java:34)
        at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
        at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893)
        at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171)

22/12/09 01:16:17 INFO mapreduce.Job:  map 100% reduce 100%
22/12/09 01:16:18 INFO mapreduce.Job: Job job_1670535169635_0016 failed with state FAILED due to: Task failed task_1670535169635_0016_m_000001
Job failed as tasks failed. failedMaps:1 failedReduces:0

22/12/09 01:16:18 INFO mapreduce.Job: Counters: 14
        Job Counters
                Failed map tasks=7
                Killed map tasks=1
                Killed reduce tasks=1
                Launched map tasks=8
                Other local map tasks=6
                Data-local map tasks=2
                Total time spent by all maps in occupied slots (ms)=28036
                Total time spent by all reduces in occupied slots (ms)=0
                Total time spent by all map tasks (ms)=28036
                Total vcore-milliseconds taken by all map tasks=28036
                Total megabyte-milliseconds taken by all map tasks=28708864
        Map-Reduce Framework
                CPU time spent (ms)=0
                Physical memory (bytes) snapshot=0
                Virtual memory (bytes) snapshot=0
22/12/09 01:16:18 ERROR streaming.StreamJob: Job not successful!
Streaming Command Failed!

When I try running the command with no -mapper argument it works fine, so that means that the script is what's probably the problem, here is my mapper script:

import sys

# read input from stdin
for line in sys.stdin:
    # split the input line into user ID, movie ID, and rating
    user_id, movie_id, rating = line.strip().split(",")

    # emit the user ID and movie ID as key-value pairs
    print("{}\t{}".format(user_id, movie_id))

I tried removing the first line, changing it, did everything, change what the script does just to test, but it always gives me the same error.
Any miniscule amount of help would be much much appreciated!


问:
How to mute scala/spark exceptions from pyspark/python
I want to silence the parquet file exceptions.  The py4j side of things was successfully muted by doing this:

```<code>                logging.getLogger('py4j').setLevel(CRITICAL)
                spark.read.parquet(in_path)
            except Exception as e:
                logging.getLogger('py4j').setLevel(WARN)
</code>```

But then on the jvm side of things we still see the initial exception printed:

```<code>org.apache.spark.SparkException: Exception thrown in awaitResult:
    at org.apache.spark.util.ThreadUtils$.awaitResult(ThreadUtils.scala:301)
    at org.apache.spark.util.ThreadUtils$.parmap(ThreadUtils.scala:375)
    at org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat$.readParquetFootersInParallel(ParquetFileFormat.scala:476)
    at org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat$.$anonfun$mergeSchemasInParallel$1(ParquetFileFormat.scala:522)
    at org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat$.$anonfun$mergeSchemasInParallel$1$adapted(ParquetFileFormat.scala:516)
    at org.apache.spark.sql.execution.datasources.SchemaMergeUtils$.$anonfun$mergeSchemasInParallel$2(SchemaMergeUtils.scala:76)
    at org.apache.spark.rdd.RDD.$anonfun$mapPartitions$2(RDD.scala:855)
    at org.apache.spark.rdd.RDD.$anonfun$mapPartitions$2$adapted(RDD.scala:855)
    at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:365)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:329)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
    at org.apache.spark.scheduler.Task.run(Task.scala:136)
    at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:548)
    at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1504)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:551)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: Could not read footer for file:
</code>```

How can the jvm side be suppressed as well?

Body:
I want to silence the parquet file exceptions.  The py4j side of things was successfully muted by doing this:

                logging.getLogger('py4j').setLevel(CRITICAL)
                spark.read.parquet(in_path)
            except Exception as e:
                logging.getLogger('py4j').setLevel(WARN)

But then on the jvm side of things we still see the initial exception printed:

org.apache.spark.SparkException: Exception thrown in awaitResult:
    at org.apache.spark.util.ThreadUtils$.awaitResult(ThreadUtils.scala:301)
    at org.apache.spark.util.ThreadUtils$.parmap(ThreadUtils.scala:375)
    at org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat$.readParquetFootersInParallel(ParquetFileFormat.scala:476)
    at org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat$.$anonfun$mergeSchemasInParallel$1(ParquetFileFormat.scala:522)
    at org.apache.spark.sql.execution.datasources.parquet.ParquetFileFormat$.$anonfun$mergeSchemasInParallel$1$adapted(ParquetFileFormat.scala:516)
    at org.apache.spark.sql.execution.datasources.SchemaMergeUtils$.$anonfun$mergeSchemasInParallel$2(SchemaMergeUtils.scala:76)
    at org.apache.spark.rdd.RDD.$anonfun$mapPartitions$2(RDD.scala:855)
    at org.apache.spark.rdd.RDD.$anonfun$mapPartitions$2$adapted(RDD.scala:855)
    at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:365)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:329)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
    at org.apache.spark.scheduler.Task.run(Task.scala:136)
    at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:548)
    at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1504)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:551)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: Could not read footer for file:

How can the jvm side be suppressed as well?


问:
I want a pie chart that has lines instead of having the labels inside of the slices
I made a pie chart using MP Chart. The values are inside of the pie pieces, but I want to have lines pointing to each piece of the pie indicating the value. Here is the code that I used to build my pie chart.

The issue I'm having is that there isn't a ton of stuff online about MP Chart and a lot of the stuff that is online is in Java. My code is in Kotlin. Trying to find something in Kotlin. Beginner to developing.

Image of my current Pie Chart

What I want my pie chart to look like

```<code>//***Start Pie Chart Code***//
    val pieChart = binding.pieChart
    // on below line we are setting user percent value,
    // setting description as enabled and offset for pie chart
    pieChart.setUsePercentValues(false)
    pieChart.getDescription().setEnabled(false)
    pieChart.setExtraOffsets(5f, 10f, 5f, 5f)
    // on below line we are setting drag for our pie chart
    pieChart.setDragDecelerationFrictionCoef(0.95f)
    // on below line we are setting hole
    // and hole color for pie chart
    pieChart.setDrawHoleEnabled(true)
    pieChart.setHoleColor(Color.WHITE)
    // on below line we are setting circle color and alpha
    pieChart.setTransparentCircleColor(Color.WHITE)
    pieChart.setTransparentCircleAlpha(110)
    // on  below line we are setting hole radius
    pieChart.setHoleRadius(20f)
    pieChart.setTransparentCircleRadius(5f)
    // on below line we are setting center text
    pieChart.setDrawCenterText(true)
    // on below line we are setting
    // rotation for our pie chart
    pieChart.setRotationAngle(0f)
    // enable rotation of the pieChart by touch
    pieChart.setRotationEnabled(true)
    pieChart.setHighlightPerTapEnabled(true)
    // on below line we are setting animation for our pie chart
    pieChart.animateY(1400, Easing.EaseInOutQuad)
    // on below line we are disabling our legend for pie chart
    pieChart.legend.isEnabled = false
    pieChart.setEntryLabelColor(Color.WHITE)
    pieChart.setEntryLabelTextSize(12f)

    // on below line we are creating array list and
    // adding data to it to display in pie chart
    val entries: ArrayList<PieEntry> = ArrayList()

    entries.add(PieEntry(proteinFloat,"g"))
    entries.add(PieEntry(carbFloat,"g"))
    entries.add(PieEntry(fatFloat,"g"))

    // on below line we are setting pie data set
    val dataSet = PieDataSet(entries, "Mobile OS")

    // on below line we are setting icons.
    dataSet.setDrawIcons(false)

    // on below line we are setting slice for pie
    dataSet.sliceSpace = 3f
    dataSet.iconsOffset = MPPointF(0f, 40f)
    dataSet.selectionShift = 5f

    // add a lot of colors to list
    val colors: ArrayList<Int> = ArrayList()
    colors.add(resources.getColor(R.color.purple_200))
    colors.add(resources.getColor(R.color.blue))
    colors.add(resources.getColor(R.color.red))

    // on below line we are setting colors.
    dataSet.colors = colors

    // on below line we are setting pie data set
    val data = PieData(dataSet)
    data.setValueFormatter(PercentFormatter())
    data.setValueTextSize(15f)
    data.setValueTypeface(Typeface.DEFAULT_BOLD)
    data.setValueTextColor(Color.WHITE)
    pieChart.setData(data)

    // undo all highlights
    pieChart.highlightValues(null)

    // loading chart
    pieChart.invalidate()
    //***End Pie Chart Code***//
</code>```

Body:
I made a pie chart using MP Chart. The values are inside of the pie pieces, but I want to have lines pointing to each piece of the pie indicating the value. Here is the code that I used to build my pie chart.

The issue I'm having is that there isn't a ton of stuff online about MP Chart and a lot of the stuff that is online is in Java. My code is in Kotlin. Trying to find something in Kotlin. Beginner to developing.

Image of my current Pie Chart

What I want my pie chart to look like

//***Start Pie Chart Code***//
    val pieChart = binding.pieChart
    // on below line we are setting user percent value,
    // setting description as enabled and offset for pie chart
    pieChart.setUsePercentValues(false)
    pieChart.getDescription().setEnabled(false)
    pieChart.setExtraOffsets(5f, 10f, 5f, 5f)
    // on below line we are setting drag for our pie chart
    pieChart.setDragDecelerationFrictionCoef(0.95f)
    // on below line we are setting hole
    // and hole color for pie chart
    pieChart.setDrawHoleEnabled(true)
    pieChart.setHoleColor(Color.WHITE)
    // on below line we are setting circle color and alpha
    pieChart.setTransparentCircleColor(Color.WHITE)
    pieChart.setTransparentCircleAlpha(110)
    // on  below line we are setting hole radius
    pieChart.setHoleRadius(20f)
    pieChart.setTransparentCircleRadius(5f)
    // on below line we are setting center text
    pieChart.setDrawCenterText(true)
    // on below line we are setting
    // rotation for our pie chart
    pieChart.setRotationAngle(0f)
    // enable rotation of the pieChart by touch
    pieChart.setRotationEnabled(true)
    pieChart.setHighlightPerTapEnabled(true)
    // on below line we are setting animation for our pie chart
    pieChart.animateY(1400, Easing.EaseInOutQuad)
    // on below line we are disabling our legend for pie chart
    pieChart.legend.isEnabled = false
    pieChart.setEntryLabelColor(Color.WHITE)
    pieChart.setEntryLabelTextSize(12f)

    // on below line we are creating array list and
    // adding data to it to display in pie chart
    val entries: ArrayList<PieEntry> = ArrayList()

    entries.add(PieEntry(proteinFloat,"g"))
    entries.add(PieEntry(carbFloat,"g"))
    entries.add(PieEntry(fatFloat,"g"))

    // on below line we are setting pie data set
    val dataSet = PieDataSet(entries, "Mobile OS")

    // on below line we are setting icons.
    dataSet.setDrawIcons(false)

    // on below line we are setting slice for pie
    dataSet.sliceSpace = 3f
    dataSet.iconsOffset = MPPointF(0f, 40f)
    dataSet.selectionShift = 5f

    // add a lot of colors to list
    val colors: ArrayList<Int> = ArrayList()
    colors.add(resources.getColor(R.color.purple_200))
    colors.add(resources.getColor(R.color.blue))
    colors.add(resources.getColor(R.color.red))

    // on below line we are setting colors.
    dataSet.colors = colors

    // on below line we are setting pie data set
    val data = PieData(dataSet)
    data.setValueFormatter(PercentFormatter())
    data.setValueTextSize(15f)
    data.setValueTypeface(Typeface.DEFAULT_BOLD)
    data.setValueTextColor(Color.WHITE)
    pieChart.setData(data)

    // undo all highlights
    pieChart.highlightValues(null)

    // loading chart
    pieChart.invalidate()
    //***End Pie Chart Code***//


问:
What would cause a JS carousel to not work on iOS & Safari?
I have a carousel that I built for a page based on this guide & it works fine on <s>desktop</s> non-iOS browsers, so not at all on Apple mobile devices (iPhone & iPad). I can't share the URL because of work stuff but the code is essentially the same. This is the first carousel/slideshow like this that I've built from scratch, soo if I'm missing something really obvious, I'm cool with that being pointed out.

I've pasted in a sanitized version of it here, I appreciate any insight in this, I'm just a bit spent at the moment between family holiday drama & working all the time, so a little community assist would do wonders for me atm.

Edit: I thought at first that this was only on mobile devices but I've fired up an old Android phone I had to check it out & it worked fine on it, so when I checked in console on Safari, I saw the following error:

TypeError: null is not an object (evaluating 'slider.lastElementChild')

// Carousel
function slider() {
  let slides = document.querySelectorAll(".slide"),
    slider = document.querySelector(".slider"),
    last = slider.lastElementChild,
    first = slider.firstElementChild,
    btn = document.querySelectorAll(".btn");

  slider.insertBefore(last, first);

  btn.forEach(btn => {
    btn.addEventListener("click", movement);
  });
  setInterval(function()
  {
      movement({target:{id:"next"}});
  }, 3000);
  function movement(e) {
    slider = document.querySelector(".slider");
    last = slider.lastElementChild;
    first = slider.firstElementChild;

    const activeSlide = document.querySelector(".active");

    if (e.target.id === "next") {
      slider.insertBefore(first, last.nextSibling);

      activeSlide.classList.remove("active");
      activeSlide.nextElementSibling.classList.add("active");
    } else {
      slider.insertBefore(last, first);
      activeSlide.classList.remove("active");
      activeSlide.previousElementSibling.classList.add("active");
    }
  }
}
slider();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>    /* JS Carousel https://www.exeideas.com/2022/09/pure-js-infinite-auto-play-slider.html */
    .slider {
      position: relative;
      width: 100vw;
      max-width: 100%;
      height: 550px;
      margin: auto;
      overflow: hidden;
      display: flex;
      align-items: center;
    }

    .slide {
      opacity: 0;
      width: 100%;
      height: auto;
      position: absolute;
      text-align: center;
      -webkit-transition: 2s all;
      transition: 2s all;
    }

    .slide.active {
      opacity:1;
    }

    .slide.active~.slide {
      transiiton: 250ms all;
    }
    .slider__wrapper {
      position: relative;
    }
    .slider_arrow_box{
      position: absolute;
      bottom: 4%;
      left: 45%;
      padding: 3px;
    }
    .slider_arrow_wrapper {
      display: inline-block;
      margin: 0 15px;
      background: blue;
      padding: 7px;
      border-radius: 50%;
      border-style: solid;
      border-width: 1.5px;
      opacity: .6;
    }
    .slider_arrow_wrapper:hover {
        opacity: 1;
    }
    [class*="icono-arrow2"] {
      width: 0;
      height: 0;
      border-width: 6px;
      border-style: solid;
      border-bottom-color: transparent;
      border-left-color: transparent;
      margin: 10px;
    }
    [class*="icono-arrow2"]:before {
      right: 0;
      top: -3px;
      position: absolute;
      height: 4px;
      box-shadow: inset 0 0 0 32px;
      transform: rotate(-45deg);
      width: 15px;
      transform-origin: right top;
    }
    [class*="icono"] {
      position: relative;
      display: inline-block;
      vertical-align: middle;
      color: #fff;
      box-sizing: border-box;
    }
    [class*="icono"]:before,
    [class*="icono"]:after {
      content: "";
      box-sizing: border-box;

    }
    [class*="icono-arrow2"][class*="-left"] {
      transform: rotate(-135deg);
    }
    [class*="icono-arrow2"][class*="-right"] {
      transform: rotate(45deg);
    }
    </code>```

Slide 1

Slide 2

Slide 3

Slide 4

```

Body:
I have a carousel that I built for a page based on this guide & it works fine on <s>desktop</s> non-iOS browsers, so not at all on Apple mobile devices (iPhone & iPad). I can't share the URL because of work stuff but the code is essentially the same. This is the first carousel/slideshow like this that I've built from scratch, soo if I'm missing something really obvious, I'm cool with that being pointed out.

I've pasted in a sanitized version of it here, I appreciate any insight in this, I'm just a bit spent at the moment between family holiday drama & working all the time, so a little community assist would do wonders for me atm.

Edit: I thought at first that this was only on mobile devices but I've fired up an old Android phone I had to check it out & it worked fine on it, so when I checked in console on Safari, I saw the following error:

TypeError: null is not an object (evaluating 'slider.lastElementChild')

// Carousel
function slider() {
  let slides = document.querySelectorAll(".slide"),
    slider = document.querySelector(".slider"),
    last = slider.lastElementChild,
    first = slider.firstElementChild,
    btn = document.querySelectorAll(".btn");

  slider.insertBefore(last, first);

  btn.forEach(btn => {
    btn.addEventListener("click", movement);
  });
  setInterval(function()
  {
      movement({target:{id:"next"}});
  }, 3000);
  function movement(e) {
    slider = document.querySelector(".slider");
    last = slider.lastElementChild;
    first = slider.firstElementChild;

    const activeSlide = document.querySelector(".active");

    if (e.target.id === "next") {
      slider.insertBefore(first, last.nextSibling);

      activeSlide.classList.remove("active");
      activeSlide.nextElementSibling.classList.add("active");
    } else {
      slider.insertBefore(last, first);
      activeSlide.classList.remove("active");
      activeSlide.previousElementSibling.classList.add("active");
    }
  }
}
slider();

    /* JS Carousel https://www.exeideas.com/2022/09/pure-js-infinite-auto-play-slider.html */
    .slider {
      position: relative;
      width: 100vw;
      max-width: 100%;
      height: 550px;
      margin: auto;
      overflow: hidden;
      display: flex;
      align-items: center;
    }

    .slide {
      opacity: 0;
      width: 100%;
      height: auto;
      position: absolute;
      text-align: center;
      -webkit-transition: 2s all;
      transition: 2s all;
    }

    .slide.active {
      opacity:1;
    }

    .slide.active~.slide {
      transiiton: 250ms all;
    }
    .slider__wrapper {
      position: relative;
    }
    .slider_arrow_box{
      position: absolute;
      bottom: 4%;
      left: 45%;
      padding: 3px;
    }
    .slider_arrow_wrapper {
      display: inline-block;
      margin: 0 15px;
      background: blue;
      padding: 7px;
      border-radius: 50%;
      border-style: solid;
      border-width: 1.5px;
      opacity: .6;
    }
    .slider_arrow_wrapper:hover {
        opacity: 1;
    }
    [class*="icono-arrow2"] {
      width: 0;
      height: 0;
      border-width: 6px;
      border-style: solid;
      border-bottom-color: transparent;
      border-left-color: transparent;
      margin: 10px;
    }
    [class*="icono-arrow2"]:before {
      right: 0;
      top: -3px;
      position: absolute;
      height: 4px;
      box-shadow: inset 0 0 0 32px;
      transform: rotate(-45deg);
      width: 15px;
      transform-origin: right top;
    }
    [class*="icono"] {
      position: relative;
      display: inline-block;
      vertical-align: middle;
      color: #fff;
      box-sizing: border-box;
    }
    [class*="icono"]:before,
    [class*="icono"]:after {
      content: "";
      box-sizing: border-box;

    }
    [class*="icono-arrow2"][class*="-left"] {
      transform: rotate(-135deg);
    }
    [class*="icono-arrow2"][class*="-right"] {
      transform: rotate(45deg);
    }

Slide 1

Slide 2

Slide 3

Slide 4


问:
Unhandled exception at 0x00401067 in Project.exe: 0xC0000005: Access violation reading location 0x00407000. at cmp eax,[edx]
I tried to do bubble sort based on this C code. Implement Bubble sort in assembly. Follow the reference C code and translate it to assembly. The implementation requires you exact translation of the reference code, which means you need to implement using local variables, function calls, and parameter passing following the given c code. Submit the source code, screenshot of intermediate steps, and the sorted array in memory window.

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm Links to an external site. that repeatedly steps through the input list element by element, comparing the current element with the one after it, swapping Links to an external site.their values if needed. These passes through the list are repeated until no swaps have to be performed during a pass, meaning that the list has become fully sorted. The algorithm, which is a comparison sort Links to an external site., is named for the way the larger elements "bubble" up to the top of the list.

```<code>// C program for implementation of Bubble sort
#include <stdio.h>

int arr[] = { 5, 1, 4, 2, 8 };

void swap(int* xp, int* yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

// A function to implement bubble sort
void bubbleSort(int arr[], int n)
{
    int i, j;
    for (i = 0; i < n - 1; i++)

        // Last i elements are already in place
        for (j = 0; j < n - i - 1; j++)
            if (arr[j] > arr[j + 1])
                swap(&arr[j], &arr[j + 1]);
}

// Driver program to test above functions
int main()
{
    int n = sizeof(arr) / sizeof(arr[0]);
    bubbleSort(arr, n);
    return 0;
}
</code>```

the code is

myarr DWORD 5,1,4,2,8
.code
elementswap proc
push ebp
mov ebp,esp

```<code> push eax
 push ebx

mov eax,[EBP+8]
mov ebx,[EBP+12]
mov [EBP+8],ebx
mov [EBP+12],eax

pop eax
pop ebx

mov esp,ebp
pop ebp
ret
</code>```

elementswap endp

bubblesort proc
push ebp
mov ebp,esp
mov esi,0
mov ebx,[EBP+8]
sub ebx,1
mov ecx,ebx
mov edx,[EBP+12]

```<code>outerloop:
     cmp esi,ebx; 0 1 2 3 4,4
     JE exit_loop
     sub ecx,esi
     inc esi
     mov edi,0
     JL innerloop

innerloop:
     cmp edi,ecx ;0 1 2 3 4,4 ;0 1 2 3,3;0 1 2,2;0 1,1;0,0
     JGE outerloop
     JL L1

L1:
    mov eax,[edx]
    add edx,4
    cmp eax,[edx]; 0404000,0404004  0404004,0404008  0404008,040400C  040400C,0404011
    JG eleswap ;if eax content is bigger than element of the address stored edx
    JLE L2 ;if eax is less or equal than element of the address stored edx

eleswap:
     push eax
     mov eax,edx
     push eax
     mov eax,[edx]
     call elementswap
     JMP L2

L2:
    inc edi ;increment index innerloop
    JMP innerloop

exit_loop:

mov esp,ebp
pop ebp
ret
</code>```

bubblesort endp

main proc
push ebp
mov ebp,esp

```<code>mov eax,OFFSET myarr
push eax

mov eax,LENGTHOF myarr
push eax

call bubblesort

mov esp,ebp
pop ebp
ret

invoke ExitProcess,0
</code>```

main endp
end main

```<code>

It suppose to sort the array and the elementswap supposed to go back inside the loop but it goes to the bubblesort function
</code>```

Body:
I tried to do bubble sort based on this C code. Implement Bubble sort in assembly. Follow the reference C code and translate it to assembly. The implementation requires you exact translation of the reference code, which means you need to implement using local variables, function calls, and parameter passing following the given c code. Submit the source code, screenshot of intermediate steps, and the sorted array in memory window.

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm Links to an external site. that repeatedly steps through the input list element by element, comparing the current element with the one after it, swapping Links to an external site.their values if needed. These passes through the list are repeated until no swaps have to be performed during a pass, meaning that the list has become fully sorted. The algorithm, which is a comparison sort Links to an external site., is named for the way the larger elements "bubble" up to the top of the list.

// C program for implementation of Bubble sort
#include <stdio.h>

int arr[] = { 5, 1, 4, 2, 8 };

void swap(int* xp, int* yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

// A function to implement bubble sort
void bubbleSort(int arr[], int n)
{
    int i, j;
    for (i = 0; i < n - 1; i++)

        // Last i elements are already in place
        for (j = 0; j < n - i - 1; j++)
            if (arr[j] > arr[j + 1])
                swap(&arr[j], &arr[j + 1]);
}

// Driver program to test above functions
int main()
{
    int n = sizeof(arr) / sizeof(arr[0]);
    bubbleSort(arr, n);
    return 0;
}

the code is

myarr DWORD 5,1,4,2,8
.code
elementswap proc
push ebp
mov ebp,esp

 push eax
 push ebx

mov eax,[EBP+8]
mov ebx,[EBP+12]
mov [EBP+8],ebx
mov [EBP+12],eax

pop eax
pop ebx

mov esp,ebp
pop ebp
ret

elementswap endp

bubblesort proc
push ebp
mov ebp,esp
mov esi,0
mov ebx,[EBP+8]
sub ebx,1
mov ecx,ebx
mov edx,[EBP+12]

outerloop:
     cmp esi,ebx; 0 1 2 3 4,4
     JE exit_loop
     sub ecx,esi
     inc esi
     mov edi,0
     JL innerloop

innerloop:
     cmp edi,ecx ;0 1 2 3 4,4 ;0 1 2 3,3;0 1 2,2;0 1,1;0,0
     JGE outerloop
     JL L1

L1:
    mov eax,[edx]
    add edx,4
    cmp eax,[edx]; 0404000,0404004  0404004,0404008  0404008,040400C  040400C,0404011
    JG eleswap ;if eax content is bigger than element of the address stored edx
    JLE L2 ;if eax is less or equal than element of the address stored edx

eleswap:
     push eax
     mov eax,edx
     push eax
     mov eax,[edx]
     call elementswap
     JMP L2

L2:
    inc edi ;increment index innerloop
    JMP innerloop

exit_loop:

mov esp,ebp
pop ebp
ret

bubblesort endp

main proc
push ebp
mov ebp,esp

mov eax,OFFSET myarr
push eax

mov eax,LENGTHOF myarr
push eax

call bubblesort

mov esp,ebp
pop ebp
ret

invoke ExitProcess,0

main endp
end main

It suppose to sort the array and the elementswap supposed to go back inside the loop but it goes to the bubblesort function


问:
Change in PyQt QDialog Layout Does Not Update Correctly -- bug or my error?
I created a dialog to show two columns of radio buttons with the text for each button obtained from a network server. The button text in one column is static. The other changes. The dialog updates its display to show radio buttons as the dynamic list changes but the update is not correct. Old information remains visible.

My current design uses two QVBoxLayout (staticBox and dynamicBox) for the two columns. For each update, all radio buttons are removed from dynamicBox and deleted, then new radio buttons are added. I confirmed the VBox item count reduced to zero as items were removed and the button widgets are deleted but the update does not work properly. Although the old radio buttons are removed from the VBoxLayout, they continue to display on the dialog along with the new radio buttons.

I reduced my code to an example that replaces the network server with a simple routine that alternately returns one of two lists. I am using Python 3.8.10 with PyQt 5.14.1 (the underlying Qt version is 5.12.8).

The problem can be seen more easily by occasionally resizing the dialog. The dynamic radio buttons from previous iterations remain visible at whatever position they had when first displayed. They also continue to be working buttons whose selection is mutually exclusive.

I added a few print statements and noticed something curious. According to the print, more than one QWidgetItem has the same memory address. I checked for equality between items -- not true -- so is this a bug in how the print is rendered?

I would appreciate any suggestions you may have on how to get this working correctly.

```<code>import sys

from PyQt5 import QtWidgets, QtCore

class SelectDialog(QtWidgets.QDialog):
    def __init__(self, staticList, parent=None):
        super(SelectDialog, self).__init__(parent=parent)
        self.initWidgets(staticList)
        self.app = QtWidgets.QApplication.instance()
        self.initUpdateTimer()

    def initUpdateTimer(self):
        self.toggle = 1
        self.updtTimer = QtCore.QTimer()
        self.updtTimer.setInterval(3000)
        self.updtTimer.timeout.connect(self.updateDynamic)
        self.updtTimer.start()

    def updateDynamic(self):
        # update and show current list of dynamic items
        # save name of any current selection
        selection = None
        for rb in self.dynamicButtonList:
            if rb.isChecked():
                selection = rb.text()
        # clear button list
        self.dynamicButtonList.clear()
        if self.dynamicBox.count() > 1:
            print('\nQWidgetItems in layout box ----------------------------')
            for i in range(self.dynamicBox.count()):
                print('++++', self.dynamicBox.itemAt(i))
            print('\nCompare 0 : 1 ======> {}\n'.
                    format(self.dynamicBox.itemAt(0) == self.dynamicBox.itemAt(1)))
        # remove all items from the box layout
        while self.dynamicBox.count() > 0:
            item = self.dynamicBox.itemAt(0)
            w = item.widget()
            if w is not None:
                print('Removing item {:9}  {}'.format(w.text(), item))
                del w
            else:
                print('Removing item {:9}  {}'.format(' ', item))
            self.dynamicBox.removeItem(item)
            del item
        # get current list of dynamic items
        dynamicList = self.getDynamicList()
        # build widgets for all dynamic items
        if len(dynamicList) > 0:
            dynamicPrompt = QtWidgets.QLabel('Dynamic')
            self.dynamicBox.addWidget(dynamicPrompt)
            self.dynamicBox.addSpacing(10)
            for ex in (dynamicList):
                rb = QtWidgets.QRadioButton(ex, self)
                if selection == ex:
                    # restore previous selection
                    rb.setChecked(True)
                self.dynamicButtonList.append(rb)
                self.dynamicBox.addWidget(rb)
            self.dynamicBox.addStretch()
            self.divLine.setVisible(True)
        else:
            self.divLine.setVisible(False)
        # refresh dialog display
        self.update()
        self.app.processEvents()

    def getDynamicList(self):
        self.toggle = 1 - self.toggle
        if self.toggle == 0:
            return list()
        else:
            return ['Eight', 'Eleven']

    def initWidgets(self, staticList):
        mainBox = QtWidgets.QVBoxLayout()
        #--- static and dynamic
        self.staticButtonList = list()
        self.dynamicButtonList = list()
        hBox = QtWidgets.QHBoxLayout()
        # static
        staticBox = QtWidgets.QVBoxLayout()
        staticPrompt = QtWidgets.QLabel('Static')
        staticBox.addWidget(staticPrompt)
        staticBox.addSpacing(10)
        for itm in staticList:
            rb = QtWidgets.QRadioButton(itm, self)
            self.staticButtonList.append(rb)
            staticBox.addWidget(rb)
        staticBox.addStretch()
        hBox.addStretch()
        hBox.addLayout(staticBox)
        # dynamic
        self.dynamicBox = QtWidgets.QVBoxLayout()
        # insert divider between static and dynamic lists
        self.divLine = QtWidgets.QFrame()
        self.divLine.setFrameStyle(QtWidgets.QFrame.VLine)
        self.divLine.setVisible(False)
        hBox.addWidget(self.divLine)
        hBox.addLayout(self.dynamicBox)
        hBox.addStretch()
        #--- buttons
        btnBox = QtWidgets.QHBoxLayout()
        cmdQuit = QtWidgets.QPushButton('&Quit')
        cmdQuit.clicked.connect(self.reject)
        btnBox.addStretch()
        btnBox.addWidget(cmdQuit)
        btnBox.addStretch()
        #--- complete the layout
        mainBox.addLayout(hBox)
        mainBox.addSpacing(15)
        mainBox.addLayout(btnBox)
        self.setLayout(mainBox)

    def reject(self):
        self.updtTimer.stop()
        super(SelectDialog, self).reject()

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    staticList = ['One', 'Two', 'Three', 'Four']
    sd = SelectDialog(staticList)
    sd.exec_()
    print('\nFINI')
    sys.exit()
</code>```

Body:
I created a dialog to show two columns of radio buttons with the text for each button obtained from a network server. The button text in one column is static. The other changes. The dialog updates its display to show radio buttons as the dynamic list changes but the update is not correct. Old information remains visible.

My current design uses two QVBoxLayout (staticBox and dynamicBox) for the two columns. For each update, all radio buttons are removed from dynamicBox and deleted, then new radio buttons are added. I confirmed the VBox item count reduced to zero as items were removed and the button widgets are deleted but the update does not work properly. Although the old radio buttons are removed from the VBoxLayout, they continue to display on the dialog along with the new radio buttons.

I reduced my code to an example that replaces the network server with a simple routine that alternately returns one of two lists. I am using Python 3.8.10 with PyQt 5.14.1 (the underlying Qt version is 5.12.8).

The problem can be seen more easily by occasionally resizing the dialog. The dynamic radio buttons from previous iterations remain visible at whatever position they had when first displayed. They also continue to be working buttons whose selection is mutually exclusive.

I added a few print statements and noticed something curious. According to the print, more than one QWidgetItem has the same memory address. I checked for equality between items -- not true -- so is this a bug in how the print is rendered?

I would appreciate any suggestions you may have on how to get this working correctly.

import sys

from PyQt5 import QtWidgets, QtCore

class SelectDialog(QtWidgets.QDialog):
    def __init__(self, staticList, parent=None):
        super(SelectDialog, self).__init__(parent=parent)
        self.initWidgets(staticList)
        self.app = QtWidgets.QApplication.instance()
        self.initUpdateTimer()

    def initUpdateTimer(self):
        self.toggle = 1
        self.updtTimer = QtCore.QTimer()
        self.updtTimer.setInterval(3000)
        self.updtTimer.timeout.connect(self.updateDynamic)
        self.updtTimer.start()

    def updateDynamic(self):
        # update and show current list of dynamic items
        # save name of any current selection
        selection = None
        for rb in self.dynamicButtonList:
            if rb.isChecked():
                selection = rb.text()
        # clear button list
        self.dynamicButtonList.clear()
        if self.dynamicBox.count() > 1:
            print('\nQWidgetItems in layout box ----------------------------')
            for i in range(self.dynamicBox.count()):
                print('++++', self.dynamicBox.itemAt(i))
            print('\nCompare 0 : 1 ======> {}\n'.
                    format(self.dynamicBox.itemAt(0) == self.dynamicBox.itemAt(1)))
        # remove all items from the box layout
        while self.dynamicBox.count() > 0:
            item = self.dynamicBox.itemAt(0)
            w = item.widget()
            if w is not None:
                print('Removing item {:9}  {}'.format(w.text(), item))
                del w
            else:
                print('Removing item {:9}  {}'.format(' ', item))
            self.dynamicBox.removeItem(item)
            del item
        # get current list of dynamic items
        dynamicList = self.getDynamicList()
        # build widgets for all dynamic items
        if len(dynamicList) > 0:
            dynamicPrompt = QtWidgets.QLabel('Dynamic')
            self.dynamicBox.addWidget(dynamicPrompt)
            self.dynamicBox.addSpacing(10)
            for ex in (dynamicList):
                rb = QtWidgets.QRadioButton(ex, self)
                if selection == ex:
                    # restore previous selection
                    rb.setChecked(True)
                self.dynamicButtonList.append(rb)
                self.dynamicBox.addWidget(rb)
            self.dynamicBox.addStretch()
            self.divLine.setVisible(True)
        else:
            self.divLine.setVisible(False)
        # refresh dialog display
        self.update()
        self.app.processEvents()

    def getDynamicList(self):
        self.toggle = 1 - self.toggle
        if self.toggle == 0:
            return list()
        else:
            return ['Eight', 'Eleven']

    def initWidgets(self, staticList):
        mainBox = QtWidgets.QVBoxLayout()
        #--- static and dynamic
        self.staticButtonList = list()
        self.dynamicButtonList = list()
        hBox = QtWidgets.QHBoxLayout()
        # static
        staticBox = QtWidgets.QVBoxLayout()
        staticPrompt = QtWidgets.QLabel('Static')
        staticBox.addWidget(staticPrompt)
        staticBox.addSpacing(10)
        for itm in staticList:
            rb = QtWidgets.QRadioButton(itm, self)
            self.staticButtonList.append(rb)
            staticBox.addWidget(rb)
        staticBox.addStretch()
        hBox.addStretch()
        hBox.addLayout(staticBox)
        # dynamic
        self.dynamicBox = QtWidgets.QVBoxLayout()
        # insert divider between static and dynamic lists
        self.divLine = QtWidgets.QFrame()
        self.divLine.setFrameStyle(QtWidgets.QFrame.VLine)
        self.divLine.setVisible(False)
        hBox.addWidget(self.divLine)
        hBox.addLayout(self.dynamicBox)
        hBox.addStretch()
        #--- buttons
        btnBox = QtWidgets.QHBoxLayout()
        cmdQuit = QtWidgets.QPushButton('&Quit')
        cmdQuit.clicked.connect(self.reject)
        btnBox.addStretch()
        btnBox.addWidget(cmdQuit)
        btnBox.addStretch()
        #--- complete the layout
        mainBox.addLayout(hBox)
        mainBox.addSpacing(15)
        mainBox.addLayout(btnBox)
        self.setLayout(mainBox)

    def reject(self):
        self.updtTimer.stop()
        super(SelectDialog, self).reject()

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    staticList = ['One', 'Two', 'Three', 'Four']
    sd = SelectDialog(staticList)
    sd.exec_()
    print('\nFINI')
    sys.exit()


问:
No longer want some of a previous EF Core migration
I have a code-first EF Core project that has been in development for some time. Migrations will eventually run on the current production database, but have not yet.

I have 20+ migrations, and we now realize that some of the changes (e.g. columns dropped) in the 4th migration we don't want to occur.

```<code>1. 20220110_InitialMigration
2. 20200210_GoodMigration
3. 20200210_GoodMigration
4. **20200210_BadMigration**
.
.
.
19. 20200210_GoodMigration
20. 20200210_GoodMigration
</code>```

I started to modify the bad migration in question but stopped as it feels incorrect as the snapshot/designer.cs no longer aligns and I'm not sure if it will come back to bite further down the road.

How can I handle this scenario?

Body:
I have a code-first EF Core project that has been in development for some time. Migrations will eventually run on the current production database, but have not yet.

I have 20+ migrations, and we now realize that some of the changes (e.g. columns dropped) in the 4th migration we don't want to occur.

1. 20220110_InitialMigration
2. 20200210_GoodMigration
3. 20200210_GoodMigration
4. **20200210_BadMigration**
.
.
.
19. 20200210_GoodMigration
20. 20200210_GoodMigration

I started to modify the bad migration in question but stopped as it feels incorrect as the snapshot/designer.cs no longer aligns and I'm not sure if it will come back to bite further down the road.

How can I handle this scenario?


问:
Load Balancer with external check
Could you please advice how to solve the issue below?

I need to balance traffic between the two hosts using the external check. So I need to retrieve two values from the api response every 10 minutes, compare these two values and set traffic to the host, which value from the response is bigger.
Could you please advice how to implement it with Haproxy or Nginx?

Thanks in advance!

Title: Load Balancer with external check


问:
Retrieve Vendor name from Rest API on Add to cart
We are using Woocommerce and we are  trying to retrieve the vendor name for a product that has been added to a cart.
We are using the Cocart plugin to make the RestAPI work.
Our marketplace plugin is Dokan.

That is our code:

```<code>$cart_contents[ $item_key ]['product_author'] = apply_filters( 'cocart_product_author', $_product->getAuthor(), $_product, $cart_item, $item_key );
</code>```

We got the below error

```<code><b>Fatalerror</b>: UncaughtError: CalltoundefinedmethodWC_Product_Simple: : getAuthor()
</code>```

My entire code

```<code>
     * Return cart contents.
     *
     * @access  public
     * @since   2.0.0
     * @version 3.5.0
     * @param   array  $data
     * @param   array  $cart_contents
     * @param   string $cart_item_key
     * @param   bool   $from_session
     * @return  array  $cart_contents
     */
    public function return_cart_contents( $data = array(), $cart_contents = array(), $cart_item_key = '', $from_session = false ) {
        if ( CoCart_Count_Items_Controller::get_cart_contents_count( array( 'return' => 'numeric' ), $cart_contents ) <= 0 || empty( $cart_contents ) ) {
            /**
             * Filter response for empty cart.
             *
             * @since 2.0.8
             */
            $empty_cart = apply_filters( 'cocart_return_empty_cart', array() );

            return $empty_cart;
        }

        $show_thumb = ! empty( $data['thumb'] ) ? $data['thumb'] : false;

        // Find the cart item key in the existing cart.
        if ( ! empty( $cart_item_key ) ) {
            $cart_item_key = $this->find_product_in_cart( $cart_item_key );

            return $cart_contents[ $cart_item_key ];
        }

        foreach ( $cart_contents as $item_key => $cart_item ) {
            // If product data is missing then get product data and apply.
            if ( ! isset( $cart_item['data'] ) ) {
                $cart_item['data']                  = wc_get_product( $cart_item['variation_id'] ? $cart_item['variation_id'] : $cart_item['product_id'] );
                $cart_contents[ $item_key ]['data'] = $cart_item['data'];
            }

            $_product = apply_filters( 'cocart_item_product', $cart_item['data'], $cart_item, $item_key );

            // If product is no longer purchasable then don't return it and notify customer.
            if ( ! $_product->is_purchasable() ) {
                /* translators: %s: product name */
                $message = sprintf( __( '%s has been removed from your cart because it can no longer be purchased. Please contact us if you need assistance.', 'cart-rest-api-for-woocommerce' ), $_product->get_name() );

                /**
                 * Filter message about item removed from the cart.
                 *
                 * @since 2.1.0
                 * @param string     $message Message.
                 * @param WC_Product $_product Product data.
                 */
                $message = apply_filters( 'cocart_cart_item_removed_message', $message, $_product );

                WC()->cart->set_quantity( $item_key, 0 ); // Sets item quantity to zero so it's removed from the cart.

                wc_add_notice( $message, 'error' );
            } else {
                // Adds the product name and title as new variables.
                $cart_contents[ $item_key ]['product_name']  = apply_filters( 'cocart_product_name', $_product->get_name(), $_product, $cart_item, $item_key );
                $cart_contents[ $item_key ]['product_title'] = apply_filters( 'cocart_product_title', $_product->get_title(), $_product, $cart_item, $item_key );
                $cart_contents[ $item_key ]['product_author'] = apply_filters( 'cocart_product_author', $_product->getAuthor(), $_product, $cart_item, $item_key );
</code>```

Body:
We are using Woocommerce and we are  trying to retrieve the vendor name for a product that has been added to a cart.
We are using the Cocart plugin to make the RestAPI work.
Our marketplace plugin is Dokan.

That is our code:

$cart_contents[ $item_key ]['product_author'] = apply_filters( 'cocart_product_author', $_product->getAuthor(), $_product, $cart_item, $item_key );

We got the below error

Fatalerror: UncaughtError: CalltoundefinedmethodWC_Product_Simple: : getAuthor()

My entire code

     * Return cart contents.
     *
     * @access  public
     * @since   2.0.0
     * @version 3.5.0
     * @param   array  $data
     * @param   array  $cart_contents
     * @param   string $cart_item_key
     * @param   bool   $from_session
     * @return  array  $cart_contents
     */
    public function return_cart_contents( $data = array(), $cart_contents = array(), $cart_item_key = '', $from_session = false ) {
        if ( CoCart_Count_Items_Controller::get_cart_contents_count( array( 'return' => 'numeric' ), $cart_contents ) <= 0 || empty( $cart_contents ) ) {
            /**
             * Filter response for empty cart.
             *
             * @since 2.0.8
             */
            $empty_cart = apply_filters( 'cocart_return_empty_cart', array() );

            return $empty_cart;
        }

        $show_thumb = ! empty( $data['thumb'] ) ? $data['thumb'] : false;

        // Find the cart item key in the existing cart.
        if ( ! empty( $cart_item_key ) ) {
            $cart_item_key = $this->find_product_in_cart( $cart_item_key );

            return $cart_contents[ $cart_item_key ];
        }

        foreach ( $cart_contents as $item_key => $cart_item ) {
            // If product data is missing then get product data and apply.
            if ( ! isset( $cart_item['data'] ) ) {
                $cart_item['data']                  = wc_get_product( $cart_item['variation_id'] ? $cart_item['variation_id'] : $cart_item['product_id'] );
                $cart_contents[ $item_key ]['data'] = $cart_item['data'];
            }

            $_product = apply_filters( 'cocart_item_product', $cart_item['data'], $cart_item, $item_key );

            // If product is no longer purchasable then don't return it and notify customer.
            if ( ! $_product->is_purchasable() ) {
                /* translators: %s: product name */
                $message = sprintf( __( '%s has been removed from your cart because it can no longer be purchased. Please contact us if you need assistance.', 'cart-rest-api-for-woocommerce' ), $_product->get_name() );

                /**
                 * Filter message about item removed from the cart.
                 *
                 * @since 2.1.0
                 * @param string     $message Message.
                 * @param WC_Product $_product Product data.
                 */
                $message = apply_filters( 'cocart_cart_item_removed_message', $message, $_product );

                WC()->cart->set_quantity( $item_key, 0 ); // Sets item quantity to zero so it's removed from the cart.

                wc_add_notice( $message, 'error' );
            } else {
                // Adds the product name and title as new variables.
                $cart_contents[ $item_key ]['product_name']  = apply_filters( 'cocart_product_name', $_product->get_name(), $_product, $cart_item, $item_key );
                $cart_contents[ $item_key ]['product_title'] = apply_filters( 'cocart_product_title', $_product->get_title(), $_product, $cart_item, $item_key );
                $cart_contents[ $item_key ]['product_author'] = apply_filters( 'cocart_product_author', $_product->getAuthor(), $_product, $cart_item, $item_key );


问:
Hexo - For post in site.posts not working
Have a Hexo Blog. Been using it for a bit. Wanted to add support for choosing a random post and displaying it.

I have a route/page called 'random', in the index.html file (generated from index.md), I have just javascript. I need to query hexo for every post and get the url to every post. Then I will set the location.href to the url for that post.

I've seen a lot of examples and they seem to use this:

```<code><%
    // Fast array clone
    var posts = site.posts.slice(0);
    posts.sort(function(a, b){
      return a.date < b.date
    });
%>
<% posts.forEach( function(item, i) { %>
    console.log(item.path);
<% } %>
</code>```

or something similar.

This does not work for me. the container is empty as no console.log lines are ever printed out.

Is it not possible to use this markup within a javascript function? How can I do what I'm trying to do?

Body:
Have a Hexo Blog. Been using it for a bit. Wanted to add support for choosing a random post and displaying it.

I have a route/page called 'random', in the index.html file (generated from index.md), I have just javascript. I need to query hexo for every post and get the url to every post. Then I will set the location.href to the url for that post.

I've seen a lot of examples and they seem to use this:

<%
    // Fast array clone
    var posts = site.posts.slice(0);
    posts.sort(function(a, b){
      return a.date
<% posts.forEach( function(item, i) { %>
    console.log(item.path);
<% } %>

or something similar.

This does not work for me. the container is empty as no console.log lines are ever printed out.

Is it not possible to use this markup within a javascript function? How can I do what I'm trying to do?


问:
React is rendering multiple widgets (widgetbot.io) instead of only rendering once
I am trying to implement widgetbot.io into a project of mine and I am running into an issue where react is rendering the widget multiple times.

```<code>function App() {
  async function createWidget() {
    let result = await import("@widgetbot/crate");
    const Crate = await result.cdn();
    new Crate({
      server: "some-random-numbers",
      channel: "some-random-numbers",
    });
  }

  useEffect(() => {
    createWidget();
  }, []);

  return (
    <div className="App">
      {* content here *}
    </div>
  );
}

export default App;

</code>```

I thought that by passing in an empty dependency array useEffect would only run on the initial render?

I did some print debugging and found out that the widget is being rendered twice on initial load.

Does anyone know how I can solve this issue?

Body:
I am trying to implement widgetbot.io into a project of mine and I am running into an issue where react is rendering the widget multiple times.

function App() {
  async function createWidget() {
    let result = await import("@widgetbot/crate");
    const Crate = await result.cdn();
    new Crate({
      server: "some-random-numbers",
      channel: "some-random-numbers",
    });
  }

  useEffect(() => {
    createWidget();
  }, []);

  return (

      {* content here *}

  );
}

export default App;

I thought that by passing in an empty dependency array useEffect would only run on the initial render?

I did some print debugging and found out that the widget is being rendered twice on initial load.

Does anyone know how I can solve this issue?


问:
Nothing being written to file in python
Basically, I'm editing a battleship code so that you can save the board at any point in the game by writing it to a file. However, when I write it to the file, the only thing that is in the file is the word "None". These are the two chunks I've added.

```<code>def save_game():
    with open('savegame.txt', 'w') as f:
        f.write(str(print_board(board, True)))
</code>```

.
.
.
.

```<code>    finally:
        if str(position) == 'save':
            save_game()
            return print_board(board, reveal = False)
            exit()
</code>```

Title: Nothing being written to file in python

Body:
Basically, I'm editing a battleship code so that you can save the board at any point in the game by writing it to a file. However, when I write it to the file, the only thing that is in the file is the word "None". These are the two chunks I've added.

def save_game():
    with open('savegame.txt', 'w') as f:
        f.write(str(print_board(board, True)))

.
.
.
.

    finally:
        if str(position) == 'save':
            save_game()
            return print_board(board, reveal = False)
            exit()


问:
Minimal setup to use vapor/fluent-sqlite-driver, vapor/fluent in a standalone Swift package?
What is the minimal code setup needed to use vapor/fluent-sqlite-driver or vapor/fluent in a standalone Swift executable package?  "Standalone" meaning without the inclusion of Vapor itself.

Basically, what would "Hello World" starters look like for a FluentSQLiteDriver (SQL-like calls) standalone executable package and Fluent (ORM calls) standalone executable package?

Background:

I set out to create two quick & simple packages to tinker with "fluent-sqlite-driver" and  "fluent + fluent-sqlite-driver".  Alas, "quick" did not happen and "simple" remains TBD. Some of the findings:

"The package readmes will show docs on how to use the package standalone" did not happen for Fluent and for the related FluentSQLiteDriver...

"[Docs] Better explanation of how to set up Fluent without Vapor infrastructure #583"

"... a great reference for seeing how to configure Fluent without Vapor. For example: FluentSQLiteDriverTests.swift" leads one on a nugget treasure explorering the depths of things like FluentBenchmark. Not so simple.


问:
When selling Sunshine and Rainbow (SAR) NFTs, does the seller forfeit their reward tokens?
With Sunshine and Rainbows, the novel staking algorithm on Pangolin DEX, users are disincentivized from dumping reward-tokens because the longer they stake, the higher their rewards. The size of their rewards, measured as a % APR, is represented as an NFT that can be traded on the open market.

In PangolinStakingPositions, it seems any 'harvest' action will harvest all rewards and restart staking duration.

When selling that NFT (and ultimately selling the % APR), does the user also forfeit their rewards?


问:
How can I change the color of an object depending on its location and translation without having to add a new material?
I'm trying to make a function where the color of an object changes depending on where it goes within the RGB scale. For example: if it travels in the x axis it will turn red, if it travels in the y axis it will turn green, and if it travels in the z axis it will turn blue.</p>
```<code>positions = (0,-35,3.7), (0, -20, 3.7), (0, 30, 3.7), (0, 100, 30), (0, 200, 60), (0, 300, 120), (0, 350, 250), (0, 400, 400), (0, 400, 500), (0, 400, 700)

camera = (0,-35,3.7), (0, -20, 3.7), (0, 30, 3.7), (0, 100, 30), (0, 200, 60), (0, 300, 120), (0, 350, 250), (0, 400, 400), (0, 400, 500), (0, 400, 700)

# Initialize object references
plane = bpy.data.objects["Plane"]
camera = bpy.data.objects["PlaneCamera"]

# Declare function
    frame_num = 0

    for index,position in enumerate(positions):
        bpy.context.scene.frame_set(frame_num)

        # Record location coords
        plane.location = position
        camera.location = positions_cam[index]

        # Record rotation angles in XYZ Euler
        plane.rotation_euler = (math.radians(rotations[index][0]), math.radians(rotations[index][1]), math.radians(rotations[index][2]))

        # Record keyframes
        plane.keyframe_insert(data_path='location', index=-1)
        plane.keyframe_insert(data_path='rotation_euler', index=-1)
        camera.keyframe_insert(data_path='rotation_euler', index=-1)

        #Record color
        activeObject = bpy.context.active_object #Set active object to variable
        mat = bpy.data.materials.new(name="MaterialName") #set new material to variable
        activeObject.data.materials.append(mat) #add the material to the object
        bpy.context.object.active_material.diffuse_color = (positions[index][0], positions[index][1]/500, positions[index][2]/700) #change color

        frame_num += 10

The record color is where things get into problems as I end up only generating multiple different blank materials.
</code>```

Body:
I'm trying to make a function where the color of an object changes depending on where it goes within the RGB scale. For example: if it travels in the x axis it will turn red, if it travels in the y axis it will turn green, and if it travels in the z axis it will turn blue.

positions = (0,-35,3.7), (0, -20, 3.7), (0, 30, 3.7), (0, 100, 30), (0, 200, 60), (0, 300, 120), (0, 350, 250), (0, 400, 400), (0, 400, 500), (0, 400, 700)

camera = (0,-35,3.7), (0, -20, 3.7), (0, 30, 3.7), (0, 100, 30), (0, 200, 60), (0, 300, 120), (0, 350, 250), (0, 400, 400), (0, 400, 500), (0, 400, 700)

# Initialize object references
plane = bpy.data.objects["Plane"]
camera = bpy.data.objects["PlaneCamera"]

# Declare function
    frame_num = 0

    for index,position in enumerate(positions):
        bpy.context.scene.frame_set(frame_num)

        # Record location coords
        plane.location = position
        camera.location = positions_cam[index]

        # Record rotation angles in XYZ Euler
        plane.rotation_euler = (math.radians(rotations[index][0]), math.radians(rotations[index][1]), math.radians(rotations[index][2]))

        # Record keyframes
        plane.keyframe_insert(data_path='location', index=-1)
        plane.keyframe_insert(data_path='rotation_euler', index=-1)
        camera.keyframe_insert(data_path='rotation_euler', index=-1)

        #Record color
        activeObject = bpy.context.active_object #Set active object to variable
        mat = bpy.data.materials.new(name="MaterialName") #set new material to variable
        activeObject.data.materials.append(mat) #add the material to the object
        bpy.context.object.active_material.diffuse_color = (positions[index][0], positions[index][1]/500, positions[index][2]/700) #change color

        frame_num += 10

The record color is where things get into problems as I end up only generating multiple different blank materials.


问:
Role based Row Level Security for mysql based web applications
I'm trying to figure out how to best implement Role Based RLS (Row Level Security) for a web application that returns paginated results.

Given a web application that has a typical three tier architecture (Front end, back end compute, database).
The database is MySql/Aurora
The Compute is Lambda (Serverless)
Front end is React

Each user is assigned a role (let's say of three possible roles)
User 1    Role A
User 2    Role B
User 3    Role B
User 4    Role C
User 5    Role A
...

Let's say I only have 1 table called 'trans' defined as
COMPANY
DEPARTMENT
CUSTOMER
TRAN_ID

Role access should be
ROLE A see COMPANY 100
ROLE B sees COMPANY 200
ROLE C sees both companies

The table has a billion rows but it's static. No more rows will be added or changed ever. I know this is a unique case and may not matter.

What is considered best practice for implementing row level security?

Option 1 - include the fields in the where clause before making the call to the DB.
The limitation here is, if we decide to add DEPT as a secured field, we'd have to rewrite all of our queries to include that in the where clause

Option 2 - make the call to the database and then strip out the secured records in the result set.
The limitation here is if you're paginating data serverside, you can't always ensure you're getting a full pages of data. The 1st page could be blank ... Also, with a billion records, your compute will likely choke

Option 3 - Bring back everything from the compute layer and subtract at the presentation layer... Not secured and can cause the same issue as option 2

Option 4 - Make the where clause dynamic somehow where you pass in the things it should check based on how the roles are defined. This option seems best, but what is the best practice for storing the roles and constructing the query? I don't want to invent something new.

Is there an Option 5?
What is the best practice?


问:
Vue inject works in other compnents except the root
We are using vue 3 (With Laravel) and  we are using inject

on app.js

```<code>import MainApp from './folder/to/the/app.vue';
const app = createApp(MainApp);
app.mount('#app');

....

app.provide('BLABLA', import.meta.env.BLABLA)
</code>```

on the app.vue

```<code>import { ref, onMounted, inject } from 'vue'
const bla = inject('BLABLA');

console.log(bla); //Getting Undefined
</code>```

Getting warning:

inject() can only be used inside setup() or functional components.

But on other components that is being displayed in <router-view /> The code above is working just fine.

Body:
We are using vue 3 (With Laravel) and  we are using inject

on app.js

import MainApp from './folder/to/the/app.vue';
const app = createApp(MainApp);
app.mount('#app');

....

app.provide('BLABLA', import.meta.env.BLABLA)

on the app.vue

import { ref, onMounted, inject } from 'vue'
const bla = inject('BLABLA');

console.log(bla); //Getting Undefined

Getting warning:

inject() can only be used inside setup() or functional components.

But on other components that is being displayed in <router-view /> The code above is working just fine.