小编use*_*174的帖子

maven-resources-plugin:2.6 - 无法创建资源输出目录

所以我刚从EC2创建了一个Linux实例,现在我正在尝试在其上安装AWS Java SDK.当我跑步时,我在安装结束时mvn clean compile exec:java得到这个:

[ec2-user@ip-xxx-xxx-xxx-xxx aws-java-sample]$ mvn clean compile exec:java
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building aws-java-sample 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ aws-java-sample ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ aws-java-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: x.xxx s
[INFO] Finished at: xxxx-xx-xxTxx:xx:xx+xx:xx
[INFO] Final Memory: M/xM
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) …
Run Code Online (Sandbox Code Playgroud)

java linux amazon-ec2 maven aws-java-sdk

8
推荐指数
2
解决办法
9816
查看次数

如何将数据集写入Cassandra?

所以我有一个Python Stream-sourced DataFrame df,它包含我想要放入带有spark-cassandra-connector的Cassandra表的所有数据.我试过两种方式:

df.write \
    .format("org.apache.spark.sql.cassandra") \
    .mode('append') \
    .options(table="myTable",keyspace="myKeySpace") \
    .save() 

query = df.writeStream \
    .format("org.apache.spark.sql.cassandra") \
    .outputMode('append') \
    .options(table="myTable",keyspace="myKeySpace") \
    .start()

query.awaitTermination()
Run Code Online (Sandbox Code Playgroud)

但是我继续分别得到这个错误:

pyspark.sql.utils.AnalysisException: "'write' can not be called on streaming Dataset/DataFrame;
Run Code Online (Sandbox Code Playgroud)

java.lang.UnsupportedOperationException: Data source org.apache.spark.sql.cassandra does not support streamed writing.
Run Code Online (Sandbox Code Playgroud)

无论如何我可以将我的Streaming DataFrame发送到我的Cassandra表中吗?

apache-spark pyspark spark-cassandra-connector spark-structured-streaming

8
推荐指数
2
解决办法
1768
查看次数

ImportError:没有名为'tasks'的模块

我正在努力让Celery与django合作设置预定的任务.我试着找过的第一步W /芹菜第一步骤瓦特/ Django的教程,并没有一直为我工作.这是我的项目布局与相关文件:

Python 3.5.1

Django 1.10

芹菜4.0.2

RabbitMQ 3.6.6

OTP 19.2

mysite/ (project name)
    polls/ (myapp)
        tasks
        ...
    mysite/
        __init__
        celery
        settings
        ...
    manage
    ...
Run Code Online (Sandbox Code Playgroud)

mysite的/ __ init__.py:

from __future__ import absolute_import, unicode_literals

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

__all__ = ['celery_app']
Run Code Online (Sandbox Code Playgroud)

民调/ celery.py:

from __future__ import absolute_import, unicode_literals
import os
from celery import …
Run Code Online (Sandbox Code Playgroud)

python django scheduled-tasks celery

7
推荐指数
1
解决办法
6707
查看次数

Django-Celery 正在生产中吗?

所以我一直在试图弄清楚如何制定计划任务,我找到了 Celery 并且能够制定简单的计划任务。为此,我需要打开命令行并运行celery -A proj beat以使任务发生。这在开发环境中工作得很好,但是当将其投入生产时,这将是一个问题。

那么如何在不使用命令行的情况下让 celery 工作呢?当我的生产服务器在线时,如何确保我的调度程序能够正常运行?芹菜可以做到这一点还是我需要采用另一种方法?

django celery django-celery

7
推荐指数
1
解决办法
6162
查看次数

访问模型属性的rails返回nil

所以我上了一堂ItemActiveRecord::Base.我已经实施了这个show动作,以便我可以看到它items\id.在show.html.erb我已访问所有属性并在文件上标记它们.当我进入网页时,没有任何属性出现,只有他们的标签.然后我去看看出了什么问题.@item存储属性的对象出现了,但是当我逐个检查所有属性时,它们都是nil.有谁知道为什么会这样?

[时间戳] _create_items.rb:

class CreateItems < ActiveRecord::Migration
    def change
        create_table :items do |t|
            t.string :name
            t.text :description
            t.decimal :price

            t.timestamps null: false
        end
    end
end
Run Code Online (Sandbox Code Playgroud)

item.rb的:

class Item < ActiveRecord::Base
    attr_accessor :name, :description, :price
    validates :name, presence: true, uniqueness: true, length: { maximum: 100 }
    validates :description, presence: true,
        length: { maximum: 1000 }
    VALID_PRICE_REGEX = /\A\d+(?:\.\d{0,2})?\z/
    validates :price, presence: true,
        :format => { with: VALID_PRICE_REGEX …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails rails-activerecord

4
推荐指数
2
解决办法
1787
查看次数

Rails 唯一性验证测试失败

我从 Rails 4.2 开始,我尝试测试我正在制作的 Item 模型的唯一性,我运行了以下代码:

项目.rb:

class Item < ActiveRecord::Base
    attr_accessor :name
    validates :name, uniqueness: true #, other validations...
end
Run Code Online (Sandbox Code Playgroud)

item_test.rb:

require 'test_helper'

class ItemTest < ActiveSupport::TestCase

    def setup
        @item = Item.new(name: "Example Item")
    end

    test "name should be unique" do
        duplicate_item = @item.dup
        @item.save
        assert_not duplicate_item.valid?
    end
end
Run Code Online (Sandbox Code Playgroud)

但是测试没有通过,说assert_not线路true在应该出来的时候出来了nil或者false。我基本上从教程中得到了这段代码,但不知道为什么它没有通过。有什么帮助吗?

编辑:我找到了解决方案,通过不定义我在操作中定义的其他成员(特别是:price),测试通过了。但是现在我不知道如何让它通过成员。下面是 item.rb 和 item_test.rb 的完整实现。@itemsetup:price

项目.rb:

class Item < ActiveRecord::Base
    attr_accessor :name, :description, :price
    validates …
Run Code Online (Sandbox Code Playgroud)

testing validation ruby-on-rails unique

3
推荐指数
1
解决办法
3334
查看次数

如何显示流式DataFrame(显示失败并带有AnalysisException)?

因此,我在Kafka主题中流了一些数据,我正在获取这些流数据并将其放入DataFrame。我想在DataFrame中显示数据:

import os
from kafka import KafkaProducer
from pyspark.sql import SparkSession, DataFrame
import time
from datetime import datetime, timedelta

os.environ['PYSPARK_SUBMIT_ARGS'] = '--packages org.apache.spark:spark-sql-kafka-0-10_2.11:2.2.0,org.apache.spark:spark-streaming-kafka-0-8_2.11:2.2.0 pyspark-shell'

topic_name = "my-topic"
kafka_broker = "localhost:9092"

producer = KafkaProducer(bootstrap_servers = kafka_broker)
spark = SparkSession.builder.getOrCreate()
terminate = datetime.now() + timedelta(seconds=30)

while datetime.now() < terminate:
    producer.send(topic = topic_name, value = str(datetime.now()).encode('utf-8'))
    time.sleep(1)

readDF = spark \
    .readStream \
    .format("kafka") \
    .option("kafka.bootstrap.servers", kafka_broker) \
    .option("subscribe", topic_name) \
    .load()
readDF = readDF.selectExpr("CAST(key AS STRING)","CAST(value AS STRING)")

readDF.writeStream.format("console").start()
readDF.show() …
Run Code Online (Sandbox Code Playgroud)

apache-kafka apache-spark pyspark spark-structured-streaming

3
推荐指数
1
解决办法
4082
查看次数

Rails faker gem 产生相同的产品名称

我正在尝试使用 Rails Faker gem 生成唯一的产品名称,以在数据库中创建示例项目模型。我已经多次使用 Faker,但由于某种原因我无法生成新的产品名称。我已经创建了 nameMaker 函数来避免可能的早期重复,但在一次插入后我就得到了一条记录失效。有谁知道我该如何解决这个问题?

种子.rb:

98.times do |n|
    name = Item.nameMaker
    description = Faker::Lorem.sentence(1)
    price = Item.priceMaker
    item = Item.create!(
        name: name,
        description: description,
        price: price)
    end
Run Code Online (Sandbox Code Playgroud)

项目.rb:

class Item < ActiveRecord::Base
    validates :name, presence: true, length: { maximum: 100 }
    validates :description, presence: true,
        length: { maximum: 1000 }
    VALID_PRICE_REGEX = /\A\d+(?:\.\d{0,3})?\z/
    validates :price, presence: true,
        :format => { with: VALID_PRICE_REGEX },
        :numericality => {:greater_than => 0}
    validates_uniqueness_of :name  

    def Item.nameMaker
        loop do
            name = …
Run Code Online (Sandbox Code Playgroud)

random ruby-on-rails faker ruby-on-rails-4

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

json.decoder.JSONDecodeError:意外的 UTF-8 BOM(使用 utf-8-sig 进行解码)

所以我的目标是使用 ISO Alpha-2 国家/地区代码找到一个国家/地区的名称。我认为这是第一次尝试 RESTful API(确切地说是世界银行 API )的好时机。我开始使用本教程来尝试实现我的目标,它似乎requests.get()是我问题的答案,我尝试了一下并得到了这个:

(InteractiveConsole)
>>> import requests
>>> resp = requests.get('http://api.worldbank.org/countries/br')
>>> resp
<Response [200]>
>>> resp.json()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\site-packages\requests\models.py", line 866, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\json\__init__.py", line 315, in loads
    s, 0)
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
Run Code Online (Sandbox Code Playgroud)

我不太确定出了什么问题或者它告诉我要做什么(我对 JSON 不太熟悉)。对此有什么解释以及如何解决它吗?

我在用:

Windows 7 64 位

Python 3.5.1

姜戈 …

python django rest json

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

'UpdateView' 对象没有属性 'object'

所以我一直在尝试向我一直在使用的 UpdateView 添加一个取消按钮。这是我的代码:

视图.py:

class CountryEditView(generic.edit.UpdateView):
    model = Country
    fields = ['name']
    template_name_suffix = '_edit'  

    def post(self, request, *args, **kwargs):
        if "cancel" in request.POST:
            url = self.object.get_absolute_url()
            return HttpResponseRedirect(url)
        else:
            return super(CountryEditView, self).post(request, *args, **kwargs)
# etc....
Run Code Online (Sandbox Code Playgroud)

模型.py:

class Country(AutoUpdateModel): #A subclass of models.Model
    def get_absolute_url(self):
        return reverse('appName:country_info', args=(self.id,))
    #etc...
Run Code Online (Sandbox Code Playgroud)

country_edit.html:

<form action="" method="post">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Update" />
    <input type="submit" name="cancel" value="Cancel" />
</form>
Run Code Online (Sandbox Code Playgroud)

但是我一直收到这个错误:

Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\exception.py", line 42, …
Run Code Online (Sandbox Code Playgroud)

python django django-views

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

Hadoop启动ResourceManager和NodeManager时出错

我正在尝试使用单节点集群(Psuedo分布式)设置Hadoop3-alpha3,并使用apache指南进行设置。我尝试运行示例MapReduce作业,但是每次拒绝连接时。运行后,sbin/start-all.sh我一直在ResourceManager日志(以及类似的NodeManager日志)中看到这些异常:

xxxx-xx-xx xx:xx:xx,xxx INFO org.apache.commons.beanutils.FluentPropertyBeanIntrospector: Error when creating PropertyDescriptor for public final void org.apache.commons.configuration2.AbstractConfiguration.setProperty(java.lang.String,java.lang.Object)! Ignoring this property.
xxxx-xx-xx xx:xx:xx,xxx DEBUG org.apache.commons.beanutils.FluentPropertyBeanIntrospector: Exception is:
java.beans.IntrospectionException: bad write method arg count: public final void org.apache.commons.configuration2.AbstractConfiguration.setProperty(java.lang.String,java.lang.Object)
    at java.desktop/java.beans.PropertyDescriptor.findPropertyType(PropertyDescriptor.java:696)
    at java.desktop/java.beans.PropertyDescriptor.setWriteMethod(PropertyDescriptor.java:356)
    at java.desktop/java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:142)
    at org.apache.commons.beanutils.FluentPropertyBeanIntrospector.createFluentPropertyDescritor(FluentPropertyBeanIntrospector.java:178)
    at org.apache.commons.beanutils.FluentPropertyBeanIntrospector.introspect(FluentPropertyBeanIntrospector.java:141)
    at org.apache.commons.beanutils.PropertyUtilsBean.fetchIntrospectionData(PropertyUtilsBean.java:2245)
    at org.apache.commons.beanutils.PropertyUtilsBean.getIntrospectionData(PropertyUtilsBean.java:2226)
    at org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:954)
    at org.apache.commons.beanutils.PropertyUtilsBean.isWriteable(PropertyUtilsBean.java:1478)
    at org.apache.commons.configuration2.beanutils.BeanHelper.isPropertyWriteable(BeanHelper.java:521)
    at org.apache.commons.configuration2.beanutils.BeanHelper.initProperty(BeanHelper.java:357)
    at org.apache.commons.configuration2.beanutils.BeanHelper.initBeanProperties(BeanHelper.java:273)
    at org.apache.commons.configuration2.beanutils.BeanHelper.initBean(BeanHelper.java:192)
    at org.apache.commons.configuration2.beanutils.BeanHelper$BeanCreationContextImpl.initBean(BeanHelper.java:669)
    at org.apache.commons.configuration2.beanutils.DefaultBeanFactory.initBeanInstance(DefaultBeanFactory.java:162)
    at org.apache.commons.configuration2.beanutils.DefaultBeanFactory.createBean(DefaultBeanFactory.java:116)
    at org.apache.commons.configuration2.beanutils.BeanHelper.createBean(BeanHelper.java:459)
    at org.apache.commons.configuration2.beanutils.BeanHelper.createBean(BeanHelper.java:479)
    at org.apache.commons.configuration2.beanutils.BeanHelper.createBean(BeanHelper.java:492)
    at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.createResultInstance(BasicConfigurationBuilder.java:447)
    at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.createResult(BasicConfigurationBuilder.java:417)
    at …
Run Code Online (Sandbox Code Playgroud)

java hadoop resourcemanager hadoop3

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

Python Cassandra浮动精度损失

我正在发送来回Python和Cassandra的数据.我float在我的python程序中使用了内置 类型和我的Cassandra表的数据类型.如果我955.99从python 发送一个数字到Cassandra,它会显示在数据库中955.989999.当我在python中发送一个查询以返回我刚刚发送的值时,现在就是955.989990234375.

我理解python中精确丢失的问题,我只是想知道Cassandra中是否存在可以防止此问题的任何内置机制.

python floating-point precision cassandra cassandra-python-driver

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