我已使用TokenAuthentication启用了使用DRF的用户身份验证
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication'
),
'DEFAULT_MODEL_SERIALIZER_CLASS':
'rest_framework.serializers.ModelSerializer',
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.AllowAny',
),
#'EXCEPTION_HANDLER': 'apps.core.exceptions.custom_exception_handler'
}
Run Code Online (Sandbox Code Playgroud)
我有以下型号:
class Device(CreationModificationMixin):
"""
Contains devices (WW controllers). A device may be associated with the Owner
"""
_STATUSES = (
('A', 'Active'), # when everything is okay
('I', 'Inactive'), # when we got nothing from SPA controllers for X minutes
('F', 'Failure'), # when controller says it has issues
)
_TYPES = (
('S', 'Spa'),
('P', 'Pool'),
)
udid = models.CharField(max_length=255, verbose_name="Unique …Run Code Online (Sandbox Code Playgroud) authentication django django-authentication django-rest-framework
In [88]: c
Out[88]:
Address Name
CustomerID
10 Address for Mike Mike
11 Address for Marcia Marcia
In [89]: c.index
Out[89]: Int64Index([10, 11], dtype='int64', name='CustomerID')
In [90]: orders
Out[90]:
CustomerID OrderDate
0 10 2014-12-01
1 11 2014-12-01
2 10 2014-12-01
In [91]: orders.index
Out[91]: RangeIndex(start=0, stop=3, step=1)
In [92]: c.merge(orders)
---------------------------
MergeError: No common columns to perform merge on
Run Code Online (Sandbox Code Playgroud)
如果一个数据帧中的索引列与第二个数据帧中的另一列具有相同的名称,那么panda无法合并?
因此,如果集群是使用以下命令创建的
eksctl create cluster -f config/prod.yaml
Run Code Online (Sandbox Code Playgroud)
产品.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
....
Run Code Online (Sandbox Code Playgroud)
如果 prod.yaml 文件丢失(无法再访问),如何获取当前版本?
如何获得 Kubernetes 内服务的完整 FQDN?
? k get svc -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
airflow-flower-service ClusterIP 172.20.119.107 <none> 5555/TCP 20d app=edna-airflow
airflow-service ClusterIP 172.20.76.63 <none> 80/TCP 20d app=edna-airflow
backend-service ClusterIP 172.20.39.154 <none> 80/TCP 20d app=edna-backend
Run Code Online (Sandbox Code Playgroud)
那么如何查询内部 Kubernetes DNS 以获取后端服务的 FQDN?
#!/bin/zsh
zk_servers=('10.138.0.8' '10.138.0.9' '10.138.0.16')
kafka_servers=('10.138.0.13:9092' '10.138.0.14:9092')
topics=('t1' 't2' 't1_failed' 't2_failed')
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2; tput bold)
YELLOW=$(tput setaf 3)
RED=$(tput setaf 1)
function red() {
echo -e "$RED$*$NORMAL"
}
function green() {
echo -e "$GREEN$*$NORMAL"
}
function yellow() {
echo -e "$YELLOW$*$NORMAL"
}
for topic in $topics; do
yellow "Cleaning up messages in topic @ " $topic
yellow "=============================================================="
$KAFKA/kafka-topics.sh --zookeeper $zk_servers --alter --topic $topic --config retention.ms=100
$KAFKA/kafka-topics.sh --zookeeper $zk_servers --describe --topic $topic
done
red "Waiting 120 seconds for …Run Code Online (Sandbox Code Playgroud) 我使用以下命令生成ctags
ctags -R --fields=+l --languages=python --python-kinds=-iv -f ./tags apps/employees/models.py
Run Code Online (Sandbox Code Playgroud)
这是我的代码
from django.contrib.auth.models import AbstractUser
from django.contrib.postgres.fields import HStoreField
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from author.decorators import with_author
from django_extensions.db.models import TimeStampedModel
from django_fsm import FSMField
from imagekit import models as imagekitmodels
from imagekit.processors import ResizeToFill
from phonenumber_field.modelfields import PhoneNumberField
from timezone_field import TimeZoneField
from libs import utils
# Solution to avoid unique_together for email
AbstractUser._meta.get_field('email')._unique = …Run Code Online (Sandbox Code Playgroud) import pandas as pd
d = {
'resource': [1,2,3,4,5,6,7],
'branch': ['a', 'b', 'c', 'a', 'a', 'c', 'b'],
'utilization': [0.7, 0.76, 0.9, 0.3, 0.55, 0.87, 0.71]
}
df = pd.DataFrame(data=d)
Run Code Online (Sandbox Code Playgroud)
像这样的东西:
df.groupby('branch')[['resource', 'utilization']].nlargest(2, 'utilization')
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法:
f = lambda x: x.sort_values('utilization', ascending=False)
df.groupby('branch', sort=False).apply(f).nlargest(3, 'utilization')
Run Code Online (Sandbox Code Playgroud)
但是当我在每组中需要前N时,它会让我在所有记录中排名前三
resource branch utilization
branch
c 2 3 c 0.90
5 6 c 0.87
b 1 2 b 0.76
Run Code Online (Sandbox Code Playgroud) \xe2\x9e\x9c terraform -v \nTerraform v0.12.24\n+ provider.aws v2.60.0\n\nRun Code Online (Sandbox Code Playgroud)\n\n我的地形example.tf:
\n\nlocals {\n standard_tags = {\n team = var.team\n project = var.project\n component = var.component\n environment = var.environment\n }\n}\n\nprovider "aws" {\n profile = "profile"\n region = var.region\n}\n\nresource "aws_key_pair" "security_key" {\n key_name = "security_key"\n public_key = file(".ssh/key.pub")\n}\n\n# New resource for the S3 bucket our application will use.\nresource "aws_s3_bucket" "project_bucket" {\n # NOTE: S3 bucket names must be unique across _all_ AWS accounts, so\n # this name must be changed before …Run Code Online (Sandbox Code Playgroud) 我定期看到容器 状态:已终止 - OOMKilled(退出代码:137)
但是被调度到内存充足的节点
$ k get statefulset -n metrics
NAME READY AGE
prometheus 0/1 232d
$ k get po -n metrics
prometheus-0 1/2 CrashLoopBackOff 147 12h
$ k get events -n metrics
LAST SEEN TYPE REASON OBJECT MESSAGE
10m Normal Pulled pod/prometheus-0 Container image "prom/prometheus:v2.11.1" already present on machine
51s Warning BackOff pod/prometheus-0 Back-off restarting failed container
k logs -f prometheus-0 -n metrics --all-containers=true
level=warn ts=2020-08-22T20:48:02.302Z caller=main.go:282 deprecation_notice="'storage.tsdb.retention' flag is deprecated use 'storage.tsdb.retention.time' instead."
level=info ts=2020-08-22T20:48:02.302Z caller=main.go:329 …Run Code Online (Sandbox Code Playgroud) 尝试在 Python 2.7.8 中实现以下目标
class X:
pass
a = X()
b = X()
t={1: {1: a, 2: b}}
map(lambda x: setattr(x, 'test', 'wow'), t[1].values())
Run Code Online (Sandbox Code Playgroud)
给出:[None,None],虽然我希望它将每个属性“test”设置为“wow”,如果我在map()之外调用setattr(a,“test”,“wow”)那么一切正常
kubernetes ×3
python ×3
amazon-eks ×2
pandas ×2
apache-kafka ×1
ctags ×1
dictionary ×1
django ×1
dns ×1
eksctl ×1
prometheus ×1
python-2.7 ×1
terraform ×1
vim ×1