Difference between revisions of "Python: snippets"

From Research management course
Jump to: navigation, search
m
Line 1: Line 1:
 
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.
 
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.
  
How to install to
+
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
To import modules from custom py-files, mount the Google-drive
 
 
  from google.colab import drive
 
  from google.colab import drive
 
  drive.mount('/content/drive')
 
  drive.mount('/content/drive')
Line 13: Line 16:
 
  % and import desired functions from it
 
  % and import desired functions from it
 
  from utils import *
 
  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

Revision as of 00:39, 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