小编Ana*_*kov的帖子

aws ecs 执行命令失败,因为未启用

我在跑步aws ecs execute-command --cluster UltimaF --task 838d773b17954bcfbbacf343fb4fea70 --container ultima --interactive --command "/bin/sh"

\n

取回:An error occurred (InvalidParameterException) when calling the ExecuteCommand operation: The execute command failed because execute command was not enabled when the task was run or the execute command agent isn\xe2\x80\x99t running. Wait and try again or run a new task with execute command enabled and try again.

\n

我已保证:

\n
    \n
  1. 任务正在运行。
  2. \n
  3. aws ecs describe-tasks --cluster UltimaF --tasks 838d773b17954bcfbbacf343fb4fea70回报"enableExecuteCommand": true
  4. \n
  5. 任务角色附加了以下权限:\n …

execute amazon-web-services amazon-ecs aws-cli

9
推荐指数
2
解决办法
1万
查看次数

Docker django.db.utils.OperationalError:无法将主机名“db”转换为地址:名称解析暂时失败

似乎是一个常见错误。我遵循了 Stackoverflow 上所有可能的建议(添加链接、网络等),但这对我来说没有什么区别。我在 Windows 上运行。

我的 Dockerfile:

#Pull base image.
FROM python:3.9.5-slim

#Usefull to get logs
ENV PYTHONUNBUFFERED 1

#Make local dir
RUN mkdir -p /app

#set as the working directory
WORKDIR /app

#https://luis-sena.medium.com/creating-the-perfect-python-dockerfile-51bdec41f1c8
COPY requirements.txt .

#now copy all the files in this directory to \code
ADD . .

#https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/
RUN apt-get update && \
 apt-get install -y postgresql-server-dev-all gcc python3-dev musl-dev && \
 pip install -r requirements.txt && \
 adduser --disabled-password --no-create-home app

USER app

#CMD python manage.py …
Run Code Online (Sandbox Code Playgroud)

python django postgresql django-rest-framework docker

6
推荐指数
1
解决办法
2万
查看次数

Rust Polars:是否可以将列表列分解为多个列?

我有一个返回列表类型列的函数。因此,我的专栏之一是一个列表。我想将此列表列变成多列。例如:

\n
use polars::prelude::*;\nuse polars::df;\n\nfn main() {\n    let s0 = Series::new("a", &[1i64, 2, 3]);\n    let s1 = Series::new("b", &[1i64, 1, 1]);\n    let s2 = Series::new("c", &[Some(2i64), None, None]);\n    // construct a new ListChunked for a slice of Series.\n    let list = Series::new("foo", &[s0, s1, s2]);\n\n    // construct a few more Series.\n    let s0 = Series::new("Group", ["A", "B", "A"]);\n    let s1 = Series::new("Cost", [1, 1, 1]);\n    let df = DataFrame::new(vec![s0, s1, list]).unwrap();\n\n    dbg!(df);\n
Run Code Online (Sandbox Code Playgroud)\n

在这个阶段 DF 看起来像这样:

\n
\xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n\xe2\x94\x82 Group \xe2\x94\x86 …
Run Code Online (Sandbox Code Playgroud)

explode dataframe rust rust-polars python-polars

5
推荐指数
1
解决办法
4794
查看次数

如何在 Rust 中序列化 Arc<Mutex<T>>?

我有一个特质DataSet,我是Serialize这样实现的:

impl Serialize for dyn DataSet {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: Serializer,
    {
        let mut seq = serializer.serialize_map(Some(2))?;
        seq.serialize_entry("fields", "Hello")?;
        seq.serialize_entry("measures", "There")?;
        seq.end()
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,在程序/应用程序中,我共享指向特征对象的指针:

let x: Arc<Mutex<dyn DataSet>> = Arc::new(Mutex::new(data));
Run Code Online (Sandbox Code Playgroud)

哪里data有实现 DataSet 的对象。

现在,我想把这个对象转换成json(即序列化它):

serde_json::to_string(&x)
Run Code Online (Sandbox Code Playgroud)

它适用于Box而不是Arc<Mutex<>>. 但Arc<Mutex<>>编译器抱怨:

the size for values of type `dyn base_engine::DataSet` cannot be known at compilation time
the trait `Sized` is not implemented for `dyn base_engine::DataSet`
the …
Run Code Online (Sandbox Code Playgroud)

rust serde

4
推荐指数
1
解决办法
1210
查看次数

我可以将 Arc&lt;dyn MyTrait&gt; 传递给需要 Arc&lt;impl MyTrait&gt; 的函数吗?

Jon Gjengset在Rust for Rustaceans中指出(强调我的):

\n
\n

当您\xe2\x80\x99 在静态和动态调度之间进行选择时,\n很少有明确的正确答案。不过,从广义上讲,您\xe2\x80\x99ll\n希望在库中使用静态调度,在二进制文件中使用动态调度。在库中,您希望允许用户决定哪种类型的调度最适合他们,因为您不知道他们的需求是什么。如果您使用动态调度,它们\xe2\x80\x99将被迫执行相同的操作,而如果您使用\n静态调度,它们可以选择是否使用动态调度。

\n
\n

我对此的解释是:

\n
    \n
  • 在库中应该使用:fn execute(x: Arc<impl MyTrait>) -> ...这是静态调度。

    \n
  • \n
  • 在二进制文件中:let x: Arc<dyn MyTrait> = Arc::new(my_obj)这是动态的。

    \n
  • \n
\n

然后我想调用execute(x),但编译器抱怨:

\n
error[E0277]: the size for values of type `dyn MyTrait` cannot be known at compilation time\n  --> src/main.rs:12:13\n   |\n12 |     execute(x);\n   |     ------- ^ doesn\'t have a size known at compile-time\n   |     |\n   |     required by a bound introduced …
Run Code Online (Sandbox Code Playgroud)

types traits dispatch rust

4
推荐指数
1
解决办法
387
查看次数