问:
Tensorflow c_api decision forest savedModel loaded but status is not TF_OK
I am using tensorflow decision forests. I trained my model using Python and saved the model with SavedModel format. Then for inference I am trying to load the model in C using tensorflow C_API. I found that for this task I need to load the decision forest inference.so file from Python package.

You can use this command in Debian 10 to install Python package:

pip3 install tensorflow-decision-forests

After that in my program I load the inference.so file using TF_LoadLibrary. Then I load the model using TF_LoadSessionFromSavedModel.

Here is the code

```<code>#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  TF_Graph *Graph = TF_NewGraph();
  TF_Status *Status = TF_NewStatus();
  TF_SessionOptions *SessionOpts = TF_NewSessionOptions();
  TF_Buffer *RunOpts = NULL;
  TF_Library *library;

  library = TF_LoadLibrary("/home/user/.local/lib/python3.7/site-packages/tensorflow_decision_forests/tensorflow/ops/inference/inference.so",
                              Status);

  const char *saved_model_dir = "randomforests-model/";
  const char *tags = "serve";
  int ntags = 1;

  TF_Session *Session = TF_LoadSessionFromSavedModel(
      SessionOpts, RunOpts, saved_model_dir, &tags, ntags, Graph, NULL, Status);

  printf("status: %s\n", TF_Message(Status));

  if(TF_GetCode(Status) == TF_OK) {
    printf("loaded\n");
  }else{
    printf("not loaded\n");
  }

  return 0;
}
</code>```

Output

```<code>$ gcc -g main.c -ltensorflow -o main.out
user@debian:/home/code/tftest$ ./main.out
Hello from TensorFlow C library version 2.7.0-dev20211101
2022-01-22 19:39:28.539621: I tensorflow/cc/saved_model/reader.cc:43] Reading SavedModel from: randomforests-mtproto-model-001028/
2022-01-22 19:39:28.547223: I tensorflow/cc/saved_model/reader.cc:107] Reading meta graph with tags { serve }
2022-01-22 19:39:28.547792: I tensorflow/cc/saved_model/reader.cc:148] Reading SavedModel debug info (if present) from: randomforests-mtproto-model-001028/
2022-01-22 19:39:28.548298: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-01-22 19:39:28.598841: I tensorflow/cc/saved_model/loader.cc:210] Restoring SavedModel bundle.
2022-01-22 19:39:28.743885: I tensorflow/cc/saved_model/loader.cc:194] Running initialization op on SavedModel bundle at path: randomforests-mtproto-model-001028/
[INFO kernel.cc:1153] Loading model from path
[INFO decision_forest.cc:617] Model loaded with 300 root(s), 618972 node(s), and 28 input feature(s).
[INFO abstract_model.cc:1063] Engine "RandomForestOptPred" built
[INFO kernel.cc:1001] Use fast generic engine
2022-01-22 19:39:30.922861: I tensorflow/cc/saved_model/loader.cc:283] SavedModel load for tags { serve }; Status: success: OK. Took 2383248 microseconds.

status: No shape inference function exists for op 'SimpleMLLoadModelFromPathWithHandle', did you forget to define it?
not loaded
</code>```

The problem is that the function output is telling that the model is loading with Status: success: OK but the Status variable is no equal to TF_OK and the related message is No shape inference function exists for op 'SimpleMLLoadModelFromPathWithHandle', did you forget to define it?

So how can I load the model in the right way?

答:
After a long time and didn't get an answer, I asked the question in the TensorFlow's forum and get the answer.
It seems that the current version of TensorFlow has a problem with loading decision forests with C_API. So we can use the Yggdrasil library as discussed in the answer.

Body:
I am using tensorflow decision forests. I trained my model using Python and saved the model with SavedModel format. Then for inference I am trying to load the model in C using tensorflow C_API. I found that for this task I need to load the decision forest inference.so file from Python package.

You can use this command in Debian 10 to install Python package:

pip3 install tensorflow-decision-forests

After that in my program I load the inference.so file using TF_LoadLibrary. Then I load the model using TF_LoadSessionFromSavedModel.

Here is the code

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  TF_Graph *Graph = TF_NewGraph();
  TF_Status *Status = TF_NewStatus();
  TF_SessionOptions *SessionOpts = TF_NewSessionOptions();
  TF_Buffer *RunOpts = NULL;
  TF_Library *library;

  library = TF_LoadLibrary("/home/user/.local/lib/python3.7/site-packages/tensorflow_decision_forests/tensorflow/ops/inference/inference.so",
                              Status);

  const char *saved_model_dir = "randomforests-model/";
  const char *tags = "serve";
  int ntags = 1;

  TF_Session *Session = TF_LoadSessionFromSavedModel(
      SessionOpts, RunOpts, saved_model_dir, &tags, ntags, Graph, NULL, Status);

  printf("status: %s\n", TF_Message(Status));

  if(TF_GetCode(Status) == TF_OK) {
    printf("loaded\n");
  }else{
    printf("not loaded\n");
  }

  return 0;
}

Output

$ gcc -g main.c -ltensorflow -o main.out
user@debian:/home/code/tftest$ ./main.out
Hello from TensorFlow C library version 2.7.0-dev20211101
2022-01-22 19:39:28.539621: I tensorflow/cc/saved_model/reader.cc:43] Reading SavedModel from: randomforests-mtproto-model-001028/
2022-01-22 19:39:28.547223: I tensorflow/cc/saved_model/reader.cc:107] Reading meta graph with tags { serve }
2022-01-22 19:39:28.547792: I tensorflow/cc/saved_model/reader.cc:148] Reading SavedModel debug info (if present) from: randomforests-mtproto-model-001028/
2022-01-22 19:39:28.548298: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-01-22 19:39:28.598841: I tensorflow/cc/saved_model/loader.cc:210] Restoring SavedModel bundle.
2022-01-22 19:39:28.743885: I tensorflow/cc/saved_model/loader.cc:194] Running initialization op on SavedModel bundle at path: randomforests-mtproto-model-001028/
[INFO kernel.cc:1153] Loading model from path
[INFO decision_forest.cc:617] Model loaded with 300 root(s), 618972 node(s), and 28 input feature(s).
[INFO abstract_model.cc:1063] Engine "RandomForestOptPred" built
[INFO kernel.cc:1001] Use fast generic engine
2022-01-22 19:39:30.922861: I tensorflow/cc/saved_model/loader.cc:283] SavedModel load for tags { serve }; Status: success: OK. Took 2383248 microseconds.

status: No shape inference function exists for op 'SimpleMLLoadModelFromPathWithHandle', did you forget to define it?
not loaded

The problem is that the function output is telling that the model is loading with Status: success: OK but the Status variable is no equal to TF_OK and the related message is No shape inference function exists for op 'SimpleMLLoadModelFromPathWithHandle', did you forget to define it?

So how can I load the model in the right way?


来源: stackexchange

问:
Problem with validation: if I click one input it will show error in the another input
I really stuck up. I have a problem with my validation scheme. When I clicking on password field it shows an error also in the new password field. Validation scheme looks like right, but maybe I have missed something. So, this is my form:

And when I focusing field with current password error also is appearing inside the new password field. This is my code:

```<code>
import React, { useState } from "react";
import { useFormik } from "formik";
import { useSelector } from "react-redux";

import { UserPasswordChangeSchema } from "common/types/user/userPasswordChangeSchema.type";
import { InputText, Button } from "../../components/common/index";
import { passChange } from "helpers/passChange";

import './SecurityPage.css'
import { Redirect } from "react-router-dom";

export const SecurityPage: React.FC = () => {
    const email = useSelector((state: any) => state.userprofile.profile ? state.userprofile.profile.email : null)
    const [makeRedirect, setMakeRedirect] = useState<boolean>(false);

    const formik = useFormik(
        {
            initialValues: {
                oldPassword: '',
                password: '',
                passwordConfirm: ''
            },
            onSubmit: async values => {
                if (
                    await passChange({
                        email,
                        oldPassword: values.oldPassword,
                        newPassword: values.passwordConfirm
                    })
                ) {
                    setMakeRedirect(true);
                }

            },
            validationSchema: UserPasswordChangeSchema
        }
    )

    if (makeRedirect) {
        return <Redirect to='/' />;
    }

    console.log(formik.touched)

    return (
        <div className="security">
            <div className="security-info">
                <h1 className="security-info-header">Security</h1>
                <h2 className="security-info-subheader">Here you can change your password.</h2>
            </div>
            <form action="" className="security-form" onSubmit={formik.handleSubmit}>
                <InputText
                    name={"Current password"}
                    propName={"oldPassword"}
                    value={formik.values.oldPassword}
                    isPassword={true}
                    onChange={formik.handleChange}
                    onBlur={formik.handleBlur}
                    touched={formik.touched.oldPassword}
                    errorMsg={formik.errors.oldPassword}
                    width={451}
                />
                <InputText
                    name={"New password"}
                    propName={"password"}
                    value={formik.values.password}
                    isPassword={true}
                    onChange={formik.handleChange}
                    onBlur={formik.handleBlur}
                    touched={formik.touched.password}
                    errorMsg={formik.errors.password}
                    width={451}
                />
                <InputText
                    name={"Confirm new password"}
                    propName={"passwordConfirm"}
                    value={formik.values.passwordConfirm}
                    isPassword={true}
                    onChange={formik.handleChange}
                    onBlur={formik.handleBlur}
                    touched={formik.touched.passwordConfirm}
                    errorMsg={formik.errors.passwordConfirm}
                    width={451}
                />
                <Button
                    isSubmit={true}
                    primary={true}
                    width={'451px'}
                    textCenter={true}>
                    Save
                </Button>
            </form>
        </div>
    )
}
</code>```

And validation scheme:

```<code>import * as Yup from 'yup';

const UserPasswordChangeSchema = Yup.object({
    oldPassword: Yup.string()
        .trim()
        .required("Password is required"),
    password: Yup.string()
        .trim()
        .required("New password is required")
        .min(8, "The password must contain 8 - 24 characters")
        .max(24, "The password must contain 8 - 24 characters"),
    passwordConfirm: Yup.string()
        .trim()
        .oneOf([Yup.ref("password"), null], "Passwords must match")
});

export { UserPasswordChangeSchema }

</code>```

I wiil be very appreciated for your help

答:
Try to import the Field and ErrorMessage component from Formik

```<code>import { Field, ErrorMessage } from 'formik';
</code>```

and replace the InputText for this new Field something like:

```<code><Field
 placeHolder={"Current password"}
 type="password"
 name="oldPassword"
 className="form-control"
 value={formik.values.oldPassword}
/>
<ErrorMessage name="oldPassword" />
</code>```

and repeat for the others inputs but changes the data.

ContentLicense: CC BY-SA 4.0

Body:
I really stuck up. I have a problem with my validation scheme. When I clicking on password field it shows an error also in the new password field. Validation scheme looks like right, but maybe I have missed something. So, this is my form:

And when I focusing field with current password error also is appearing inside the new password field. This is my code:

import React, { useState } from "react";
import { useFormik } from "formik";
import { useSelector } from "react-redux";

import { UserPasswordChangeSchema } from "common/types/user/userPasswordChangeSchema.type";
import { InputText, Button } from "../../components/common/index";
import { passChange } from "helpers/passChange";

import './SecurityPage.css'
import { Redirect } from "react-router-dom";

export const SecurityPage: React.FC = () => {
    const email = useSelector((state: any) => state.userprofile.profile ? state.userprofile.profile.email : null)
    const [makeRedirect, setMakeRedirect] = useState<boolean>(false);

    const formik = useFormik(
        {
            initialValues: {
                oldPassword: '',
                password: '',
                passwordConfirm: ''
            },
            onSubmit: async values => {
                if (
                    await passChange({
                        email,
                        oldPassword: values.oldPassword,
                        newPassword: values.passwordConfirm
                    })
                ) {
                    setMakeRedirect(true);
                }

            },
            validationSchema: UserPasswordChangeSchema
        }
    )

    if (makeRedirect) {
        return <Redirect to='/' />;
    }

    console.log(formik.touched)

    return (

Security

Here you can change your password.

            <form action="" className="security-form" onSubmit={formik.handleSubmit}>
                <InputText
                    name={"Current password"}
                    propName={"oldPassword"}
                    value={formik.values.oldPassword}
                    isPassword={true}
                    onChange={formik.handleChange}
                    onBlur={formik.handleBlur}
                    touched={formik.touched.oldPassword}
                    errorMsg={formik.errors.oldPassword}
                    width={451}
                />
                <InputText
                    name={"New password"}
                    propName={"password"}
                    value={formik.values.password}
                    isPassword={true}
                    onChange={formik.handleChange}
                    onBlur={formik.handleBlur}
                    touched={formik.touched.password}
                    errorMsg={formik.errors.password}
                    width={451}
                />
                <InputText
                    name={"Confirm new password"}
                    propName={"passwordConfirm"}
                    value={formik.values.passwordConfirm}
                    isPassword={true}
                    onChange={formik.handleChange}
                    onBlur={formik.handleBlur}
                    touched={formik.touched.passwordConfirm}
                    errorMsg={formik.errors.passwordConfirm}
                    width={451}
                />
                <Button
                    isSubmit={true}
                    primary={true}
                    width={'451px'}
                    textCenter={true}>
                    Save
                </Button>
            </form>

    )
}

And validation scheme:

import * as Yup from 'yup';

const UserPasswordChangeSchema = Yup.object({
    oldPassword: Yup.string()
        .trim()
        .required("Password is required"),
    password: Yup.string()
        .trim()
        .required("New password is required")
        .min(8, "The password must contain 8 - 24 characters")
        .max(24, "The password must contain 8 - 24 characters"),
    passwordConfirm: Yup.string()
        .trim()
        .oneOf([Yup.ref("password"), null], "Passwords must match")
});

export { UserPasswordChangeSchema }

I wiil be very appreciated for your help

Body:
Try to import the Field and ErrorMessage component from Formik

import { Field, ErrorMessage } from 'formik';

and replace the InputText for this new Field something like:

<Field
 placeHolder={"Current password"}
 type="password"
 name="oldPassword"
 className="form-control"
 value={formik.values.oldPassword}
/>
<ErrorMessage name="oldPassword" />

and repeat for the others inputs but changes the data.


问:
How to remove intermediate images from a build after the build?
When you build your multi-stage Dockerfile with

```<code>docker build -t myimage .
</code>```

it produces the final image tagged myimage, and also intermediate images. To be completely clear we are talking here not about containers, but about images. It looks like this:

See these <none> images? These are what I'm talking about.

Now this "issue" has been discussed to some extent here and here.

Here are some relevant parts:

If these intermediate images would be purged/pruned automatically, the build cache would be gone with each build, therefore forcing you to rebuild the entire image each time.

So okay, it does not make sense to prune then automatically.

Some people do this:

For now, I'm using docker image prune -f after my docker build -t app . command to cleanup those intermediate images.

But unfortunately this is not something I can do. As one discussion participant commented:

It removes "all dangling images", so in shared environments (like Jenkins slave) it's more akin to shooting oneself in the foot. :)

And this is a scenario I found myself in.

So nothing to be "fixed" on Docker side. But how can I remove those extra images, from a single particular build only?

Update

After reading very nice answer from d4nyll below, which is a big step forward, I'd like to add some more constraints to the question ;) First, let me sum up the answer:

One can use ARG to pass a build id from CI/CD to Dockerfile builder

Then one can use LABEL syntax to add build id metadata to the stage images being built

Then one can use the --filter option of docker image prune command to remove only the images with the current build id

This is a big step forward, but I'm still struggling into how to fit it into my usage scenario without adding unnecessary complexity.

In my case a requirement is that application developers who author the Dockerfiles and check them into the source control system are responsible for making sure that their Dockerfiles build the image to their satisfaction. They are not required to craft all their Dockerfiles in a specific way, "so our CI/CD process does not break". They simply have to provide a Dockerfile that produce correct docker image.

Thus, I'm not really in a position to request them to add stuff in the Dockerfile for every single application, just for the sake of CI/CD pipeline. This is something that CI/CD pipeline is expected to handle all by itself.

The only way I can see making this work is to write a Dockerfile parser, that will detect multi-staged build and inject a label per stage and then build that modified Dockerfile. This is a complexity that I'm very hesitant to add to the CI/CD pipeline.

Do I have a better (read simpler) options?

答:
Please use the below command for deleting all intermediate images:</p>
```<code>docker rmi $(docker images -a|grep "<none>"|awk '$1=="<none>" {print $3}')
</code>```

Body:
When you build your multi-stage Dockerfile with

docker build -t myimage .

it produces the final image tagged myimage, and also intermediate images. To be completely clear we are talking here not about containers, but about images. It looks like this:

See these <none> images? These are what I'm talking about.

Now this "issue" has been discussed to some extent here and here.

Here are some relevant parts:

If these intermediate images would be purged/pruned automatically, the build cache would be gone with each build, therefore forcing you to rebuild the entire image each time.

So okay, it does not make sense to prune then automatically.

Some people do this:

For now, I'm using docker image prune -f after my docker build -t app . command to cleanup those intermediate images.

But unfortunately this is not something I can do. As one discussion participant commented:

It removes "all dangling images", so in shared environments (like Jenkins slave) it's more akin to shooting oneself in the foot. :)

And this is a scenario I found myself in.

So nothing to be "fixed" on Docker side. But how can I remove those extra images, from a single particular build only?

Update

After reading very nice answer from d4nyll below, which is a big step forward, I'd like to add some more constraints to the question ;) First, let me sum up the answer:

One can use ARG to pass a build id from CI/CD to Dockerfile builder

Then one can use LABEL syntax to add build id metadata to the stage images being built

Then one can use the --filter option of docker image prune command to remove only the images with the current build id

This is a big step forward, but I'm still struggling into how to fit it into my usage scenario without adding unnecessary complexity.

In my case a requirement is that application developers who author the Dockerfiles and check them into the source control system are responsible for making sure that their Dockerfiles build the image to their satisfaction. They are not required to craft all their Dockerfiles in a specific way, "so our CI/CD process does not break". They simply have to provide a Dockerfile that produce correct docker image.

Thus, I'm not really in a position to request them to add stuff in the Dockerfile for every single application, just for the sake of CI/CD pipeline. This is something that CI/CD pipeline is expected to handle all by itself.

The only way I can see making this work is to write a Dockerfile parser, that will detect multi-staged build and inject a label per stage and then build that modified Dockerfile. This is a complexity that I'm very hesitant to add to the CI/CD pipeline.

Do I have a better (read simpler) options?

Body:
Please use the below command for deleting all intermediate images:

docker rmi $(docker images -a|grep "<none>"|awk '$1=="<none>" {print $3}')


问:
Azure Data Factory Pagination with offset
I have a project scenario to get all users from an endpoint URL and insert it to a SQL table, I am using ADF Pipeline but I'm having some issues with pagination, I have used before pagination but only with nextpage:"someurl" using AbsoluteUrl but now I am having issues because my response comes as follow and for me to get next pages I need to perform multiple calls as follow.

What I have tried, created a for-each loop and iterate through using range but it gives me duplicates of the first call in an infinite loop and does not take the next 500 records, following this solution example here.

https://learn.microsoft.com/en-us/answers/questions/468561/azure-data-factory-pagination-issue.html#answer-470345

BaseURL: https://xyz.xyz.com/api/v2/users?take=500 which gives me the first 500
Response:

```<code>> ],
"total": 3059,
"next": 500
}
</code>```

In order for me to take the next 500 rows, I need to make requests as follow

https://xyz.xyz.com/api/v2/users?take=500&skip=500

https://xyz.xyz.com/api/v2/users?take=500&skip=1000

https://xyz.xyz.com/api/v2/users?take=500&skip=1500

And so on...
Note skip workes as offset in my case and I have 36000 rows to fetch.

Could you give me any recommendations on how to approach this?
Thank You in advance.

答:
Please check if below solution works,

Define a variable in the main pipeline let's say offset with value 0

Inside Until activity

a. have a web call with dynamic content as below -
@concat('https://xyz.xyz.com/api/v2/users?take=500&skip=',variables('offset'))

b. Perform required operation on data - like writing response to ADLS

c. use "set variable" activity to increase offset value by 500.

Use proper expression in your Until loop when to exit, there are number of ways to do that, below is one of the approaches -
just set a variable when you get zero records in your web call response, in your case - https://xyz.xyz.com/api/v2/users?take=500&skip=36000
use this variable in until expression.

Body:
I have a project scenario to get all users from an endpoint URL and insert it to a SQL table, I am using ADF Pipeline but I'm having some issues with pagination, I have used before pagination but only with nextpage:"someurl" using AbsoluteUrl but now I am having issues because my response comes as follow and for me to get next pages I need to perform multiple calls as follow.

What I have tried, created a for-each loop and iterate through using range but it gives me duplicates of the first call in an infinite loop and does not take the next 500 records, following this solution example here.

https://learn.microsoft.com/en-us/answers/questions/468561/azure-data-factory-pagination-issue.html#answer-470345

BaseURL: https://xyz.xyz.com/api/v2/users?take=500 which gives me the first 500
Response:

> ],
"total": 3059,
"next": 500
}

In order for me to take the next 500 rows, I need to make requests as follow

https://xyz.xyz.com/api/v2/users?take=500&skip=500

https://xyz.xyz.com/api/v2/users?take=500&skip=1000

https://xyz.xyz.com/api/v2/users?take=500&skip=1500

And so on...
Note skip workes as offset in my case and I have 36000 rows to fetch.

Could you give me any recommendations on how to approach this?
Thank You in advance.


问:
How to update values in a complicated JSON Array using Jackson?
I have a request body (in JSON format) that looks like this:

```<code>[
  {
    "l_ts":0,
    "af":{
      "lib":"xyz",
      "OS":"abc",
      "wdt":"2.63",
    },
    "frs":false,
    "g":"-v4d89ae6885b14baf91b102caaefea245",
    "tlc":[],
    "type":"meta",
  },
  {
    "s":1643895073,
    "evtName":"CONTENT_LIKE_DISLIKE",
    "evtData":{
      "contentId":17189,
      "likeContent":true,
    },
    "type":"event",
    "n":"_bg"
  }
]
</code>```

Now before sending the request, I need to update the value of "contentId" field. I am using Jackson in my current project, so what would be the best way to update the "contentId" field in the JSON above.

This is what I have tried till now:

```<code>ObjectMapper om = new ObjectMapper();
JsonNode requestBody = om.readTree(new File(pathToJsonAbove));
JsonNode requestBodyNode = requestBody.get(1);
requestBodyNode = JsonUtil.put(requestBodyNode, "evtData", "contentId", newValue);
requestBody = JsonUtil.put(requestBody, "[1]", requestBodyNode); // getting error here
</code>```

The JsonUtil functions are as below:

```<code>public static final JsonNode put(JsonNode node, String key1, String key2, int value) {
    JsonNode jsonNode = node.path(key1);
         put(jsonNode, key2, value);
         return node;
}

public static final JsonNode put(JsonNode node, String key, int value) {
    return ((ObjectNode)node).put(key, value);
}

public static final JsonNode put(JsonNode node, String key, JsonNode value) {
    return ((ObjectNode)node).putPOJO(key, value);
}
</code>```

I am not able to successfully put the node that I have edited (requestBodyNode), back in the requestBody which is the main JsonNode that holds the entire body. When I run the above code, I get a ClassCastException saying that I can't convert from ArrayNode to ObjectNode.

What is the best way to update the "contentId" field in the JSON above?

答:
If you have to update just the contentId field you can identify the parent node of the contentId node and modify the child (moreover basically you have already made more than that with the creation of your function throwing the error) :

```<code>ObjectMapper om = new ObjectMapper();
JsonNode requestBody = om.readTree(json);
JsonNode requestBodyNode = requestBody.get(1);
ObjectNode objectNode = (ObjectNode) requestBodyNode.get("evtData");
objectNode.put("contentId", 0); //<-- 0 chosen as the new value
//it will show contentId updated to 0
System.out.println(requestBody);
</code>```

Body:
I have a request body (in JSON format) that looks like this:

[
  {
    "l_ts":0,
    "af":{
      "lib":"xyz",
      "OS":"abc",
      "wdt":"2.63",
    },
    "frs":false,
    "g":"-v4d89ae6885b14baf91b102caaefea245",
    "tlc":[],
    "type":"meta",
  },
  {
    "s":1643895073,
    "evtName":"CONTENT_LIKE_DISLIKE",
    "evtData":{
      "contentId":17189,
      "likeContent":true,
    },
    "type":"event",
    "n":"_bg"
  }
]

Now before sending the request, I need to update the value of "contentId" field. I am using Jackson in my current project, so what would be the best way to update the "contentId" field in the JSON above.

This is what I have tried till now:

ObjectMapper om = new ObjectMapper();
JsonNode requestBody = om.readTree(new File(pathToJsonAbove));
JsonNode requestBodyNode = requestBody.get(1);
requestBodyNode = JsonUtil.put(requestBodyNode, "evtData", "contentId", newValue);
requestBody = JsonUtil.put(requestBody, "[1]", requestBodyNode); // getting error here

The JsonUtil functions are as below:

public static final JsonNode put(JsonNode node, String key1, String key2, int value) {
    JsonNode jsonNode = node.path(key1);
         put(jsonNode, key2, value);
         return node;
}

public static final JsonNode put(JsonNode node, String key, int value) {
    return ((ObjectNode)node).put(key, value);
}

public static final JsonNode put(JsonNode node, String key, JsonNode value) {
    return ((ObjectNode)node).putPOJO(key, value);
}

I am not able to successfully put the node that I have edited (requestBodyNode), back in the requestBody which is the main JsonNode that holds the entire body. When I run the above code, I get a ClassCastException saying that I can't convert from ArrayNode to ObjectNode.

What is the best way to update the "contentId" field in the JSON above?

Body:
If you have to update just the contentId field you can identify the parent node of the contentId node and modify the child (moreover basically you have already made more than that with the creation of your function throwing the error) :

ObjectMapper om = new ObjectMapper();
JsonNode requestBody = om.readTree(json);
JsonNode requestBodyNode = requestBody.get(1);
ObjectNode objectNode = (ObjectNode) requestBodyNode.get("evtData");
objectNode.put("contentId", 0); //<-- 0 chosen as the new value
//it will show contentId updated to 0
System.out.println(requestBody);


问:
How do I create classes in dart?
I dont understand why im getting an error, can somebody please help. I just started to code in dart, but i cannot find a logical reason why this shouldnt work.</p>
```<code>void main() {
  User userx = User('luigi', 21);

  print(userx.age);
  userx.login();

  User usery = User('mario', 33);
  print(usery.username);
  usery.login();
}

class User {
  String username;
  int age;

  User(String username, int age){
    this.username = username;
    this.age = age;
  }

  void login() {
    print('user logged in');
  }
}
</code>```

答:
The correct syntax is:

void main() {
  User userx = User('luigi', 21);

  print(userx.age);
  userx.login();

  User usery = User('mario', 33);
  print(usery.username);
  usery.login();
}

class User {
  String username;
  int age;

  User(this.username, this.age);

  void login() {
    print('user logged in');
  }
}
```

Your compiler should have underlined the problematic parts with a helpful error message. Best thing would be read the message and try to do what it suggests.

Maybe you should start at the beginning e.g. by looking at some documentation: https://dart.dev/guides/language/language-tour#using-constructors

Title: How do I create classes in dart?

Body:
I dont understand why im getting an error, can somebody please help. I just started to code in dart, but i cannot find a logical reason why this shouldnt work.

void main() {
  User userx = User('luigi', 21);

  print(userx.age);
  userx.login();

  User usery = User('mario', 33);
  print(usery.username);
  usery.login();
}

class User {
  String username;
  int age;

  User(String username, int age){
    this.username = username;
    this.age = age;
  }

  void login() {
    print('user logged in');
  }
}

Body:
The correct syntax is:

void main() {
  User userx = User('luigi', 21);

  print(userx.age);
  userx.login();

  User usery = User('mario', 33);
  print(usery.username);
  usery.login();
}

class User {
  String username;
  int age;

  User(this.username, this.age);

  void login() {
    print('user logged in');
  }
}

Your compiler should have underlined the problematic parts with a helpful error message. Best thing would be read the message and try to do what it suggests.

Maybe you should start at the beginning e.g. by looking at some documentation: https://dart.dev/guides/language/language-tour#using-constructors


问:
How to find maximum number of occurrences for a character in a cell in a column in a CSV table in Python
I'm trying to find the maximum number of occurrences of '/' (a slash) in a cell in a column in a CSV file. Here's the table below. It has hundreds of rows.

Person Full Name
Person CRD Number
ID Number

Jack Johnson
32 / 54 / 57 / 87
5686

John Johnsen
11 / 22
6589

Luke Peterson
34
6978

Kyle Garcia
63 / 24 / 83
8957

Here's my code:

```<code>import pandas as pd

data = '/Users/myname/Downloads/tabularShell.csv'

df = pd.read_csv(data, index_col=0)

df1 = pd.DataFrame(df)['Person CRD Number']

df2 = df1.value_counts('/')

print(df2)
</code>```

The output should be 3 because the maximum number of occurrences of '/' is 3 in a cell in the "Person CRD Number" column in the table shown above.

Thank you!

答:
```<code>print(max(df['Person CRD Number'].str.count('/')))
</code>```

output:

```<code>>>> 3
</code>```

Body:
I'm trying to find the maximum number of occurrences of '/' (a slash) in a cell in a column in a CSV file. Here's the table below. It has hundreds of rows.

Person Full Name
Person CRD Number
ID Number

Jack Johnson
32 / 54 / 57 / 87
5686

John Johnsen
11 / 22
6589

Luke Peterson
34
6978

Kyle Garcia
63 / 24 / 83
8957

Here's my code:

import pandas as pd

data = '/Users/myname/Downloads/tabularShell.csv'

df = pd.read_csv(data, index_col=0)

df1 = pd.DataFrame(df)['Person CRD Number']

df2 = df1.value_counts('/')

print(df2)

The output should be 3 because the maximum number of occurrences of '/' is 3 in a cell in the "Person CRD Number" column in the table shown above.

Thank you!

Body:
print(max(df['Person CRD Number'].str.count('/')))

output:

>>> 3


问:
Find vector product using structures in C
I need to write function for calculating vector product of three vectors using structures in C. I have written function which works correct but I don't know how to print result.
Structures are new to me.

I get an error:

format ‘%g’ expects argument of type ‘double’, but argument 2 has type ‘Vektor3d’ {aka ‘struct anonymous’}

```<code>#include <stdio.h>
typedef struct{
    double x,y,z;
}     Vektor3d;

Vektor3d vector_product(Vektor3d v1, Vektor3d v2)
{
    Vektor3d v3;
    v3.x=(v1.y*v2.z-v1.z*v2.y);
    v3.y=(v1.z*v2.x-v1.x*v2.z);
    v3.z=(v1.x*v2.y-v1.y*v2.x);
    return v3;
}

int main() {
   Vektor3d v1,v2;
    scanf("%lf %lf %lf", &v1.x, &v1.y, &v1.z);
    scanf("%lf %lf %lf", &v2.x, &v2.y, &v2.z);
    printf("%g", vector_product(v1, v2));
    return 0;
}
</code>```

答:
In this line:

```<code>    printf("%g", vector_product(v1, v2));
</code>```

vector_product() returns an object of type Vektor3d. The function printf() does not know how to print this object. You have to call printf() and pass to it only the types it can handle (e.g. integers, doubles, etc.)

To fix this, simply store the result object in a variable, then pass its components to printf(). That is,

```<code>int main() {
    Vektor3d v1,v2;
    Vektor3d v3;

    scanf("%lf %lf %lf", &v1.x, &v1.y, &v1.z);
    scanf("%lf %lf %lf", &v2.x, &v2.y, &v2.z);
    v3 = vector_product(v1, v2);          /* Save the return value in v3 */
    printf("%g %g %g", v3.x, v3.y, v3.z); /* pass the components of v3 to printf */
    return 0;
}
</code>```

Body:
I need to write function for calculating vector product of three vectors using structures in C. I have written function which works correct but I don't know how to print result.
Structures are new to me.

I get an error:

format ‘%g’ expects argument of type ‘double’, but argument 2 has type ‘Vektor3d’ {aka ‘struct anonymous’}

#include <stdio.h>
typedef struct{
    double x,y,z;
}     Vektor3d;

Vektor3d vector_product(Vektor3d v1, Vektor3d v2)
{
    Vektor3d v3;
    v3.x=(v1.y*v2.z-v1.z*v2.y);
    v3.y=(v1.z*v2.x-v1.x*v2.z);
    v3.z=(v1.x*v2.y-v1.y*v2.x);
    return v3;
}

int main() {
   Vektor3d v1,v2;
    scanf("%lf %lf %lf", &v1.x, &v1.y, &v1.z);
    scanf("%lf %lf %lf", &v2.x, &v2.y, &v2.z);
    printf("%g", vector_product(v1, v2));
    return 0;
}

Body:
In this line:

    printf("%g", vector_product(v1, v2));

vector_product() returns an object of type Vektor3d. The function printf() does not know how to print this object. You have to call printf() and pass to it only the types it can handle (e.g. integers, doubles, etc.)

To fix this, simply store the result object in a variable, then pass its components to printf(). That is,

int main() {
    Vektor3d v1,v2;
    Vektor3d v3;

    scanf("%lf %lf %lf", &v1.x, &v1.y, &v1.z);
    scanf("%lf %lf %lf", &v2.x, &v2.y, &v2.z);
    v3 = vector_product(v1, v2);          /* Save the return value in v3 */
    printf("%g %g %g", v3.x, v3.y, v3.z); /* pass the components of v3 to printf */
    return 0;
}


问:
Append a txt file in .Net
I am Creating a txt file in.Net with the help of below code.

```<code>StreamWriter writerVer = new StreamWriter(@"c:\Version.txt");
writerVer.WriteLine("Version : " + Context.Parameters["ver"]);
File.SetAttributes(@"C:\Version.txt", FileAttributes.Hidden);
</code>```

Then I need to Update the file on the next line by keeping the above code as it is.

This code overrites the entire file.

```<code>StreamWriter writer = new StreamWriter(@"c:\Version.txt");
writer.WriteLine("Connection string : "+con);
</code>```

Regrads,

Sachin K

答:
Use the constructor which takes the append boolean parameter to indicate whether to append to the file - http://msdn.microsoft.com/en-us/library/36b035cb.aspx

```<code>StreamWriter writer = new StreamWriter("file.txt", true);
</code>```

ContentLicense: CC BY-SA 3.0

Title: Append a txt file in .Net

Body:
I am Creating a txt file in.Net with the help of below code.

StreamWriter writerVer = new StreamWriter(@"c:\Version.txt");
writerVer.WriteLine("Version : " + Context.Parameters["ver"]);
File.SetAttributes(@"C:\Version.txt", FileAttributes.Hidden);

Then I need to Update the file on the next line by keeping the above code as it is.

This code overrites the entire file.

StreamWriter writer = new StreamWriter(@"c:\Version.txt");
writer.WriteLine("Connection string : "+con);

Regrads,

Sachin K

Body:
Use the constructor which takes the append boolean parameter to indicate whether to append to the file - http://msdn.microsoft.com/en-us/library/36b035cb.aspx

StreamWriter writer = new StreamWriter("file.txt", true);


答:
You can use .str.count for this. For each item in the column, it returns how many of the specified character are in that colum. .max() will then select the largest value.

```<code>>>> df['Person CRD Number'].str.count('/').max()
3
</code>```

Title: How to find maximum number of occurrences for a character in a cell in a column in a CSV table in Python

Body:
You can use .str.count for this. For each item in the column, it returns how many of the specified character are in that colum. .max() will then select the largest value.

>>> df['Person CRD Number'].str.count('/').max()
3


问:
How to receive the message from stomp websocket with spring boot on android?
I've got the simple WebSocket example from https://spring.io/guides/gs/messaging-stomp-websocket/

package com.example.chatservice.message;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker("/topic");
        config.setApplicationDestinationPrefixes("/app");
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/gs-guide-websocket").withSockJS();
    }
}
```
<pre class="lang-java prettyprint-override"><code>@Controller
public class ChatController {
    @MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public Greeting greeting(HelloMessage message) throws Exception {
        return new Greeting("Hello from chat!");
    }
}
</code>```

and I'd like to receive the Greeting message from the spring server to an android app. I use https://github.com/NaikSoftware/StompProtocolAndroid as a stomp client

package com.example.chatapp;

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import org.java_websocket.WebSocket;

import ua.naiksoftware.stomp.Stomp;
import ua.naiksoftware.stomp.client.StompClient;

public class MainActivity extends AppCompatActivity {
    private StompClient mStompClient;
    public static  final String TAG="StompClient";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button view = (Button) findViewById(R.id.send_message);
        view.setOnClickListener(e->  new StompTask().execute(""));
    }

    private static class StompTask extends AsyncTask<String, Void, String> {
        private StompClient mStompClient;
        String TAG="LongOperation";

        @Override
        protected String doInBackground(String... params) {
            mStompClient = Stomp.over(WebSocket.class, "http://10.0.2.2:8080/gs-guide-websocket/websocket");
            mStompClient.connect();

            mStompClient.topic("/topic/greetings").subscribe(topicMessage -> {
                Log.d(TAG, topicMessage.getPayload());
            });

            mStompClient.lifecycle().subscribe(lifecycleEvent -> {
                switch (lifecycleEvent.getType()) {

                    case OPENED:
                        Log.d(TAG, "Stomp connection opened");
                        break;

                    case ERROR:
                        Log.e(TAG, "Error", lifecycleEvent.getException());
                        break;

                    case CLOSED:
                        Log.d(TAG, "Stomp connection closed");
                        break;
                }
            });

            return "Executed";
        }
    }
}
```
<p>and the connection to the</p>
<p><code>http://10.0.2.2:8080/gs-guide-websocket/websocket</code></p>
<p>works, because the log shows it's connected</p>
<p><code>2022-01-18 14:04:56.486 23717-23752/com.example.chatapp D/LongOperation: Stomp connection opened</code></p>
<p>but it does not subscribe to the topic:</p>
<pre class="lang-java prettyprint-override"><code>mStompClient.topic("/topic/greetings").subscribe(topicMessage -> {
    Log.d(TAG, topicMessage.getPayload());
});
</code>```

because when I set the breakpoint it doesn't ever hit it.

how can I receive this message?

答:
First of all I suppose you understand that if you don't send the proper message to the specified request topic, then you won't get anything here -

```<code>mStompClient.topic("/topic/greetings").subscribe(topicMessage -> {
    Log.d(TAG, topicMessage.getPayload());
});
</code>```

Today I had the issue where when sending a message,

```<code>mStompClient.send(REQUEST_TOPIC, requestAsString)
</code>```

I also did not receive anything in the subscription. The problem is that in addition to subscribing to the topic of receiving messages, you must subscribe to the topic of sending messages -

```<code>mStompClient.send(REQUEST_TOPIC, requestAsString)
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(
                                {
                                //onComplete
                                }, { error ->
                                  error.safeLog()
                                })
</code>```

Body:
I've got the simple WebSocket example from https://spring.io/guides/gs/messaging-stomp-websocket/

package com.example.chatservice.message;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker("/topic");
        config.setApplicationDestinationPrefixes("/app");
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/gs-guide-websocket").withSockJS();
    }
}

@Controller
public class ChatController {
    @MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public Greeting greeting(HelloMessage message) throws Exception {
        return new Greeting("Hello from chat!");
    }
}

and I'd like to receive the Greeting message from the spring server to an android app. I use https://github.com/NaikSoftware/StompProtocolAndroid as a stomp client

package com.example.chatapp;

import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import org.java_websocket.WebSocket;

import ua.naiksoftware.stomp.Stomp;
import ua.naiksoftware.stomp.client.StompClient;

public class MainActivity extends AppCompatActivity {
    private StompClient mStompClient;
    public static  final String TAG="StompClient";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button view = (Button) findViewById(R.id.send_message);
        view.setOnClickListener(e->  new StompTask().execute(""));
    }

    private static class StompTask extends AsyncTask<String, Void, String> {
        private StompClient mStompClient;
        String TAG="LongOperation";

        @Override
        protected String doInBackground(String... params) {
            mStompClient = Stomp.over(WebSocket.class, "http://10.0.2.2:8080/gs-guide-websocket/websocket");
            mStompClient.connect();

            mStompClient.topic("/topic/greetings").subscribe(topicMessage -> {
                Log.d(TAG, topicMessage.getPayload());
            });

            mStompClient.lifecycle().subscribe(lifecycleEvent -> {
                switch (lifecycleEvent.getType()) {

                    case OPENED:
                        Log.d(TAG, "Stomp connection opened");
                        break;

                    case ERROR:
                        Log.e(TAG, "Error", lifecycleEvent.getException());
                        break;

                    case CLOSED:
                        Log.d(TAG, "Stomp connection closed");
                        break;
                }
            });

            return "Executed";
        }
    }
}

and the connection to the

http://10.0.2.2:8080/gs-guide-websocket/websocket

works, because the log shows it's connected

2022-01-18 14:04:56.486 23717-23752/com.example.chatapp D/LongOperation: Stomp connection opened

but it does not subscribe to the topic:

mStompClient.topic("/topic/greetings").subscribe(topicMessage -> {
    Log.d(TAG, topicMessage.getPayload());
});

because when I set the breakpoint it doesn't ever hit it.

how can I receive this message?

Body:
First of all I suppose you understand that if you don't send the proper message to the specified request topic, then you won't get anything here -

mStompClient.topic("/topic/greetings").subscribe(topicMessage -> {
    Log.d(TAG, topicMessage.getPayload());
});

Today I had the issue where when sending a message,

mStompClient.send(REQUEST_TOPIC, requestAsString)

I also did not receive anything in the subscription. The problem is that in addition to subscribing to the topic of receiving messages, you must subscribe to the topic of sending messages -

mStompClient.send(REQUEST_TOPIC, requestAsString)
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(
                                {
                                //onComplete
                                }, { error ->
                                  error.safeLog()
                                })


问:
Pulumi Rancher2 provider creation is throwing error
I am currently trying to create rancher2 provider in Pulumi like this:

```<code>import * as rancher2 from '@pulumi/rancher2'

const rancher2ProviderBootstrap = new rancher2.Provider(
    'ComponentResource::AwsClusterK3s::rancher2Provider',
    {
        apiUrl: `https://rancherurl.com`,
        bootstrap: true,
        timeout: '5m',
        // I have also tried combining/removing properties (only apiUrl is required), but the error is still the same
    },
)
</code>```

And when I run pulumi preview or pulumi up I get following error:

```<code>panic: fatal: An assertion has failed

goroutine 52 [running]:
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.failfast(...)
        /Users/runner/work/pulumi/pulumi/sdk/go/common/util/contract/failfast.go:23
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.Assert(...)
        /Users/runner/work/pulumi/pulumi/sdk/go/common/util/contract/assert.go:26
github.com/pulumi/pulumi/pkg/v3/resource/deploy/providers.mustNewReference({0xc000382380, 0x6a}, {0x1acccaa, 0x24})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/providers/reference.go:134 +0xce
github.com/pulumi/pulumi/pkg/v3/resource/deploy/providers.(*Registry).Check(0xc0010dceb0, {0xc000382380, 0x6a}, 0x0, 0xc000babd70, 0x0, 0xc0006ad200)
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/providers/registry.go:284 +0x40e
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepGenerator).generateSteps(0xc00029f680, {0x1de5553bb18, 0xc000bcee20})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/step_generator.go:427 +0x10fb
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepGenerator).GenerateSteps(0xc00029f680, {0x1de5553bb18, 0xc000bcee20})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/step_generator.go:185 +0x46
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*deploymentExecutor).handleSingleEvent(0xc000688498, {0x1e2e820, 0xc000bcee20})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/deployment_executor.go:413 +0xe5
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*deploymentExecutor).Execute.func3(0xc001156240, 0xc000688498, 0xc000ef0fd0, {0x1e602f0, 0xc000681a80}, 0x0, 0x0, {0x1e60398, 0xc00113ecf0})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/deployment_executor.go:250 +0x273
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*deploymentExecutor).Execute(0xc000688498, {0x1e60398, 0xc00113ecf0}, {{0x1de5556d5a8, 0xc0005d6840}, 0x7fffffff, 0x0, 0x0, {0x0, 0x0, ...}, ...}, ...)
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/deployment_executor.go:266 +0x95f
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*Deployment).Execute(0xc000cae420, {0x1e60398, 0xc00113ecf0}, {{0x1de5556d5a8, 0xc0005d6840}, 0x7fffffff, 0x0, 0x0, {0x0, 0x0, ...}, ...}, ...)
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/deployment.go:447 +0xd0
github.com/pulumi/pulumi/pkg/v3/engine.(*deployment).run.func1()
        /Users/runner/work/pulumi/pulumi/pkg/engine/deployment.go:269 +0x250
created by github.com/pulumi/pulumi/pkg/v3/engine.(*deployment).run
        /Users/runner/work/pulumi/pulumi/pkg/engine/deployment.go:252 +0x371
</code>```

NPM Versions:

```<code>@pulumi/pulumi@3.24.1 (latest)
@pulumi/rancher2@3.6.1 (latest)
</code>```

Local PC:

```<code>PULUMI: pulumi@3.24.1 (latest)
OS: Windows 10
</code>```

Am I doing something wrong, or is this really bug in the pulumi library?

答:
Resource names shouldn't contain :. It shouldn't panic like this, but the fix is simple.

Set your resource name like this:

import * as rancher2 from '@pulumi/rancher2'

const rancher2ProviderBootstrap = new rancher2.Provider(
    'AwsClusterK3s',
    {
        apiUrl: `https://rancherurl.com`,
        bootstrap: true,
        timeout: '5m',
    },
)
```

I've added a github issue for the panic here: https://github.com/pulumi/pulumi/issues/8949

Body:
I am currently trying to create rancher2 provider in Pulumi like this:

import * as rancher2 from '@pulumi/rancher2'

const rancher2ProviderBootstrap = new rancher2.Provider(
    'ComponentResource::AwsClusterK3s::rancher2Provider',
    {
        apiUrl: `https://rancherurl.com`,
        bootstrap: true,
        timeout: '5m',
        // I have also tried combining/removing properties (only apiUrl is required), but the error is still the same
    },
)

And when I run pulumi preview or pulumi up I get following error:

panic: fatal: An assertion has failed

goroutine 52 [running]:
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.failfast(...)
        /Users/runner/work/pulumi/pulumi/sdk/go/common/util/contract/failfast.go:23
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.Assert(...)
        /Users/runner/work/pulumi/pulumi/sdk/go/common/util/contract/assert.go:26
github.com/pulumi/pulumi/pkg/v3/resource/deploy/providers.mustNewReference({0xc000382380, 0x6a}, {0x1acccaa, 0x24})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/providers/reference.go:134 +0xce
github.com/pulumi/pulumi/pkg/v3/resource/deploy/providers.(*Registry).Check(0xc0010dceb0, {0xc000382380, 0x6a}, 0x0, 0xc000babd70, 0x0, 0xc0006ad200)
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/providers/registry.go:284 +0x40e
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepGenerator).generateSteps(0xc00029f680, {0x1de5553bb18, 0xc000bcee20})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/step_generator.go:427 +0x10fb
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*stepGenerator).GenerateSteps(0xc00029f680, {0x1de5553bb18, 0xc000bcee20})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/step_generator.go:185 +0x46
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*deploymentExecutor).handleSingleEvent(0xc000688498, {0x1e2e820, 0xc000bcee20})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/deployment_executor.go:413 +0xe5
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*deploymentExecutor).Execute.func3(0xc001156240, 0xc000688498, 0xc000ef0fd0, {0x1e602f0, 0xc000681a80}, 0x0, 0x0, {0x1e60398, 0xc00113ecf0})
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/deployment_executor.go:250 +0x273
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*deploymentExecutor).Execute(0xc000688498, {0x1e60398, 0xc00113ecf0}, {{0x1de5556d5a8, 0xc0005d6840}, 0x7fffffff, 0x0, 0x0, {0x0, 0x0, ...}, ...}, ...)
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/deployment_executor.go:266 +0x95f
github.com/pulumi/pulumi/pkg/v3/resource/deploy.(*Deployment).Execute(0xc000cae420, {0x1e60398, 0xc00113ecf0}, {{0x1de5556d5a8, 0xc0005d6840}, 0x7fffffff, 0x0, 0x0, {0x0, 0x0, ...}, ...}, ...)
        /Users/runner/work/pulumi/pulumi/pkg/resource/deploy/deployment.go:447 +0xd0
github.com/pulumi/pulumi/pkg/v3/engine.(*deployment).run.func1()
        /Users/runner/work/pulumi/pulumi/pkg/engine/deployment.go:269 +0x250
created by github.com/pulumi/pulumi/pkg/v3/engine.(*deployment).run
        /Users/runner/work/pulumi/pulumi/pkg/engine/deployment.go:252 +0x371

NPM Versions:

@pulumi/pulumi@3.24.1 (latest)
@pulumi/rancher2@3.6.1 (latest)

Local PC:

PULUMI: pulumi@3.24.1 (latest)
OS: Windows 10

Am I doing something wrong, or is this really bug in the pulumi library?

Body:
Resource names shouldn't contain :. It shouldn't panic like this, but the fix is simple.

Set your resource name like this:

import * as rancher2 from '@pulumi/rancher2'

const rancher2ProviderBootstrap = new rancher2.Provider(
    'AwsClusterK3s',
    {
        apiUrl: `https://rancherurl.com`,
        bootstrap: true,
        timeout: '5m',
    },
)

I've added a github issue for the panic here: https://github.com/pulumi/pulumi/issues/8949


问:
How can I make docker-compose build an image from a remote git repository?
Docker-compose allows you to utilize either preëxisting docker images or build from source. For the build option, the official reference requires

Either a path to a directory containing a Dockerfile, or a url to a git repository.

I'd like to take advantage of the latter case, so that I don't have to create a git submodule in my project, or register a new repository on Docker Hub. Unfortunately, there are no examples for how to format the url, and every form I've tried is mistaken for a relative file path.

e.g.

```<code>---
letsencrypt:
  build: https://github.com/letsencrypt/letsencrypt.git
...
</code>```

Fails with the error:

ERROR: build path /{MY_CURRENT_PATH}/https:/github.com/letsencrypt/letsencrypt.git either does not exist or is not accessible.

I didn't have any more luck with the other forms I've tried:

git@github.com:letsencrypt/letsencrypt.git

git://github.com/letsencrypt/letsencrypt.git

https://github.com/letsencrypt/letsencrypt

答:
Sorry to revive this topic, but it came up as the first link and i could't find any other information elsewhere.

If you want to build from a specific repository tag, you will need to append #tagname
such as

```<code>build: https://github.com/postgres/pgadmin4.git#REL-6_4
</code>```

see the docker documentation.

Also building on top of the answer of @philipp-fock. Using the raw file works, as long as the original Dockerfile did not include any other files within that repository (no COPY, ADD)

Using

Body:
Docker-compose allows you to utilize either preëxisting docker images or build from source. For the build option, the official reference requires

Either a path to a directory containing a Dockerfile, or a url to a git repository.

I'd like to take advantage of the latter case, so that I don't have to create a git submodule in my project, or register a new repository on Docker Hub. Unfortunately, there are no examples for how to format the url, and every form I've tried is mistaken for a relative file path.

e.g.

---
letsencrypt:
  build: https://github.com/letsencrypt/letsencrypt.git
...

Fails with the error:

ERROR: build path /{MY_CURRENT_PATH}/https:/github.com/letsencrypt/letsencrypt.git either does not exist or is not accessible.

I didn't have any more luck with the other forms I've tried:

git@github.com:letsencrypt/letsencrypt.git

git://github.com/letsencrypt/letsencrypt.git

https://github.com/letsencrypt/letsencrypt

Body:
Sorry to revive this topic, but it came up as the first link and i could't find any other information elsewhere.

If you want to build from a specific repository tag, you will need to append #tagname
such as

build: https://github.com/postgres/pgadmin4.git#REL-6_4

see the docker documentation.

Also building on top of the answer of @philipp-fock. Using the raw file works, as long as the original Dockerfile did not include any other files within that repository (no COPY, ADD)

Using


问:
how can test my API in different PC which is in same wifi network using my IPv4 address?
how can I test my API in different PC which is in same WIFI network using my IPv4 address ?
like if i have if 192.168.2.222 then I got the error URL image plz tell me how can I solve.The API is working fine in local host. but in IPv4 I got this error so plz guide me. I have tried all the configuration from different sources but still getting this error.</p>

答:
you can do some like this

192.168.31.91/your_project_name/public/api/Your_API_Route

if your project doesn't have public then just

192.168.31.91/your_project_name/api/Your_API_Route

and also check your firewall if it allows


问:
Module not found: Error: Can't resolve 'date-fns/addDays' in 'C:\Users\
I want to use Date picker from MUI but I get this error and I don't know what exactly is wrong.
here is my code:

```<code>import TextField from "@mui/material/TextField";
import DatePicker from "@mui/lab/DatePicker";
import AdapterDateFns from "@mui/lab/AdapterDateFns";
import LocalizationProvider from "@mui/lab/LocalizationProvider";

const ExpenseForm = () => {
  return (
    <Box component="form" noValidate autoComplete="off">
      <LocalizationProvider dateAdapter={AdapterDateFns}>
        <DatePicker
          label="Basic example"
          onChange={(newValue) => {}}
          renderInput={(params) => <TextField {...params} />}
        />
      </LocalizationProvider>
    </Box>
  );
};

export default ExpenseForm;
</code>```

and my package.json:

```<code>"dependencies": {
    "@date-io/date-fns": "^2.13.1",
    "@emotion/react": "^11.7.1",
    "@emotion/styled": "^11.6.0",
    "@mui/icons-material": "^5.3.1",
    "@mui/lab": "^5.0.0-alpha.68",
    "@mui/material": "^5.4.0",
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.4"
  },
</code>```

but everytime I get these errors:

```<code>Compiled with problems:

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 1:0-39

Module not found: Error: Can't resolve 'date-fns/addDays' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 2:0-45

Module not found: Error: Can't resolve 'date-fns/addSeconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 3:0-45

Module not found: Error: Can't resolve 'date-fns/addMinutes' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 4:0-41

Module not found: Error: Can't resolve 'date-fns/addHours' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 5:0-41

Module not found: Error: Can't resolve 'date-fns/addWeeks' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 6:0-43

Module not found: Error: Can't resolve 'date-fns/addMonths' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 7:0-41

Module not found: Error: Can't resolve 'date-fns/addYears' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 8:0-59

Module not found: Error: Can't resolve 'date-fns/differenceInYears' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 9:0-65

Module not found: Error: Can't resolve 'date-fns/differenceInQuarters' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 10:0-61

Module not found: Error: Can't resolve 'date-fns/differenceInMonths' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 11:0-59

Module not found: Error: Can't resolve 'date-fns/differenceInWeeks' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 12:0-57

Module not found: Error: Can't resolve 'date-fns/differenceInDays' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 13:0-59

Module not found: Error: Can't resolve 'date-fns/differenceInHours' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 14:0-63

Module not found: Error: Can't resolve 'date-fns/differenceInMinutes' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 15:0-63

Module not found: Error: Can't resolve 'date-fns/differenceInSeconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 16:0-73

Module not found: Error: Can't resolve 'date-fns/differenceInMilliseconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 17:0-59

Module not found: Error: Can't resolve 'date-fns/eachDayOfInterval' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 18:0-41

Module not found: Error: Can't resolve 'date-fns/endOfDay' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 19:0-43

Module not found: Error: Can't resolve 'date-fns/endOfWeek' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 20:0-43

Module not found: Error: Can't resolve 'date-fns/endOfYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 21:0-37

Module not found: Error: Can't resolve 'date-fns/format' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 22:0-41

Module not found: Error: Can't resolve 'date-fns/getHours' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 23:0-45

Module not found: Error: Can't resolve 'date-fns/getSeconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 24:0-39

Module not found: Error: Can't resolve 'date-fns/getYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 25:0-39

Module not found: Error: Can't resolve 'date-fns/isAfter' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 26:0-41

Module not found: Error: Can't resolve 'date-fns/isBefore' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 27:0-39

Module not found: Error: Can't resolve 'date-fns/isEqual' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 28:0-43

Module not found: Error: Can't resolve 'date-fns/isSameDay' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 29:0-45

Module not found: Error: Can't resolve 'date-fns/isSameYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 30:0-47

Module not found: Error: Can't resolve 'date-fns/isSameMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 31:0-45

Module not found: Error: Can't resolve 'date-fns/isSameHour' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 32:0-39

Module not found: Error: Can't resolve 'date-fns/isValid' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 33:0-42

Module not found: Error: Can't resolve 'date-fns/parse' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 34:0-41

Module not found: Error: Can't resolve 'date-fns/setHours' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 35:0-45

Module not found: Error: Can't resolve 'date-fns/setMinutes' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 36:0-41

Module not found: Error: Can't resolve 'date-fns/setMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 37:0-37

Module not found: Error: Can't resolve 'date-fns/getDay' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 38:0-53

Module not found: Error: Can't resolve 'date-fns/getDaysInMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 39:0-45

Module not found: Error: Can't resolve 'date-fns/setSeconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 40:0-39

Module not found: Error: Can't resolve 'date-fns/setYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 41:0-45

Module not found: Error: Can't resolve 'date-fns/startOfDay' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 42:0-49

Module not found: Error: Can't resolve 'date-fns/startOfMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 43:0-45

Module not found: Error: Can't resolve 'date-fns/endOfMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 44:0-47

Module not found: Error: Can't resolve 'date-fns/startOfWeek' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 45:0-47

Module not found: Error: Can't resolve 'date-fns/startOfYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 46:0-41

Module not found: Error: Can't resolve 'date-fns/parseISO' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 47:0-43

Module not found: Error: Can't resolve 'date-fns/formatISO' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 48:0-57

Module not found: Error: Can't resolve 'date-fns/isWithinInterval' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 49:0-65

Module not found: Error: Can't resolve 'date-fns/_lib/format/longFormatters' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 50:0-50

Module not found: Error: Can't resolve 'date-fns/locale/en-US' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'
</code>```

I searched the web but couldn't find something useful . also some StackOverflow similar posts that suggested to restart the server I tried but didn't actually solve my problem.

答: You need to install the date-fns package from NPM using npm install --save date-fns.

Body:
I want to use Date picker from MUI but I get this error and I don't know what exactly is wrong.
here is my code:

import TextField from "@mui/material/TextField";
import DatePicker from "@mui/lab/DatePicker";
import AdapterDateFns from "@mui/lab/AdapterDateFns";
import LocalizationProvider from "@mui/lab/LocalizationProvider";

const ExpenseForm = () => {
  return (
    <Box component="form" noValidate autoComplete="off">
      <LocalizationProvider dateAdapter={AdapterDateFns}>
        <DatePicker
          label="Basic example"
          onChange={(newValue) => {}}
          renderInput={(params) => <TextField {...params} />}
        />
      </LocalizationProvider>
    </Box>
  );
};

export default ExpenseForm;

and my package.json:

"dependencies": {
    "@date-io/date-fns": "^2.13.1",
    "@emotion/react": "^11.7.1",
    "@emotion/styled": "^11.6.0",
    "@mui/icons-material": "^5.3.1",
    "@mui/lab": "^5.0.0-alpha.68",
    "@mui/material": "^5.4.0",
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.4"
  },

but everytime I get these errors:

Compiled with problems:

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 1:0-39

Module not found: Error: Can't resolve 'date-fns/addDays' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 2:0-45

Module not found: Error: Can't resolve 'date-fns/addSeconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 3:0-45

Module not found: Error: Can't resolve 'date-fns/addMinutes' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 4:0-41

Module not found: Error: Can't resolve 'date-fns/addHours' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 5:0-41

Module not found: Error: Can't resolve 'date-fns/addWeeks' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 6:0-43

Module not found: Error: Can't resolve 'date-fns/addMonths' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 7:0-41

Module not found: Error: Can't resolve 'date-fns/addYears' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 8:0-59

Module not found: Error: Can't resolve 'date-fns/differenceInYears' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 9:0-65

Module not found: Error: Can't resolve 'date-fns/differenceInQuarters' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 10:0-61

Module not found: Error: Can't resolve 'date-fns/differenceInMonths' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 11:0-59

Module not found: Error: Can't resolve 'date-fns/differenceInWeeks' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 12:0-57

Module not found: Error: Can't resolve 'date-fns/differenceInDays' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 13:0-59

Module not found: Error: Can't resolve 'date-fns/differenceInHours' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 14:0-63

Module not found: Error: Can't resolve 'date-fns/differenceInMinutes' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 15:0-63

Module not found: Error: Can't resolve 'date-fns/differenceInSeconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 16:0-73

Module not found: Error: Can't resolve 'date-fns/differenceInMilliseconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 17:0-59

Module not found: Error: Can't resolve 'date-fns/eachDayOfInterval' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 18:0-41

Module not found: Error: Can't resolve 'date-fns/endOfDay' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 19:0-43

Module not found: Error: Can't resolve 'date-fns/endOfWeek' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 20:0-43

Module not found: Error: Can't resolve 'date-fns/endOfYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 21:0-37

Module not found: Error: Can't resolve 'date-fns/format' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 22:0-41

Module not found: Error: Can't resolve 'date-fns/getHours' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 23:0-45

Module not found: Error: Can't resolve 'date-fns/getSeconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 24:0-39

Module not found: Error: Can't resolve 'date-fns/getYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 25:0-39

Module not found: Error: Can't resolve 'date-fns/isAfter' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 26:0-41

Module not found: Error: Can't resolve 'date-fns/isBefore' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 27:0-39

Module not found: Error: Can't resolve 'date-fns/isEqual' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 28:0-43

Module not found: Error: Can't resolve 'date-fns/isSameDay' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 29:0-45

Module not found: Error: Can't resolve 'date-fns/isSameYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 30:0-47

Module not found: Error: Can't resolve 'date-fns/isSameMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 31:0-45

Module not found: Error: Can't resolve 'date-fns/isSameHour' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 32:0-39

Module not found: Error: Can't resolve 'date-fns/isValid' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 33:0-42

Module not found: Error: Can't resolve 'date-fns/parse' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 34:0-41

Module not found: Error: Can't resolve 'date-fns/setHours' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 35:0-45

Module not found: Error: Can't resolve 'date-fns/setMinutes' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 36:0-41

Module not found: Error: Can't resolve 'date-fns/setMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 37:0-37

Module not found: Error: Can't resolve 'date-fns/getDay' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 38:0-53

Module not found: Error: Can't resolve 'date-fns/getDaysInMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 39:0-45

Module not found: Error: Can't resolve 'date-fns/setSeconds' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 40:0-39

Module not found: Error: Can't resolve 'date-fns/setYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 41:0-45

Module not found: Error: Can't resolve 'date-fns/startOfDay' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 42:0-49

Module not found: Error: Can't resolve 'date-fns/startOfMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 43:0-45

Module not found: Error: Can't resolve 'date-fns/endOfMonth' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 44:0-47

Module not found: Error: Can't resolve 'date-fns/startOfWeek' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 45:0-47

Module not found: Error: Can't resolve 'date-fns/startOfYear' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 46:0-41

Module not found: Error: Can't resolve 'date-fns/parseISO' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 47:0-43

Module not found: Error: Can't resolve 'date-fns/formatISO' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 48:0-57

Module not found: Error: Can't resolve 'date-fns/isWithinInterval' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 49:0-65

Module not found: Error: Can't resolve 'date-fns/_lib/format/longFormatters' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

ERROR in ./node_modules/@date-io/date-fns/build/index.esm.js 50:0-50

Module not found: Error: Can't resolve 'date-fns/locale/en-US' in 'C:\Users\Amir\Desktop\React\React-apps\expense-tracker\node_modules\@date-io\date-fns\build'

I searched the web but couldn't find something useful . also some StackOverflow similar posts that suggested to restart the server I tried but didn't actually solve my problem.


问:
Properly (independent of 32bit/64bit) saving a float to binary ofstream
So apparently on my machine, float, double and long double each have different sizes each. There also doesn't seem to be a strict standard enforcing how many bytes each of those types would have to be.

How would one, then, save a floating point value into a binary file, and then have it read properly on a different system if the sizes differ? e.g my machine has 8 byte doubles, whereas joe's have 12 byte doubles.

Without having to export it in text form (e.g "0.3232"), that is. Seems a lot less compact than the binary representation.

答:
You could use Boost serialization http://www.boost.org/doc/libs/1_47_0/libs/serialization/doc/index.html which can serialize to text, xml, or binary.

Otherwise you can do it manually, for example like this:

you agree to little endian (and check whether the machine is little or big endian and than do a recalculation)

you write one byte, how many byte long the floating point number is

then you write the float to the stream - as little endian