Difference between revisions of "Python: snippets"

From Research management course
Jump to: navigation, search
m
Line 23: Line 23:
  
 
Three ways to install a Conda environment
 
Three ways to install a Conda environment
 +
 +
 +
 +
 +
 +
* [https://stackoverflow.com/questions/52656692/debugging-in-google-colab Debugging in Google Colab]

Revision as of 00:48, 23 March 2023

Papers on Machine learning refer to the code of computational experiments to reproduce. Selecting a shell and setting up an environment to execute an alien project takes time. Below we collect some useful tips on how to start and organize work on alien projects.

For reference List of the Colab magic functions

%lsmagic

List of the bash commands in Colab

!compgen -c

Import modules from custom py-files, mount the Google-drive

from google.colab import drive
drive.mount('/content/drive')
import sys
sys.path.insert(0,'/content/drive/MyDrive/MyProject')
% download the files to the folder, namely utils.py
% and import desired functions from it
from utils import *

Clone a github project to the Colab folder

!git clone https://github.com/AuthorName/ProjectName
!cd contents/ProjectName
!ls

Three ways to install a Conda environment