Python: snippets

From Research management course
Revision as of 00:48, 23 March 2023 by Wiki (talk | contribs)
Jump to: navigation, search

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