简体   繁体   English

google colab 与 github 之间的集成

[英]integration between google colab and github

I am working in google colab with an ipython notebook which I "opened" using the link from github (the notebook is uploaded to Github).我正在使用来自 github 的链接“打开”的 ipython 笔记本在 google colab 中工作(笔记本已上传到 Github)。 Then, in the body of notebook I cloned the repository to have an access to a library from a repository.然后,在笔记本的正文中,我克隆了存储库以从存储库访问库。 I want to modify this library occasionaly, eg write a new function.我想偶尔修改这个库,例如写一个新的 function。 I noticed that even though I can view the code for the files in this library, and even modify the code of this library in colab, eg write a new function, I can't import this function in my ipython notebook.我注意到即使我可以查看这个库中文件的代码,甚至可以在 colab 中修改这个库的代码,例如编写一个新的 function,我也无法在我的 ipython 笔记本中导入这个 function。 What is the best way to solve this problem?解决这个问题的最佳方法是什么?

I tried to modify the library on my local computer, then upload these files to github.我尝试在本地计算机上修改库,然后将这些文件上传到 github。 But when I try to pull the files from the repository on ipython notebook on colab using !git pull origin master it says that all files are already up to date.但是,当我尝试使用!git pull origin master从 colab 上的 ipython notebook 上的存储库中提取文件时,它说所有文件都已经是最新的。 Even a new added function is present in a library in colab - I still cannot import the function.即使是新添加的 function 也存在于 colab 的库中 - 我仍然无法导入 function。

I also tried to close and "open" again this notebook in colab using the github link (to be able to run a cell with !git clone again - I deleted these files from the notebook in colab using %rm -rf beforehand).我还尝试使用 github 链接在 colab 中再次关闭并“打开”这个笔记本(为了能够再次使用!git clone运行单元 - 我事先使用%rm -rf从 colab 中的笔记本中删除了这些文件)。 Colab still doesn't see the function defined in github. Colab 仍然没有看到 github 中定义的 function。

I'm new to git and colab.我是 git 和 colab 的新手。 Please, help.请帮忙。

first point out to the location in drive as首先指出驱动器中的位置为

%cd /content/drive/My Drive/dir1

then clone the directory you want, eg,然后克隆你想要的目录,例如,

!git clone https://github.com/KaiDMML/FakeNewsNet

on refreshing the drive, you will find the cloned directory in the drive.刷新驱动器时,您会在驱动器中找到克隆的目录。

Remember to connect to the drive first before all these steps请记住在所有这些步骤之前先连接到驱动器在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM