Skip to content

Instantly share code, notes, and snippets.

Avatar
🔎

Maxime Liquet maximlt

🔎
View GitHub Profile
@maximlt
maximlt / debug.md
Last active Oct 17, 2021
Debug a Panel or Lumen app with VS Code
View debug.md

Add this debug configuration that is going to serve the current file, i.e. the one with .servable() calls for Panel or a YAML file for Lumen:

  {
      "name": "Python: Panel",
      "type": "python",
      "request": "launch",
      "module": "panel",
 "args": [
@maximlt
maximlt / jlab.py
Last active Sep 29, 2021
Create a notebook including a title and some imports and run it in a conda environment with Jupyter Lab
View jlab.py
#!/usr/bin/env python3
from datetime import date
import pathlib
import subprocess
import sys
def create_nb(nb_dir: str, extra_title: str = None) -> pathlib.Path:
today = date.today()
title = today.strftime("%B %d, %Y")
@maximlt
maximlt / RemoteDebuggingQgisVsCode.md
Last active Dec 21, 2020 — forked from veuncent/RemoteDebuggingQgisVsCode.md
Remote debug QGIS with VS Code
View RemoteDebuggingQgisVsCode.md
  1. Install ptvsd using the same Python interpreter Qgis uses. E.g. on Windows:
C:\OSGeo4W64\apps\Python37\python.exe -m pip install ptvsd==4.3.2 

And on Linux:

pip3 install --user ptvsd
@maximlt
maximlt / environment.yml
Created Jul 9, 2020
Test for deploying latest panel version on binder
View environment.yml
name: panel_last_env
channels:
- pyviz
- conda-forge
dependencies:
- panel
- jupyterlab
@maximlt
maximlt / run_python_script_in_conda_env.bat
Last active Dec 6, 2022
Run a Python script in a conda environment from a batch file
View run_python_script_in_conda_env.bat
@echo OFF
rem How to run a Python script in a given conda environment from a batch file.
rem It doesn't require:
rem - conda to be in the PATH
rem - cmd.exe to be initialized with conda init
rem Define here the path to your conda installation
set CONDAPATH=C:\ProgramData\Miniconda3
rem Define here the name of the environment
@maximlt
maximlt / hook-panel.py
Created Apr 23, 2020
Bundling a panel app as an exe with PyInstaller
View hook-panel.py
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('panel', include_py_files=True) + \
collect_data_files('pyviz_comms', include_py_files=True) + \
collect_data_files('bokeh') # See https://github.com/pyinstaller/pyinstaller/pull/4746
@maximlt
maximlt / GitHub-Forking.md
Created Apr 18, 2020 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow
View GitHub-Forking.md

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@maximlt
maximlt / environment.yml
Last active Apr 13, 2020
Test Binder Env for Holoviews
View environment.yml
name: holoviews
channels:
- conda-forge
dependencies:
- pyviz::holoviews=1.13*
# Install requires
- pyviz::param>=1.8.0,<2.0
- pyviz::pyviz_comms>=0.7.2
@maximlt
maximlt / make_conda_available_on_windows.md
Last active Apr 8, 2020
Make conda easily available on Windows
View make_conda_available_on_windows.md

Make conda easily available on Windows

The goal is to lower the burden of running a script with Python when that Python executable is encapsulated within a conda environment. There are several ways to do that.

Add Anaconda Prompt to Windows right click context menu

Adapted from jiewpeng's gist (original gist here)

This describes how to add Anaconda Prompt to the Windows right click context menu. In doing so, the user can open a Command Prompt in any folder from the File Explorer, which is going to be activated

@maximlt
maximlt / project_config.md
Last active Jun 20, 2022
Creating a project base
View project_config.md

Steps to create a good project base for developing in a conda environment

Step-by-step (uncomplete) tutorial for setting up a base Python library given the following requirements:

  • Use conda (instead of pipenv or others) because this is both a package manager and an environment manager, and installing the Python scientific stack (Numpy, Pandas, Scipy, Matplotlib, etc.) is straightforward
  • Use Visual Studio Code (instead of PyCharm, Spyder or others) because it's free, runs on Windows and is one of the mostly used IDE
  • Document and automate as many production steps as possible including linting (flake8), formatting (black), packaging (setup.py, setup.cfg), versionning (git), testing (pytest, pytest-cov, tox), documenting (sphinx, readthedocs), building (setuptools) and distributing (twine, keyring)
  • Include IPython Notebooks and have them tested (pytest-nbval)

Table of content