我对诗歌很陌生,想用 pytest 来设置它。我在以下设置中有一个包 mylib
\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 dist\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 mylib-0.0.1-py3-none-any.whl\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 mylib-0.0.1.tar.gz\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 poetry.lock\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 mylib\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 functions.py\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 utils.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pyproject.toml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.md\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tests\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test_functions.py\nRun Code Online (Sandbox Code Playgroud)\n在 test_functions 我有
\nimport mylib\nRun Code Online (Sandbox Code Playgroud)\n然而,当我跑步时
\npoetry run pytest\nRun Code Online (Sandbox Code Playgroud)\n它抱怨mylib没有被包括在内。我可以跑
pip install dist/mylib-0.0.1-py3-none-any.whl\nRun Code Online (Sandbox Code Playgroud)\n但这会使我的 python 环境与 mylib 变得混乱。我也想将该环境用于其他包。
\n我的问题是:使用诗歌和 pytest 的正确方法是什么?
\n我的底层 python 环境是干净的 pyenv python 3.8。使用 pyproject.toml 我为 mylib 创建一个基于项目的虚拟环境。
\n我在 neovim (0.5) 中使用 Pyright LSP。它可以工作,但似乎只能选择标准 python 安装中可用的软件包。对于不在基本 python 中但在我的 pyenv 环境中的包,它不会自动完成。在 VSCode 中,通过选择解释器可以很容易地完成此操作。
如何在 Neovim 中设置 Pyright LSP 使用的虚拟环境或 pyenv 版本?
我正在使用ansible配置一台机器.我设法在虚拟机上安装virtualenv和virtualenvwrapper.但是,我似乎无法在vm上创建virtualenv.
我正在尝试使用
- name: create virtualenv test
shell: >
executable=/bin/zsh
source `which virtualenvwrapper.sh` && mkvirtualenv test
register: run_cmd
Run Code Online (Sandbox Code Playgroud)
和
- name: create virtualenv test
action: command mkvirtualenv test
Run Code Online (Sandbox Code Playgroud)
但没有运气.有任何想法吗?
我在 GCP 上设置了一个带有远程后端的 terraform 项目。现在,当我想要部署基础设施时,我遇到了凭据问题。我有一个凭据文件
\home\mike\.config\gcloud\credentials.json
Run Code Online (Sandbox Code Playgroud)
在我的 terraform 项目中,我有以下涉及远程状态的数据:
data "terraform_remote_state" "project_id" {
backend = "gcs"
workspace = "${terraform.workspace}"
config {
bucket = "${var.bucket_name}"
prefix = "${var.prefix_project}"
}
}
Run Code Online (Sandbox Code Playgroud)
我用我的凭据文件的详细信息指定云提供商。
provider "google" {
version = "~> 1.16"
project = "${data.terraform_remote_state.project_id.project_id}"
region = "${var.region}"
credentials = "${file(var.credentials)}"
}
Run Code Online (Sandbox Code Playgroud)
然而,这会遇到
data.terraform_remote_state.project_id: data.terraform_remote_state.project_id:
error initializing backend:
storage.NewClient() failed: dialing: google: could not find default
credentials.
Run Code Online (Sandbox Code Playgroud)
如果我添加
export GOOGLE_APPLICATION_CREDENTIALS=/home/mike/.config/gcloud/credentials.json
Run Code Online (Sandbox Code Playgroud)
我确实让它按预期运行。我的问题是,我想在 terraform 文件中指定凭据,因为我从无法设置环境变量的 python 脚本中以自动方式运行 terraform 命令。如何在不设置环境变量的情况下让 terraform 知道凭据在哪里?
我在Linux上安装了Spyder(确切地说是Mint 17)并使用ipython,numpy等创建了一个科学的virtualenv(sci).我的想法是改变我的python 2/python 3的虚拟环境并且比安装更灵活一点整个Anaconda/python(x,y).我现在遇到让ipython在Spyder工作的问题.
我去了
Tools->Preferences->Console->Advanced settings
Run Code Online (Sandbox Code Playgroud)
使用以下Python解释器
/home/mike/envs/sci/bin/ipython
Run Code Online (Sandbox Code Playgroud)
但这并没有启动ipython.它响应
...
Execute the given command[TerminalIPythonApp] CRITICAL | Bad config encountered during initialization:
[TerminalIPythonApp] CRITICAL | Unrecognized flag: '-u'
...
Run Code Online (Sandbox Code Playgroud)
它也没有在控制台下显示"打开一个IPython控制台".
我缺少什么想法?
欢呼,迈克
我正在尝试将我的入口连接到静态 IP。我似乎正在遵循所有教程,但似乎仍然无法将我的静态 ip 附加到入口。我的ingress文件如下(参考静态ip“test-ip”)
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-web
annotations:
kubernetes.io/ingress.global-static-ip-name: "test-ip"
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/add-base-url: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
rules:
- http:
paths:
- path: /api/
backend:
serviceName: api-cluster-ip-service
servicePort: 5005
- path: /
backend:
serviceName: web-cluster-ip-service
servicePort: 80
Run Code Online (Sandbox Code Playgroud)
然而,当我跑
kubectl get ingress ingress-web
Run Code Online (Sandbox Code Playgroud)
它返回
kubectl get ingress ingress-web
NAME HOSTS ADDRESS PORTS AGE
ingress-web * 80 4m
Run Code Online (Sandbox Code Playgroud)
不给地址。在 VPC 网络中 [外部 IP 地址] 静态 ip 在那里,它是全局的,但它一直说:In use by None
gcloud compute addresses describe test-ip --global
Run Code Online (Sandbox Code Playgroud)
给
address: …Run Code Online (Sandbox Code Playgroud) static-ip-address google-cloud-platform kubernetes-ingress nginx-ingress
我似乎没有让我的 CTest 项目识别我的 Catch2 测试。测试项目本身构建良好,我设法使用它创建的可执行文件运行测试。但是在运行时
ctest -V
Run Code Online (Sandbox Code Playgroud)
我不断得到的输出是:
UpdateCTestConfiguration from :/home/user/code/project/libs/DartConfiguration.tcl
UpdateCTestConfiguration from :/home/user/code/project/libs/DartConfiguration.tcl
Test project /home/user/code/project/libs/
Constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
No tests were found!!!
Run Code Online (Sandbox Code Playgroud)
我的设置如下:
文件夹结构:
libs
??? maths
? ??? matrix.cpp / hpp
? ??? function.cpp / hpp
? ??? CMakeLists.txt
??? ctest
? ??? matrix_test.cpp
? ??? function_test.cpp
? ??? CMakeLists.txt
??? build
Run Code Online (Sandbox Code Playgroud)
???CMakeLists.txt
我从构建文件夹构建 …
我想在端口80上使用node.js站点(我正在使用Digital Ocean).我使用systemd和服务文件这样做
...
ExecStart=/usr/bin/nodejs /var/www/bin/app.js
...
Run Code Online (Sandbox Code Playgroud)
在localhost上,如果我使用sudo启动网站,这在端口80上工作正常,但不是没有sudo.显然,您需要以root身份运行1024以下的端口.
如何在ExecStart中允许sudo?或者我在这里完全错误的方式,如果是这样,我如何在端口80上获得快速应用程序?
干杯,迈克
我正在尝试在 AWS ECS(弹性容器服务)上运行的基于 docker 的应用程序上获取 HTTPS 证书。但是,当最终尝试将 docker 实例部署到 ECS 时,我遇到了一个未定义的问题。
INFO[0120] (service deploy) has started 1 tasks: (task f..........6). timestamp=2018-03-21 14:52:17 +0000 UTC
FATA[0301] Deployment has not completed: Running count has not changed for 5.00 minutes
Run Code Online (Sandbox Code Playgroud)
我的设置是基于https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion谁杠杆https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion
不幸的是,两者都没有给出 AWS ECS 的明确示例。我添加的是让我们加密容器的环境变量中的环境变量 DOCKER_PROVIDER=ecs 。创建我的 docker 容器并将它们上传到 ECS 后,我运行了一个特定于 ecs 的 docker-compose
ecs-cli compose --file docker-compose_ec.yml service up
Run Code Online (Sandbox Code Playgroud)
看起来像
version: '2'
services:
nginx-web:
image: 12344.dkr.ecr.eu-central-1.amazonaws.com/abc_nginx
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy:
"true"
container_name: ${NGINX_WEB}
restart: always
ports:
- "$0.0.0.0:80:80"
- "$0.0.0.0:443:443"
volumes: …Run Code Online (Sandbox Code Playgroud) 我正在尝试获取一个服务帐户,以便从 Python 脚本中在 Google Cloud Storage 中创建 blob,但我遇到了凭据问题。
1) 我为我的项目创建服务帐户,然后下载 json 格式的密钥文件:
"home/user/.config/gcloud/service_admin.json"
Run Code Online (Sandbox Code Playgroud)
2)我为服务帐户提供必要的凭据(通过子流程中的 gcloud)
roles/viewer, roles/storage.admin, roles/resourcemanager.projectCreator, roles/billing.user
Run Code Online (Sandbox Code Playgroud)
然后我想访问GCS中的一个bucket
from google.cloud import storage
import google.auth
credentials, project = google.auth.default()
client = storage.Client('myproject', credentials=credentials)
bucket = client.get_bucket('my_bucket')
Run Code Online (Sandbox Code Playgroud)
不幸的是,这会导致:
google.api_core.exceptions.Forbidden: 403 GET
https://www.googleapis.com/storage/v1/b/my_bucket?projection=noAcl:
s_account@myproject.iam.gserviceaccount.com does not have
storage.buckets.get access to my_bucket
Run Code Online (Sandbox Code Playgroud)
如果我设置环境变量,我的运气会更好一些
export GOOGLE_APPLICATION_CREDENTIALS="home/user/.config/gcloud/service_admin.json"
Run Code Online (Sandbox Code Playgroud)
并重新运行脚本。但是,我希望这一切都在创建帐户的脚本的一个实例中运行,并继续在存储桶中创建必要的文件。如果我知道我的 json 凭证文件在哪里,如何访问 my_bucket。
google-cloud-storage google-cloud-platform google-cloud-python