GVKun编程网logo

在 Google App Engine 中运行游戏推荐引擎时遇到问题(谷歌推荐应用)

1

在这篇文章中,我们将带领您了解在GoogleAppEngine中运行游戏推荐引擎时遇到问题的全貌,包括谷歌推荐应用的相关情况。同时,我们还将为您介绍有关ActionController::Routin

在这篇文章中,我们将带领您了解在 Google App Engine 中运行游戏推荐引擎时遇到问题的全貌,包括谷歌推荐应用的相关情况。同时,我们还将为您介绍有关ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j、angular – ng new hello错误:路径“/app/app.module.ts”不存在.路径“/app/app.module.ts”不存在、App Engine app.yaml 变量子目录、App Engine 部署问题 (gcloud.app.deploy) 错误响应:[9]的知识,以帮助您更好地理解这个主题。

本文目录一览:

在 Google App Engine 中运行游戏推荐引擎时遇到问题(谷歌推荐应用)

在 Google App Engine 中运行游戏推荐引擎时遇到问题(谷歌推荐应用)

如何解决在 Google App Engine 中运行游戏推荐引擎时遇到问题

所以我和几个朋友正在为我们的最终项目构建一个游戏推荐引擎。我们让引擎正常工作,但决定使用 Google App Engine 托管它。我们已经启动并运行了项目,但是每当我们尝试运行代码时,都会收到“IndexError: list index out of range”

现在我们正在运行一个代码版本,该版本已经设置为推荐 10 款反恐精英游戏(在 Steam 上为 appid 10),只是为了看看它是否有效。我们有一个要求用户输入的版本,我们稍后会尝试。

我可以在控制台中看到它正在推荐游戏,但它有问题,如上所述。在网站上,它也显示相同的错误并进行追溯。

Console Log

我也在下面发布了代码。

任何帮助将不胜感激。谢谢。

主文件

  1. import pandas as pd
  2. from sklearn.feature_extraction.text import TfidfVectorizer
  3. from sklearn.metrics.pairwise import linear_kernel
  4. app = Flask(__name__)
  5. #@app.route("/")
  6. #def index():
  7. #return "Congratulations,it''s a web app!"
  8. @app.route("/")
  9. def filter():
  10. url = ''https://drive.google.com/file/d/1_skLvOKWQtq4c3x2aZtz1HlJeIxtQeon/view''
  11. path = ''https://drive.google.com/uc?export=download&id='' + url.split(''/'')[-2]
  12. ds = pd.read_csv(path)
  13. tf = TfidfVectorizer(analyzer=''word'',ngram_range=(1,1),min_df=0,stop_words=''english'')
  14. tfidf_matrix = tf.fit_transform(ds[''genres''])
  15. cosine_similarities = linear_kernel(tfidf_matrix,tfidf_matrix)
  16. results = {}
  17. for idx,row in ds.iterrows():
  18. similar_indices = cosine_similarities[idx].argsort()[:-100:-1]
  19. similar_items = [(cosine_similarities[idx][i],ds[''appid''][i]) for i in similar_indices]
  20. results[row[''appid'']] = similar_items[1:]
  21. print(''done!'')
  22. def item(appid):
  23. return ds.loc[ds[''appid''] == appid][''name''].tolist()[0].split('' - '')[0]
  24. # Just reads the results out of the dictionary.
  25. def recommend(item_id,num):
  26. print("Recommending " + str(num) + " products similar to " + item(item_id) + "...")
  27. print("-------")
  28. recs = results[item_id][:num]
  29. for rec in recs:
  30. print("Recommended: " + item(rec[1]))
  31. recommend(item_id=10,num=10)
  32. return recommend
  33. if __name__ == "__main__":
  34. app.run(host="127.0.0.1",port=8080,debug=True)

app.yaml

runtime: python39

要求.txt

Flask==1.1.2 Pandas==1.2.4

解决方法

我认为问题出在 ds.loc[ds[''appid''] == appid][''name''].tolist()[0].split('' - '')[0] 行上。

你正在做一个比较 ```==``` 而不是赋值,即你正在比较 ```ds[''appid'']``` 和 ```appid``` 的值,这意味着你得到布尔结果(真或假)。这意味着你的代码本质上是```ds.loc[True][''name''].tolist()[0].split('' - '')[0]```


我删除了我的答案,因为我从这个 link 中发现熊猫数据帧可以基于布尔值,即```ds.loc[True] 是有效的。同一个链接还给出了一个可能会出现索引错误的原因,但您必须从数据本身中找出原因

ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j

ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j

如何解决ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j

我正在Rails上执行此应用程序,页面加载正常,但在控制台中显示:

Started GET "/vendor/assets/stylesheets/bootstrap.min.css" for ::1 at 2020-08-17 09:09:51 -0500

Started GET "/vendor/assets/javascripts/bootstrap.min.js" for ::1 at 2020-08-17 09:09:51 -0500
ActionController::RoutingError (No route matches [GET] 
"/vendor/assets/stylesheets/bootstrap.min.css"):
ActionController::RoutingError (No route matches [GET] 
"/vendor/assets/javascripts/bootstrap.min.js"):

在我的供应商文件夹中,我同时拥有文件夹,javascript和样式表,并分别位于各自的bootsrtrap.min中。 即使在application.html.erb中,我也有以下内容:

  <link href="vendor/assets/stylesheets/bootstrap.min.css" rel="stylesheet">
  <%= csrf_Meta_tags %>
  <%= stylesheet_link_tag    ''application'',media: ''all'',''data-turbolinks-track'': ''reload'' %>
  <%= javascript_include_tag ''application'',''data-turbolinks-track'': ''reload'' %>

</head>
<body>

  <!-- Navigation -->
  <nav>
    <div>
      <ahref="#">Instagram Clone</a>
      <buttontype="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
        <span></span>
      </button>
      <divid="navbarResponsive">
        <ul>
          <li>
            <ahref="#">Home
              <span>(current)</span>
            </a>
          </li>
          <li>
            <ahref="#">About</a>
          </li>
          <li>
            <ahref="#">Services</a>
          </li>
          <li>
            <ahref="#">Contact</a>
          </li>
        </ul>
      </div>
    </div>
  </nav>

  <!-- Page Content -->
  <div>
    <div>
      <div>
        <%= yield %>
      </div>
    </div>
  </div>

  <!-- Bootstrap core JavaScript -->
  <!--<script src="vendor/jquery/jquery.slim.min.js"></script>-->
  <script src="vendor/assets/javascripts/bootstrap.min.js"></script>
    
</body>
</html>

在js和CSS这两个应用程序文件中,我都放置了“ require bootsrtrap.min”,即使该错误仍然出现在控制台中。 会是什么?

解决方法

RoR不使用目录作为文件夹结构指示。因为有资产装载者。您应该将5s或更少的css导入application.css中,并将js导入application.js中。并使用自己的助手添加捆绑文件:

1。用纱安装靴子

yarn add bootstrap @popperjs/core jquery

npm i bootstrap @popperjs/core jquery

栏位不超过5

2。在Assets Pipeline中导入文件

app / assets / stylesheets / application.css:

//...
require bootstrap/dist/css/bootstrap.min
//...

但是,如果需要,我建议使用SCSS并仅导入所需的样式。

app / assets / javascript / application.js:

//...
//= require jquery
//= require @popperjs/core
//= require bootstrap/dist/js/bootstrap.min
//...

3。在布局中导入资产

app / views / layout / application.html.erb:

<head>
...
  <%= stylesheet_link_tag ''application'',media: ''all'' %>
</head>
<body>
...
  <%= javascript_include_tag ''application'' %>
</body>

使用webpack滚动6

2。在application.scss和application.js中导入Bootstrap

app / javascript / stylesheets / application.scss:

//...
import ''bootstrap''
//...

app / javascript / packs / application.js:

import ''jquery''
import ''popper.js''
import ''bootstrap''
import ''../stylesheets/application''

3。在布局中导入捆绑包

<head>
...
  <%= stylesheet_pack_tag ''application'',media: ''all'',''data-turbolinks-track'': ''reload'' %>
  <%= javascript_pack_tag ''application'',''data-turbolinks-track'': ''reload'' %>
</head>

之后,您应该可以在所有应用程序中使用引导程序!

,

[解决方案]因此,在我的HTML(application.html.erb)内部,我有两个对js和css文件的调用:

<script src="assets/javascripts/bootstrap.min.js"></script>
  <%= javascript_include_tag ''application'',''data-turbolinks-track'': ''reload'' %>       
<link href="assets/stylesheets/bootstrap.min.css" rel="stylesheet">
  <%= csrf_meta_tags %>
  <%= stylesheet_link_tag    ''application'',''data-turbolinks-track'': 
  ''reload'' %>

正如您在上面看到的那样,在使用javascript的情况下,我有一个使用脚本的调用,而另一个使用了的调用,两者都造成了问题,所以您只需要评论一个,我就对该脚本进行评论对于我的java文件和CSS文件,一个。 像这样:

  <!--<link href="assets/stylesheets/bootstrap.min.css" rel="stylesheet">-->
    <!--<script src="assets/javascripts/bootstrap.min.js"></script>-->

对我来说,解决了这个问题,我真的尝试了所有事情,这就是解决方案哈哈。

angular – ng new hello错误:路径“/app/app.module.ts”不存在.路径“/app/app.module.ts”不存在

angular – ng new hello错误:路径“/app/app.module.ts”不存在.路径“/app/app.module.ts”不存在

我在角度创建新项目时面临问题.
当我运行新的myapp命令时,我得到以下命令

新的你好

Error: Path "/app/app.module.ts" does not exist.
Path "/app/app.module.ts" does not exist.

谁能帮我吗???

解决方法

这是解决方案

Please make sure that your new folder have write permission

如果您使用的是ubuntu,请将以下命令运行到该文件夹

sudo chmod 644 -R foldername

然后运行新的appname

并检查您的节点版本

App Engine app.yaml 变量子目录

App Engine app.yaml 变量子目录

如何解决App Engine app.yaml 变量子目录

这是我当前的 app.yaml:

runtime: nodejs10
service: default

instance_class: F1
automatic_scaling:
  min_instances: 0
  max_instances: 2

handlers:

  # Serve extension from where they were requested
- url: /(.*\\.(css|ico|js|png|jpg|gif|mp4|txt|xml|json))$
  static_files: dist/apps/my-app/browser/\\1
  upload: dist/apps/my-app/browser/.*\\.(css|ico|js|png|jpg|gif|mp4|txt|xml|json)$
  secure: always
  expiration: "365d"

  # Handle blog SEO routes
- url: /blog
  static_files: dist/apps/my-app/browser/blog/index.html
  upload: dist/apps/my-app/browser/blog/index.html
  secure: always
  expiration: "0s"

- url: /blog/introducing-my-app
  static_files: dist/apps/my-app/browser/blog/introducing-my-app/index.html
  upload: dist/apps/my-app/browser/blog/introducing-my-app/index.html
  secure: always
  expiration: "0s"

- url: /blog/added-international-support
  static_files: dist/apps/my-app/browser/blog/added-international-support/index.html
  upload: dist/apps/my-app/browser/blog/added-international-support/index.html
  secure: always
  expiration: "0s"

- url: /blog/new-blog-entry
  static_files: dist/apps/my-app/browser/blog/new-blog-entry/index.html
  upload: dist/apps/my-app/browser/blog/new-blog-entry/index.html
  secure: always
  expiration: "0s"

  # Handle default index.html
- url: /(.*)
  static_files: dist/apps/my-app/browser/index.html
  upload: dist/apps/my-app/browser/index.html
  secure: always
  expiration: "0s"

如何将“处理博客 SEO 路由”下的规则合并为一个规则?使用每个博客条目更新 app.yaml 是不可扩展的。

此结构是从 Angular Universal Prerender 项目生成的。

我尝试了几种组合但都没有运气:

- url: /blog/(.*)
  static_files: dist/apps/my-app/browser/blog/\\1/index.html
  upload: dist/apps/my-app/browser/blog/\\1/index.html
  secure: always
  expiration: "0s"

解决方法

我认为您的最后一次尝试与实际解决方案非常接近。请简单地调整 upload 值:

- url: /blog/(.*)
  static_files: dist/apps/my-app/browser/\\1/index.html
  upload: dist/apps/my-app/browser/(.*)/index.html
  secure: always
  expiration: "0s"

正如您在描述 upload 键时在 Google Cloud documentation 中看到的那样,您需要在其定义中提供正则表达式占位符而不是反向引用。

请考虑在 SO 中查看类似的问题,例如 this one 或 this other。

App Engine 部署问题 (gcloud.app.deploy) 错误响应:[9]

App Engine 部署问题 (gcloud.app.deploy) 错误响应:[9]

如何解决App Engine 部署问题 (gcloud.app.deploy) 错误响应:[9]

我只是尝试重新部署我已经部署的同一个项目。我添加了一些静态文件,仅此而已,并在本地对其进行了测试,效果很好。但是,在部署时出现错误: 开始部署服务 [默认]...

╔════════════════════════════════════════════════════════════╗
╠═ Uploading 0 files to Google Cloud Storage                ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...Failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build XXX-5ad7883fea49 status: FAILURE
Build error details: Build error details not available.
Full build logs: https://console.cloud.google.com/cloud-build/builds/XXX-5ad7883fea49?project=XXX

我测试了互联网上我能找到的所有内容,但找不到错误 #9 的修复程序。我检查了日志,它们没有更多信息,至少对我来说不是:

Starting Step #4 - "analyzer"
Step #4 - "analyzer": Already have image (with digest): us.gcr.io/gae-runtimes/buildpacks/nodejs12/builder:nodejs12_20210105_12_20_1_RC00
Step #4 - "analyzer": ERROR: Failed to initialize cache: Failed to create image cache: accessing cache image "us.gcr.io/[project name]/app-engine-tmp/build-cache/ttl-7d/default/buildpack-cache:9aef878d-ea0b-4e41-9b60-13bfd4b6a332": connect to repo store ''us.gcr.io/[project name]/app-engine-tmp/build-cache/ttl-7d/default/buildpack-cache:9aef878d-ea0b-4e41-9b60-13bfd4b6a332'': GET https://us.gcr.io/v2/[project name]/app-engine-tmp/build-cache/ttl-7d/default/buildpack-cache/manifests/9aef878d-ea0b-4e41-9b60-13bfd4b6a332: DENIED: Permission denied for "9aef878d-ea0b-4e41-9b60-13bfd4b6a332" from request "/v2/[project name]/app-engine-tmp/build-cache/ttl-7d/default/buildpack-cache/manifests/9aef878d-ea0b-4e41-9b60-13bfd4b6a332". 
Finished Step #4 - "analyzer"
ERROR
ERROR: build step 4 "us.gcr.io/gae-runtimes/buildpacks/nodejs12/builder:nodejs12_20210105_12_20_1_RC00" Failed: step exited with non-zero status: 1

我不明白它在谈论什么图像,尽管我尝试删除整个 App Engine 以将其读回以解决此问题,而且我认为我无法在不丢失项目 ID 的情况下做到这一点,这不是我想要的做。

我使用的是 NodeJS12 和 Expressjs,没有别的。 app.yaml 如下:

# [START gae_quickstart_yaml]
runtime: nodejs12
# [END gae_quickstart_yaml]

任何想法我还能做什么?这个项目中的内容太少了,我基本上被困在还有什么可以削减以测试它是否是问题的点上。我检查了问题是否在 Google Cloud Shell 中仍然存在,确实如此,所以我想这不是本地错误。

解决方法

将此作为社区维基发布,因为它基于@DanielOcando 的评论

错误消息提示该问题是存储桶权限的问题。

为了修复它,您可以创建一个新的存储桶,请确保您的 App Engine 和 Cloud Build 服务帐户都具有存储管理员权限,以便能够写入和读取存储桶并同时使用 {{1} --bucket 命令中的 } 和 --no-cache 标志。

至于为什么会发生这种情况,如果不检查您的项目就很难说,所以我建议您打开一个 private customer issue on Google''s Issue Tracker,以便他们的工程团队可以确定这一点。

我们今天的关于在 Google App Engine 中运行游戏推荐引擎时遇到问题谷歌推荐应用的分享就到这里,谢谢您的阅读,如果想了解更多关于ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j、angular – ng new hello错误:路径“/app/app.module.ts”不存在.路径“/app/app.module.ts”不存在、App Engine app.yaml 变量子目录、App Engine 部署问题 (gcloud.app.deploy) 错误响应:[9]的相关信息,可以在本站进行搜索。

本文标签:

上一篇React-Router 在定义 的 App.js 中的顶层不起作用(react组件只能包含一个顶层标签)

下一篇requestIDFA / App Tracking 权限 iOS 14 - 如何将其设置为在提示后显示广告?