小编hoe*_*ing的帖子

我在 babel 构建用于生产的角度应用程序时遇到问题

当前行为我正在 circleci 上构建我的 angular 项目,但它一直失败并显示以下消息:发生未处理的异常:找不到模块“@babel/compat-data/corejs3-shipped-proposals”

需要堆栈:

/home/circleci/eleven-app/frontend/node_modules/@angular-devkit/build-angular/node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
/home/circleci/eleven-app/frontend/node_modules/@angular-devkit/build-angular/node_modules/@babel/preset-env/lib/index.js
/home/circleci/eleven-app/frontend/node_modules/@angular-devkit/build-angular/node_modules/@babel/core/lib/config/files/plugins.js
/home/circleci/eleven-app/frontend/node_modules/@angular-devkit/build-angular/node_modules/@babel/core/lib/config/files/index.js
/home/circleci/eleven-app/frontend/node_modules/@angular-devkit/build-angular/node_modules/@babel/core/lib/index.js
/home/circleci/eleven-app/frontend/node_modules/@angular-devkit/build-angular/src/utils/process-bundle.js
/home/circleci/eleven-app/frontend/node_modules/jest-worker/build/workers/processChild.js
Run Code Online (Sandbox Code Playgroud)

我在用

{
  "@babel/plugin-proposal-numeric-separator": "^7.8.3",
  "core-js": "3.2.1",
  "tslib": "^1.11.1",
  "@babel/compat-data": "~7.8.0",
  "@babel/runtime-corejs3": "^7.9.2",
  "ts-node": "7.0.0",
  "tslint": "5.11.0",
  "typescript": "3.5.3",
}
resolutions: {
  "@babel/preset-env": "^7.8.7"
}
Run Code Online (Sandbox Code Playgroud)

这是 npx nls 为什么 @babel/preset-env 输出:

eleven-app-frontend > @angular-devkit/build-angular > @babel/preset-env@7.8.7
eleven-app-frontend > @nrwl/angular > @nrwl/cypress > @cypress/webpack-preprocessor > @babel/preset-env@7.9.5
eleven-app-frontend > @nrwl/cypress > @cypress/webpack-preprocessor > @babel/preset-env@7.9.5
Run Code Online (Sandbox Code Playgroud)

感谢您的阅读。

babeljs angular

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

如何解决 PytestConfigWarning: Unknown config option: DJANGO_ SETTINGS_MODULE 错误?

我正在使用 django 构建我的网站,并使用 django-pytest 来测试我的应用程序,但我收到此错误 注意我正在使用 python 3.9

================================================================== warnings summary 

===================================================================
..\venv\lib\site-packages\_pytest\config\__init__.py:1233
  c:\users\eng_diaa_shalaby\desktop\unittest\venv\lib\site-packages\_pytest\config\__init__.py:1233: PytestConfigWarning: Unknown config option: DJANGO_
SETTINGS_MODULE

    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

-- Docs: https://docs.pytest.org/en/stable/warnings.html
Run Code Online (Sandbox Code Playgroud)

这是我的 pytest.ini 文件内容

# -- FILE: pytest.ini (or tox.ini)
[pytest]
DJANGO_SETTINGS_MODULE = testing_settings
# -- recommended but optional:
python_files = tests.py test_*.py *_tests.py
Run Code Online (Sandbox Code Playgroud)

我运行这个命令

pytest
Run Code Online (Sandbox Code Playgroud)

这是我的 venv 包

Package       Version
------------- -------
asgiref       3.3.4
atomicwrites  1.4.0
attrs         21.2.0
colorama      0.4.4
coverage      5.5
Django        3.2.4
django-pytest 0.2.0
iniconfig     1.1.1
packaging     20.9
pip           21.1.2
pluggy …
Run Code Online (Sandbox Code Playgroud)

django pytest pytest-django

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

将类特定和特定于方法的泛型封装在一种类型中

假设我需要一个与泛型Comparable类型相关的类:

class A<T extends Comparable<T>> {

    // this is just an example of usage of T type
    List<T> comparables;

    int compareSomething(T smth) {
        return comparables.get(0).compareTo(smth);
    }
}
Run Code Online (Sandbox Code Playgroud)

该类具有签名中具有自己的泛型的方法:

<V> Future<V> submit(Callable<V> task) {
    return someExecutorService.submit(task);
}
Run Code Online (Sandbox Code Playgroud)

现在,是否有可能限制submit方法的输入只接受Callables也实现T?我第一次尝试这个:

<V, W extends T & Callable<V>> Future<V> submit(W task) {
    if(compareSomething(task) != 0)
        throw new RuntimeException("");
    return someExecutorService.submit(task);
}
Run Code Online (Sandbox Code Playgroud)

但发现它是不可能的(由于此处所述的原因).有没有优雅的可能性绕过它?


编辑:我能想到的一个丑陋的可能性是将封装分成两种不同的类型并传递一个对象submit:

class A<T extends Comparable<T>> {

    // this is just an …
Run Code Online (Sandbox Code Playgroud)

java generics

14
推荐指数
1
解决办法
674
查看次数

Pip安装不与jenkins一起工作?

那是我的詹金斯文件.

pipeline {
    agent none
    stages {
        stage('Build') {
            agent {
                docker {
                    image 'python:3-alpine'
                }
            }
            steps {
                sh 'pip install --user -r requirements.txt'
                sh 'python WebChecker.py'
            }
            post {
                always {
                    junit 'output.xml'
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我在詹金斯运行时,我得到了跟随

[urltester] Running shell script

+ pip install --user -r requirements.txt

The directory '/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. …
Run Code Online (Sandbox Code Playgroud)

python pip jenkins docker

13
推荐指数
2
解决办法
4043
查看次数

CuDNNLSTM:无法调用 ThenRnnForward

我在尝试使用 CuDNNLSTM 而不是 keras.layers.LSTM 时遇到了一个问题。

这是我得到的错误:

无法使用模型配置调用 ThenRnnForward: [rnn_mode, rnn_input_mode, rnn_direction_mode]: 2, 0, 0 , [num_layers, input_size, num_units, dir_count, seq_length, batch_size]: [1, 300, 512, 5528] 1, [1, 1, 1, [{{node bidirectional_1/CudnnRNN_1}} = CudnnRNN[T=DT_FLOAT, _class=["loc:@train...NNBackprop"], direction="unidirectional", dropout=0, input_mode="linear_input", is_training=true , rnn_mode="lstm", seed=87654321, seed2=0, _device="/job:localhost/replica:0/task:0/device:GPU:0"](bidirectional_1/transpose_1, bidirectional_1/ExpandDims_1, bidirectional_1/ExpandDims_1 , bidirectional_1/concat_1)]] [[{{node loss/mul/_75}} = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device=" /job:localhost/replica:0/task:0/device:GPU:0",send_device_incarnation=1, tensor_name="edge_1209_loss/mul", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

另外,我在其中一次运行中遇到了这个错误:

内部错误:GPU 同步失败

每次运行后内核都会死掉。

当我尝试使用 CuDNNLSTM 在谷歌云上的 VM 实例上运行它时,我才开始收到此错误。

我的代码是:

MAX_LEN = max(len(article) for article in X_train_tokens)
EMBEDDING_DIM=300
vocab_size = len(word_to_id)
classes = …
Run Code Online (Sandbox Code Playgroud)

gpu google-cloud-platform lstm keras tensorflow

13
推荐指数
2
解决办法
8863
查看次数

使用Spring HibernateTemplate.如何删除ID?

对于使用数据库,我的类扩展了HibernateDaoSupport类,并在我使用Spring的方法内部HibernateTemplate.

因此,为了删除数据库中的一行,我使用以下方法:

public void delete(MyObject obj) {
    getHibernateTemplate().delete(obj);
}
Run Code Online (Sandbox Code Playgroud)

一切都好!

但是,此时我正在尝试实现一个可以删除基于id的行的方法:

public void delete(final long id) {
    // some code here
}
Run Code Online (Sandbox Code Playgroud)

我找不到HibernateTemplate像这样的方法:
getHibernateTemplate().remove(id)

在这种情况下,对我来说什么是好的解决方案?

java spring hibernate

12
推荐指数
4
解决办法
5万
查看次数

更改Cython的.so文件命名规则

我正在使用Cython从Python模块生成共享对象.编译输出被写入build/lib.linux-x86_64-3.5/<Package>/<module>.cpython-35m-x86_64-linux-gnu.so.有没有更改命名规则的选项?我希望在<module>.so没有解释器版本或arch附录的情况下命名文件.

python setuptools cython

11
推荐指数
2
解决办法
2021
查看次数

Pip问题 - 由于EnvironmentError导致无法安装软件包

我想我的Mac上有Python和/或pip的问题.我在全球安装了Python 2.7,然后我通常设置virtualenvs并安装Python3.6.4但是在最后一天左右我遇到了诸如Fabric和SSH2这样的软件包的问题,​​我要么无法安装各种错误,要么安装它们我尝试导入包时抛出的Fabric.

我现在正在尝试删除Fabric并安装Fabric3及其抛出错误,如下所示:

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Users/david/Documents/projects/uptimeapp/env/lib/python3.6/site-packages/Fabric3-1.14.post1.dist-info'
Consider using the `--user` option or check the permissions.

(env) Davids-MacBook-Air:uptimeapp david$ pip install fabric3 --user
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Run Code Online (Sandbox Code Playgroud)

如果我这样做,sudo pip install fabric 它安装但有这个警告:

The directory '/Users/david/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that …
Run Code Online (Sandbox Code Playgroud)

python macos pip python-3.x

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

在 pytest 中禁用特定记录器

在我的项目中,我使用 pdfplumber 解析一些 PDF 文件。在测试执行(pytest)期间,我有时希望查看代码中的日志以进行调试。这可以通过设置来完成--log-cli-level=DEBUG。然而,这会打开来自所有代码的消息,还有 pdfplumber - 这非常冗长并且使调试变得困难。有没有办法在测试运行期间有选择地启用/禁用记录器?

pytest 4.6.3
python 3.7.3

感谢帮助!

python logging pytest python-logging

11
推荐指数
1
解决办法
9425
查看次数

Python APScheduler - AsyncIOScheduler 如何工作?

我很难理解AsyncIOScheduler是如何工作的,它是如何非阻塞的?

如果我的工作正在执行阻塞功能,会AsyncIOScheduler阻塞吗?

如果我使用AsyncIOSchedulerwithThreadPoolExecutor呢?这是如何运作的?我可以等待作业执行吗?

python apscheduler

10
推荐指数
3
解决办法
5124
查看次数