小编jar*_*jar的帖子

如何使用GraphQL获取GitHub存储库的提交以及已更改的文件和更改本身

我能够获得提交列表(包括提交消息,oid,提交URL等字段)以及changedFilesmaster分支上的存储库中创建的数量.
但是,我无法弄清楚如何获取有关更改本身和更改的文件的任何信息.

在REST API的第3版中,有关更改的信息包含在files- > patchfiles- >中,raw_url或者blob_url在该阶段提供了有关原始文件本身的信息.

Q)在使用GraphQL的GitHub API的第4版中,我如何获得相应的信息?

查询我现在卡住了(为简洁起见只显示1次提交) -

query {
  rateLimit{
    cost
    remaining
  }
  repository(owner: "elastic", name: "elasticsearch") {
    name
    defaultBranchRef {
      name
      target {
        ... on Commit {
          history(first:1){
            nodes{
              message
              changedFiles
              id
              oid
              treeUrl
              url
              tree{
                oid
              }
            }
            pageInfo{
              hasNextPage
              startCursor
              endCursor
            }
          }
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

输出:

{
  "data": …
Run Code Online (Sandbox Code Playgroud)

graphql github-graphql

13
推荐指数
0
解决办法
366
查看次数

如何使用新的 github cli 向远程存储库发出拉取请求,而无需推送远程分支?

我试图弄清楚如何从本地分支(甚至从本地主/主分支)向我的远程存储库创建 PR。但是,无论我做什么,我都会收到以下错误:

来自本地main的尝试:

(master)$ gh pr create --title "Adding readme" --body "Testing pr from cli" --head armsp:feature

Creating pull request for armsp:feature into master in armsp/----

pull request create failed: GraphQL error: Head sha can't be blank, Base sha can't be blank, No commits between master and feature, Head ref must be a branch
Run Code Online (Sandbox Code Playgroud)

当地feature分支机构的尝试:

(feature)$ gh pr create --title "Adding readme" --body "Testing pr from cli" --head armsp:feature

Creating pull request for armsp:feature into master …
Run Code Online (Sandbox Code Playgroud)

github github-cli

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

是否可以将单个自定义 HTML 页面添加到现有的 Hugo 主题(例如 Academic)中?

你究竟想要什么?
我在 Hugo 有一个网站。但是我有一个特殊的情况。
科学家和电气工程师以及其他人可能有特定的需求。例如:有一个显示模拟的页面。或者在我的情况下使用webbluetoothwebusb,我从头开始用 HTML、CSS 和 JS 编写。此外,这些页面可能由自定义脚本生成。因此,您可以在您的 Hugo 站点中使用 git 子模块,专门用于生成这些您只想添加到您的网站的自定义单页 html。

所以我想要的只是现有主题支持的菜单项或侧边栏,但不是显示默认的 html,它应该显示我的自定义、硬编码、已经准备好的 html 文件 - 这也可能是一个index.html文件在一个文件夹中,所有必要的内容都准备好并煮熟 - 类似于_sitejekyll 创建的文件夹。

自定义html是什么意思?
我的意思是它不需要 Hugo 主题的格式。它有自己的格式,但是因为它只是整个网站中的一个页面,所以用 Hugo 编写自己的布局并不富有成效,或者可能只是值得努力这样做,因为你已经使用其他技术让它工作了。

到目前为止你做了什么,什么有效?
我实际上来自 Jekyll 背景,它就像更改layoutfrontmatter 并制作它一样简单,nil甚至是根本不存在的东西,而且jekyll在现有主题中显示自定义 HTML 方面做得很好。对 Hugo 进行了同样的尝试,但没有奏效。

你在测试什么?
雨果编码器和(或)雨果学术

有什么具体要求吗?
理想情况下,我希望在我的 Hugo 站点文件夹中有子模块,这些子模块在已知文件夹中生成自定义 html,然后以某种方式在 Hugo 中制作相应的 Markdown 文件,负责显示自定义 html。
我想避免在降价本身中编写整个 html。但如果没有其他可能的解决方案,那么我想我别无选择。

请让我知道是否有可能并且值得追求这个以及可能有帮助的任何参考资料。

html static-site hugo

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

启用 NVIDIA cuda 的 docker 容器问题 - UserWarning:CUDA 初始化:cudaGetDeviceCount() 出现意外错误

我正在尝试使用 NVIDIA 提供的基础映像,让我们可以通过 Docker 容器使用他们的 GPU。因为我使用的是 docker,所以我的系统上不需要安装 CUDA Toolkit 或 CuDNN。我所需要的只是合适的司机——我已经拥有了。

我可以运行官方的 pytorch docker 容器,并且容器使用我的 GPU。但是,当我使用 NVIDIA 的基础映像运行任何内容时,我会收到以下警告 -

$ docker run --gpus all -it --rm -p 8000:8000 ubuntu-cuda-gpu:latest
Run Code Online (Sandbox Code Playgroud)
/usr/local/lib/python3.8/dist-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 804: forward compatibility was attempted on non supported HW (Triggered internally at  /pytorch/c10/cuda/CUDAFunctions.cpp:109.)
  return torch._C._cuda_getDeviceCount() > 0
Run Code Online (Sandbox Code Playgroud)

应用程序执行时,只使用CPU。但我希望能够像使用官方 pytorch docker 镜像运行相同的代码(这是一个简单的 pytorch 示例)一样使用我的 GPU。

使用的基础图像 …

ubuntu docker pytorch nvidia-docker

6
推荐指数
0
解决办法
4175
查看次数

即使在主线程崩溃后,子线程也会继续运行

我刚刚开始学习Python并发,所以我的概念可能有点错误,在这种情况下请纠正我。以下所有事情都是在不知不觉中发生的。
这是我理解的一个简单的线程示例 -

import time
import threading

class CountDown:
    def __init__(self):
        self._running = True
    def stop(self):
        self._running = False

    def run(self, n):
        while self._running is True and n>0:
            print(f'T-minus {n}')
            n -= 1
            time.sleep(2)

c = CountDown()
t = threading.Thread(target=c.run,args=(10,))
t.start()
time.sleep(5)
c.stop()
print('Before join')
t.join()
print('After join')
Run Code Online (Sandbox Code Playgroud)

哪个输出-

T-minus 10
T-minus 9
T-minus 8
Before join
After join
Run Code Online (Sandbox Code Playgroud)

但是,如果我替换stopterminate这是不实施的情况

c = CountDown()
t = threading.Thread(target=c.run,args=(10,))
t.start()
time.sleep(5)
c.terminate()
c.stop()
print('Before join')
t.join()
print('After join')
Run Code Online (Sandbox Code Playgroud)

哪个输出- …

python multithreading

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

是否可以在棉花糖中定义具有互斥字段的嵌套模式?

我正在使用marshmallow来验证在 Flask Restful api 中收到的 json 数据。然而,在post请求中,有一个互斥的字段
例如: {"predict": {"id": "5hgy667y4h7f"}}{"predict": {"text": "This is a sample sentence"}}
不能同时发送id,并且text应一起发送。此外,根据天气idtext接收情况调用不同的方法。

问)如何在 Marshmallow 中构建一个允许我验证上述内容的模式?

我为其中一个字段提供的示例代码如下 -

from flask import Flask, request
from flask_restful import Resource, Api, abort
from marshmallow import Schema, fields, ValidationError
app = Flask(__name__)
api = Api(app)

class Mutex1(Schema):
    text = fields.Str(required=True)
    class Meta:
        strict = True

class Mutex2(Schema):
    id_ = fields.Str(required=True)
    class …
Run Code Online (Sandbox Code Playgroud)

python flask python-3.x flask-restful marshmallow

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

当我在 GitHub 的 GraphQL API 中两次调用同一个字段(使用不同的查询)时,为什么我能够绕过分页

在尝试获取用户每个存储库的未解决问题数量时,我注意到了一些我不明白的事情。

当我使用以下查询时,我被要求执行分页(按预期) -

query {
  user(login:"armsp"){
    repositories{
      nodes{
        name
        issues(states: OPEN){
          totalCount
        }
      }
    }    
  }
}

Run Code Online (Sandbox Code Playgroud)

运行上面的错误信息 -

{
  "data": {
    "user": null
  },
  "errors": [
    {
      "type": "MISSING_PAGINATION_BOUNDARIES",
      "path": [
        "user",
        "repositories"
      ],
      "locations": [
        {
          "line": 54,
          "column": 5
        }
      ],
      "message": "You must provide a `first` or `last` value to properly paginate the `repositories` connection."
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

但是,当我执行以下操作时,我实际上得到了对我没有任何意义的所有结果 -

query {
  user(login:"armsp"){
    repositories{
      totalCount
    }
    repositories{
      nodes{
        name
        issues(states: OPEN){
          totalCount
        }
      } …
Run Code Online (Sandbox Code Playgroud)

pagination github github-api graphql

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

是否有更短的方法或 pythonic 方法来生成遵循使用 BeautifulSoup 模式的自定义 html?

我正在构建 HTML 作为一个更大项目的一部分。建筑工程,没有问题。但是我担心代码太冗长或者我没有使用 BeautifulSoup 的全部功能。

例如:我正在生成一个divclass 标签,它按顺序editorial包装了一个divclass editorial-title, editorial-image, editorial-subtitle, editorial-article

示例 HTML-

<div class="editorial">
    <div class="editorial-title">Hello</div>
    <div class="editorial-image"><img src="https://images.dog.ceo/breeds/collie-border/n02106166_2595.jpg"></div>
    <div class="editorial-subtitle">world</div>
    <div class="editorial-article">Yeah. But Parasite? It should have been Gone with the Wind!</div>
</div>
Run Code Online (Sandbox Code Playgroud)

这是适用于我正在尝试做的小型演示版本的长代码 -

from bs4 import BeautifulSoup

title = "Hello"
subtitle = "world"
image_url = "https://images.dog.ceo/breeds/collie-border/n02106166_2595.jpg"
article = "But Parasite? It should have been Gone with the Wind!"

editorial_container = BeautifulSoup('', 'html.parser')
editorial_container_soup = editorial_container.new_tag('div', attrs={"class": …
Run Code Online (Sandbox Code Playgroud)

html python beautifulsoup python-3.x

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

shell: /bin/bash -e {0} 在 github Action Worker 的 bash shell 输出中意味着什么?

因为当没有要提交的更改时 git 会使用非零代码提交退出,这会导致 github 操作失败。为了克服这个问题,我尝试在提交之前检查是否有任何更改,如下所示 -

if git diff-index --quiet HEAD --; then
    echo "changes_exist=true" >> $GITHUB_ENV
else
    echo "changes_exist=false" >> $GITHUB_ENV
fi
Run Code Online (Sandbox Code Playgroud)

然后 GitHub 在其下方向我展示了这一点 - shell: /bin/bash -e {0}

谷歌搜索似乎没有产生任何结果。知道这意味着什么吗?

跑步者的精确输出 -

Run if git diff-index --quiet HEAD --; then
  if git diff-index --quiet HEAD --; then
      echo "changes_exist=true" >> $GITHUB_ENV
  else
      echo "changes_exist=false" >> $GITHUB_ENV
  fi
  shell: /bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.1/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.1/x64/lib
Run Code Online (Sandbox Code Playgroud)

git bash shell github github-actions

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

无法弄清楚如何突出显示或选择 InstancedMesh 中的单个对象并使用 React 三纤维显示自定义 HTML 工具提示

我一直在尝试通过 React 应用程序使用 Three.js 的InstancedMesh来显示 3D 散点图(因此使用 React Three Fiber)。

几天后,我获得了球体的 3D 散点图,并为它们着色。不过,我希望能够通过鼠标单击/悬停来选择/突出显示各个球体。我遵循了一个简单的教程,使用了onPointerOverandonPointerOut但似乎不起作用,也许是因为它不适用于 InstancedMesh 对象。

看起来我需要使用 raycaster,但我不清楚该怎么做。任何建议都会非常有帮助。

设置步骤 -

npx create-react-app demo
cd demo
npm install three
npm i @react-three/fiber
npm i @react-three/drei
Run Code Online (Sandbox Code Playgroud)

显示不同颜色球体的当前代码 -

应用程序.jsx

npx create-react-app demo
cd demo
npm install three
npm i @react-three/fiber
npm i @react-three/drei
Run Code Online (Sandbox Code Playgroud)

IScatter.jsx

import React from 'react'
import { Suspense } from "react";
import { Canvas } from "@react-three/fiber";
import { OrbitControls } from …
Run Code Online (Sandbox Code Playgroud)

javascript three.js reactjs react-three-fiber

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