慕巷

文章 评论 浏览 28

慕巷 2025-02-20 18:12:28

当您指定AWS :: :: serverless :: function的体系结构时,体系结构来自Temlate文件中指定的内容。

从github repo中获取:

软件包CI
dotnet lambda package-ci

用于无服务器应用程序的 。它创建了Lambda应用程序捆绑包并将其上传到Amazon S3。然后写道
lambda功能代码的位置更新为
应用程序包上载的位置。在AWS CodePipeline中,该命令可以作为 codebuild 的一部分执行
舞台作为构建工件返回转换的模板。稍后,在转换无服务器的管道中。
与云形式阶段一起部署应用程序。

注释

dotnet lambda package-ci检查并使用 架构 aws :: serverless :: function 确定软件包的运行时。

例如:

      "Architectures": [
        "arm64"
      ],

将执行dotnet Publish使用- runtime值的参数linux-arm64

The architecture comes from whatever is specified in your temlate file when you specify the architecture for the AWS::Serverless::Function.

Taken from the GitHub repo:

Package CI
dotnet lambda package-ci

Used for serverless applications. It creates the Lambda application bundle and uploads it to Amazon S3. It then writes
a new version of the serverless.template with the location of the Lambda function code updated to
where the application bundle was uploaded. In an AWS CodePipeline this command can be executed as part of a CodeBuild
stage returning the transformed template as the build artifact. Later in the pipeline that transformed serverless.template can
be used with a CloudFormation stage to deploy the application.

Notes

dotnet lambda package-ci inspects and uses the Architectures property of AWS::Serverless::Function to determine the runtime of the package.

For example:

      "Architectures": [
        "arm64"
      ],

will execute dotnet publish with a --runtime argument of value linux-arm64:

您如何“ dotnet lambda package-ci”对于ARM64?

慕巷 2025-02-20 17:52:01

我看到您的问题,您的逻辑是正确的,但是实现不佳,一旦您过滤了数据,它才会呈现一个新组件:

import { EmailIcon, LocationIcon } from "./assets/FormSvgIcons";
import React, { useEffect, useState } from "react";

export default function SettingsForm() {
  const [stateList, setStateList] = useState([]);

  useEffect(() => {
    fetch("https://servicodados.ibge.gov.br/api/v1/localidades/estados/")
      .then((response) => {
        return response.json();
      })
      .then((data) => {
        console.log(data);
        setStateList(data);
      });
  }, []);

  return (
    <form>
      <div className="user-country">
        <label className="white-label">Local</label>
        <div className="input-icon-wrapper">
          <div className="icon-input w-embed">
            <LocationIcon />
          </div>
          <select
            className="select-field white-select w-select"
            id="locationField"
            name="locationField"
            onChange={handleLocation}
          >
            {stateList.map((state) => {
              return <CreateDropdownOptions state={state} />;
            })}
          </select>
        </div>
      </div>
    </form>
  );
}

function CreateDropdownOptions({ state }) {
  return (
    <option key={state.id} value={state.sigla}>
      {state.sigla}
    </option>
  );
}

我建议为每个选项使用一个组件,如果您以后需要使用一个组件,那么它将变得更加容易对

I see your problem, your logic is correct, but it is poorly implemented, once you have filtered the data, it is only rendering a new component:

import { EmailIcon, LocationIcon } from "./assets/FormSvgIcons";
import React, { useEffect, useState } from "react";

export default function SettingsForm() {
  const [stateList, setStateList] = useState([]);

  useEffect(() => {
    fetch("https://servicodados.ibge.gov.br/api/v1/localidades/estados/")
      .then((response) => {
        return response.json();
      })
      .then((data) => {
        console.log(data);
        setStateList(data);
      });
  }, []);

  return (
    <form>
      <div className="user-country">
        <label className="white-label">Local</label>
        <div className="input-icon-wrapper">
          <div className="icon-input w-embed">
            <LocationIcon />
          </div>
          <select
            className="select-field white-select w-select"
            id="locationField"
            name="locationField"
            onChange={handleLocation}
          >
            {stateList.map((state) => {
              return <CreateDropdownOptions state={state} />;
            })}
          </select>
        </div>
      </div>
    </form>
  );
}

function CreateDropdownOptions({ state }) {
  return (
    <option key={state.id} value={state.sigla}>
      {state.sigla}
    </option>
  );
}

I recommend using a component for each option, this will make it easier if you later need to do some action on the

从下拉列表中动态创建选项

慕巷 2025-02-20 08:10:17

只需添加statelistCitiesList的数组。

stateList = [{ name: 'England' }];
citiesList = ['London'];

Just add array of stateList and citiesList.

stateList = [{ name: 'England' }];
citiesList = ['London'];

角度:在选择中显示值

慕巷 2025-02-20 03:57:56

RES变量不是初始化的。用 @mock 享用注释使用

@ExtendWith(MockitoExtension.class)
public class ATest {
...

res variable is not initialized. To mock objects with @Mock annotation use

@ExtendWith(MockitoExtension.class)
public class ATest {
...

MOCKITO-服务中的响应返回测试中的null -Java

慕巷 2025-02-19 22:20:49

如某些注释中所述,您不仅可以短路路径并在没有返回关键字的情况下返回值。 返回仅在该方法的最后值中不需要。无论如何,通常,避免在方法中具有多个回报的短路是一种好习惯。
在您的示例中,添加两个else您可以在不使用return关键字的情况下构造每个可能输出的最后值的路径:

def balance(chars: List[Char]): Boolean = {
  def parenBalance(char : List[Char])  :Boolean = {
    parenBalanceRecur(char, 0 , 0)
  }

  @tailrec
  def parenBalanceRecur(charSequence: List[Char], itr : Int, imbalance : Int) : Boolean = {
    if (imbalance < 0) then false
    else if (itr == charSequence.length ) {
      if (imbalance == 0) then true else false // #1
    }

    else if (charSequence(itr) == '(')  {  // # 2
      parenBalanceRecur(charSequence, (itr + 1), (imbalance + 1))
    }
    else if (charSequence(itr) == ')') {
      parenBalanceRecur(charSequence, itr + 1, imbalance -1)
    }
    else {
      parenBalanceRecur (charSequence, itr +1, imbalance)
    }
  }
  parenBalance(chars)
}

As mentioned in some comments, you can not just short circuit the path and return a value without the return keyword. return is not needed only at the last value of the method. In any case, usually, it's a good practice to avoid short circuits with multiple returns in a method.
In your example, adding two else you can construct the path down to the last value of each possible output without using the return keyword:

def balance(chars: List[Char]): Boolean = {
  def parenBalance(char : List[Char])  :Boolean = {
    parenBalanceRecur(char, 0 , 0)
  }

  @tailrec
  def parenBalanceRecur(charSequence: List[Char], itr : Int, imbalance : Int) : Boolean = {
    if (imbalance < 0) then false
    else if (itr == charSequence.length ) {
      if (imbalance == 0) then true else false // #1
    }

    else if (charSequence(itr) == '(')  {  // # 2
      parenBalanceRecur(charSequence, (itr + 1), (imbalance + 1))
    }
    else if (charSequence(itr) == ')') {
      parenBalanceRecur(charSequence, itr + 1, imbalance -1)
    }
    else {
      parenBalanceRecur (charSequence, itr +1, imbalance)
    }
  }
  parenBalance(chars)
}

Scala似乎需要返回&#x27;递归功能的关键字

慕巷 2025-02-19 21:34:36

如果您这样做了:

   if ($request->hasFile('slider_image')) {
        $data['slider_image'] = [];
        $data['slider_image_url'] = [];
        foreach($request->file('slider_image') as $slider_image)
        {
        $filenameWithExt = $slider_image->getClientOriginalName ();
        $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
        $extension = $slider_image->getClientOriginalExtension();
        $fileNameToStore = $filename. '_'. time().'.'.$extension;
        $slider_image->storeAs('public/artists/products/slider_image', $fileNameToStore);
        array_push($data['slider_image'], $fileNameToStore);
        array_push($data['slider_image_url'], url('storage/artists/products/slider_image/'.$fileNameToStoreImgUrl));
     }
       dd($data); // see if this solves your problem
     }

在$ data ['slider_image']上,您将拥有一系列文件名,在$ data ['slider_image_url']上,您将拥有一系列URL。

What if you did this:

   if ($request->hasFile('slider_image')) {
        $data['slider_image'] = [];
        $data['slider_image_url'] = [];
        foreach($request->file('slider_image') as $slider_image)
        {
        $filenameWithExt = $slider_image->getClientOriginalName ();
        $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
        $extension = $slider_image->getClientOriginalExtension();
        $fileNameToStore = $filename. '_'. time().'.'.$extension;
        $slider_image->storeAs('public/artists/products/slider_image', $fileNameToStore);
        array_push($data['slider_image'], $fileNameToStore);
        array_push($data['slider_image_url'], url('storage/artists/products/slider_image/'.$fileNameToStoreImgUrl));
     }
       dd($data); // see if this solves your problem
     }

On $data['slider_image'] you'll have an array of file names, on $data['slider_image_url'] you'll have an array of URLs.

如何使用自定义URL Laravel保存数组

慕巷 2025-02-19 04:03:18

ViewLoader是一个抽象类。 Guice只是说您需要提供可以实施的东西。 Guice无法实例化抽象类。因此,提供具有具体实现的绑定:

class MyViewLoader extends ViewLoader {
  // Implement abstract methods.
}

然后在模块中绑定实现:

  @Override public void configure() {
    bind(ViewLoader.class).to(MyViewLoader.class);
  }

ViewLoader is an abstract class. Guice simply says that you need to provide something it can instanciate. Guice can't instantiate abstract class. So provide a binding with a concrete implementation:

class MyViewLoader extends ViewLoader {
  // Implement abstract methods.
}

Then bind the implementation in your module:

  @Override public void configure() {
    bind(ViewLoader.class).to(MyViewLoader.class);
  }

[GUICE/MISTIMPLENTION]:Viewloader没有实现

慕巷 2025-02-18 19:01:18

您可以将其与套接字合作,但是如果您已经安装了Visa驱动程序,则使用pyvisa是必不可少的方法。我不使用Agilent(Keysight)E4980A,但应该相似。

在计算机上,您安装了Keysight IO库,使用Keysight连接专家应用程序添加您的LAN设备,然后以下代码可行:

% py
Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvisa
>>> rm = pyvisa.ResourceManager()
>>> rm.list_resources()
('TCPIP0::192.168.1.15::inst0::INSTR')
>>> inst=rm.open_resource('TCPIP0::192.168.1.15::inst0::INSTR')
>>> inst.query('*IDN?')
'Agilent Technologies,N9040B\n'

在Keysight Connectigh Connection Expert中,您也可以分配Aliases,以便您可以做以下操作:

>>> inst=rm.open_resource('MyDevice')

It's neat you got it working with sockets, but if you've already installed the VISA driver, using pyvisa is the way to go. I'm not using the Agilent (Keysight) E4980A, but it should be similar.

On the computer you installed the Keysight IO Libraries, use the Keysight Connection Expert application to add your LAN device, then the following code should work:

% py
Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvisa
>>> rm = pyvisa.ResourceManager()
>>> rm.list_resources()
('TCPIP0::192.168.1.15::inst0::INSTR')
>>> inst=rm.open_resource('TCPIP0::192.168.1.15::inst0::INSTR')
>>> inst.query('*IDN?')
'Agilent Technologies,N9040B\n'

In the Keysight Connection Expert you can also assign aliases so you can do things like:

>>> inst=rm.open_resource('MyDevice')

如何通过Python中的TCP/IP与设备进行通信?

慕巷 2025-02-18 18:00:55

您是否尝试过复制现有文件(例如,单_post.php的精确副本)只是为了查看它是否有效?
如果页面有标题和页脚,则该错误在此PHP文件上,否则在其他地方。

你可以有这样的想法

Have you tried to copy an existing file (exact copy of single_post.php for example) just to see if it works ?
If the page have header and footer, then the error is on this php file, otherwise it's somewhere else.

You can have an idea like that

WordPress:儿童主题&#x2B;自定义邮政模板

慕巷 2025-02-18 15:21:52

TL:DR将Getters和Setters添加到QueitalSteNaireDtoreQuest

另外,这只会使值无效,而不是QuageSnaireDtoreQuest对象。是这样吗?

我跑了:

  curl --location --request POST 'localhost:8081/' \
    --header 'Content-Type: application/json' \
    --data-raw '  {
  "description": "Third questionnaire",
  "createdDate": "2022-06-23",
  "approvalStatus": "Approved",
  "questionnaireVersion": "V1",
  "isActive": false,
  "questionSet": [
    {
      "text": "Question text"    }
  ]
}'

我的控制器:

@RestController
public class MyController {

    @PostMapping(
            produces =    MediaType.APPLICATION_JSON_VALUE   ,
            consumes =    MediaType.APPLICATION_JSON_VALUE
    )
    public String createQuestionnaire(@RequestBody QuestionnaireDTORequest questionnaireDTORequest){

        if(questionnaireDTORequest != null)
            return "Questionnaire created successfully";
        else
            return "Questionnaire cannot be created";
    }
}

模型是相​​同的仅添加的getters和setter。

TL:DR Add getters and setters to QuestionnaireDTORequest.

Also, that will only make the values null, not the QuestionnaireDTORequest object. Is that the case?

I ran:

  curl --location --request POST 'localhost:8081/' \
    --header 'Content-Type: application/json' \
    --data-raw '  {
  "description": "Third questionnaire",
  "createdDate": "2022-06-23",
  "approvalStatus": "Approved",
  "questionnaireVersion": "V1",
  "isActive": false,
  "questionSet": [
    {
      "text": "Question text"    }
  ]
}'

My controller:

@RestController
public class MyController {

    @PostMapping(
            produces =    MediaType.APPLICATION_JSON_VALUE   ,
            consumes =    MediaType.APPLICATION_JSON_VALUE
    )
    public String createQuestionnaire(@RequestBody QuestionnaireDTORequest questionnaireDTORequest){

        if(questionnaireDTORequest != null)
            return "Questionnaire created successfully";
        else
            return "Questionnaire cannot be created";
    }
}

The model was the same only added Getters and Setters.

REST POST方法接收null dto对象

慕巷 2025-02-18 05:48:56

而不是 doc.id 使用地图项目索引,例如Bellow。看看它是否有效。

{imageData.map((index, doc) => (
   <button
      key={index}
          className="fileBtn"
            onClick={() => viewImageFile(doc)}>
                <FaIcons.FaImage /> {doc.imageName}
   </button>
))}

Instead of doc.id use map item index like bellow. See if it works.

{imageData.map((index, doc) => (
   <button
      key={index}
          className="fileBtn"
            onClick={() => viewImageFile(doc)}>
                <FaIcons.FaImage /> {doc.imageName}
   </button>
))}

反应重复的关键警告

慕巷 2025-02-18 05:34:48

首先在列表中使用flatten dictonary创建元组列表,然后传递到dataframe构造函数:

L = [(a, k, v) for a, b in zip(df['TopicID'], df['keywords']) for k, v in b.items()]
df_final = pd.DataFrame(L, columns=['TopicID','Keyword','Value'])
print (df_final)
    TopicID     Keyword  Value
0       797     licence  0.529
1       797     chapter  0.462
2       797    explains  0.263
3       797     visitor  0.244
4       797    resident  0.220
5       797    applying  0.205
6       797  privileges  0.199
7       797   graduated  0.188
8       797       tests  0.184
9       797   licensing  0.180
10      798   emotional  0.352
11      798      mental  0.327
12      798       state  0.309
13      798     operate  0.295
14      798       drive  0.242
15      798       motor  0.227
16      798     ability  0.227
17      798        next  0.176
18      798     illness  0.176
19      798    diminish  0.176

Create list of tuples by flatten dictonary in list comprehension first and then pass to DataFrame constructor:

L = [(a, k, v) for a, b in zip(df['TopicID'], df['keywords']) for k, v in b.items()]
df_final = pd.DataFrame(L, columns=['TopicID','Keyword','Value'])
print (df_final)
    TopicID     Keyword  Value
0       797     licence  0.529
1       797     chapter  0.462
2       797    explains  0.263
3       797     visitor  0.244
4       797    resident  0.220
5       797    applying  0.205
6       797  privileges  0.199
7       797   graduated  0.188
8       797       tests  0.184
9       797   licensing  0.180
10      798   emotional  0.352
11      798      mental  0.327
12      798       state  0.309
13      798     operate  0.295
14      798       drive  0.242
15      798       motor  0.227
16      798     ability  0.227
17      798        next  0.176
18      798     illness  0.176
19      798    diminish  0.176

如何在PANDAS DataFrame中标准化一列字典类型?

慕巷 2025-02-18 03:45:38

一种选择是,

bool foo4(uint64_t x)
{
    return (((x << 1) >> 53) + 1) >> 11;
}

哪个与GCC一起编译到

foo:
        ubfx    r0, r1, #20, #11
        adds    r0, r0, #1
        ubfx    r0, r0, #11, #1
        bx      lr

此处的保存中,主要来自不必转换为0/1结果,而是直接生成1位。如果将此功能夹住并将结果用于分支,则无用,实际上可能导致代码较慢。

One option is

bool foo4(uint64_t x)
{
    return (((x << 1) >> 53) + 1) >> 11;
}

which compiles with gcc to

foo:
        ubfx    r0, r1, #20, #11
        adds    r0, r0, #1
        ubfx    r0, r0, #11, #1
        bx      lr

The saving here mostly comes from not having to convert to a 0/1 result but generating an 1 bit directly. If this function is inlined and the result is used for a branch, this is not helpful and might actually result in slower code.

如何“位和面具等于面具”可以优化吗?

慕巷 2025-02-18 02:48:15

最后,我从队列和进程更改为conturrent.futures's ProcessPoolExecutor,正如@CharChit所暗示的,我必须移动我的映射函数计算到模块的顶级级别,以便可以腌制。该解决方案对我来说非常有用,因为除了这个问题外,我还需要在Multecrocess.pool本身内运行start_multicore_task,这是一个无法产生孩子的守护程序虽然来自并发的一个池,但在其内部运行平稳。

from concurrent.futures import ProcessPoolExecutor as Pool
from functools import partial
import numpy as np


def calculate_row(in_data, nres):
    "function to fill a row of what will be a square numpy array"
    res, others = in_data
    row = np.zeros((nres,))

    for other in others:
        # in my real code, which also doesn't work, obviously this performs a more
        # complex calculation to add to the row[other] array position
        row[other] = other

    return res, row




def start_multicore_task(nres, cores_per_task):
    in_data = []
    iterator = set(range(nres))
    for res1 in iterator:
        # "others" are every value in "iterator" higher than res1 itself
        others = list(iterator - set(range(res1)) - {res1})
        if len(others) > 0:
            # a check because the last value in "iterator" won't have any value higher than itself
            in_data.append((res1, others))

            
        
    with Pool(cores_per_task) as p:
        results = list(p.map(partial(calculate_row, nres=nres), in_data, chunksize=len(in_data)/(cores_per_task*2)))
        p.shutdown()
        
    
    corr = np.zeros((nres, nres))
    for result in results:
        res, row = result
        corr[res, :] = row
    
        
    return corr

In the end, I changed from Queues and Processes to a concurrent.futures's ProcessPoolExecutor and, as hinted by @Charchit, I had to move my mapped function calculate_row to the top-level of the module so that it could be pickled. This solution works great for me because, besides this problem, I need to run the start_multicore_task inside a multiprocess.Pool itself, which is a daemonic process that can't spawn children of its own, while a Pool from concurrent.futures runs smoothly inside it.

from concurrent.futures import ProcessPoolExecutor as Pool
from functools import partial
import numpy as np


def calculate_row(in_data, nres):
    "function to fill a row of what will be a square numpy array"
    res, others = in_data
    row = np.zeros((nres,))

    for other in others:
        # in my real code, which also doesn't work, obviously this performs a more
        # complex calculation to add to the row[other] array position
        row[other] = other

    return res, row




def start_multicore_task(nres, cores_per_task):
    in_data = []
    iterator = set(range(nres))
    for res1 in iterator:
        # "others" are every value in "iterator" higher than res1 itself
        others = list(iterator - set(range(res1)) - {res1})
        if len(others) > 0:
            # a check because the last value in "iterator" won't have any value higher than itself
            in_data.append((res1, others))

            
        
    with Pool(cores_per_task) as p:
        results = list(p.map(partial(calculate_row, nres=nres), in_data, chunksize=len(in_data)/(cores_per_task*2)))
        p.shutdown()
        
    
    corr = np.zeros((nres, nres))
    for result in results:
        res, row = result
        corr[res, :] = row
    
        
    return corr

优化/正确的Python多处理队列和过程的组合

慕巷 2025-02-18 01:48:21

外键是一对一的关系。在您的情况下,一个类别可以拥有许多品牌,因此,如果该品牌必须属于另一个类别,则在这种情况下也意味着您必须将关系从外国密钥关系更改为多一到多的关系。

检查以下链接以获取参考

https:> https://djangoproject.com /EN/4.0/topics/db/examples/many_to_many/


class Brand(models.Model):
    """
        This model is use to store the data of products sub category
    """
    user = models.ForeignKey(User, related_name='brand_user', on_delete=models.CASCADE,null=True,blank=True, default=None)
    name = models.CharField(max_length=50, unique=True, verbose_name="Brand Name")
    brand_img = models.FileField(verbose_name='Upload Image')
    category = models.ManyToManyField(Brand_Category,related_name='brand_category')
    slug = models.SlugField(max_length=140, unique=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True)


Foreign Key is One to Many Relation. In your case, one category can have many Many Brands so if the brand has to be in another category also means in that case you have to change the relationship from Foreign key relation to Many-to-Many Relation.

Check the below link for reference

https://docs.djangoproject.com/en/4.0/topics/db/examples/many_to_many/


class Brand(models.Model):
    """
        This model is use to store the data of products sub category
    """
    user = models.ForeignKey(User, related_name='brand_user', on_delete=models.CASCADE,null=True,blank=True, default=None)
    name = models.CharField(max_length=50, unique=True, verbose_name="Brand Name")
    brand_img = models.FileField(verbose_name='Upload Image')
    category = models.ManyToManyField(Brand_Category,related_name='brand_category')
    slug = models.SlugField(max_length=140, unique=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True)


如何在外键字段中存储多个值?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文