To get a unique list of all Python packages your application depends on:
grep -irhP '^import ' interp_stn_to_grid | sort | uniq
where interp_stn_to_grid
is the top-level directory containing all the Python scripts in your application.
#!/usr/bin/env python | |
import os, sys | |
import pkgutil | |
def list_submodules(list_name, package_name): | |
for loader, module_name, is_pkg in pkgutil.walk_packages(package_name.__path__, package_name.__name__+'.'): | |
list_name.append(module_name) | |
module_name = __import__(module_name, fromlist='dummylist') | |
if is_pkg: |
To get a unique list of all Python packages your application depends on:
grep -irhP '^import ' interp_stn_to_grid | sort | uniq
where interp_stn_to_grid
is the top-level directory containing all the Python scripts in your application.
Validates a --dates
argument in Python with the following possible formats:
To use this function, reference it in the argparse
setup:
Replace all instances of with your app name (eg. 'my-python-app', dashes are allowed), and all instances of
with your app's main module (eg. 'my_python_app', dashes are NOT allowed), and
# Ansible deployment playbook | |
--- | |
# ------------------------------------------------------------------------------------------------ | |
# Hosts to deploy to (set to all if you want to be able to just limit installation to specific | |
# hosts using the `--limit` arg to `ansible-playbook`. | |
# | |
- hosts: all | |
# ---------------------------------------------------------------------------------------------- | |
# Files containing additional variables | |
# |
#!/bin/csh | |
# Get the name of this script | |
if ( $?_ ) then | |
# With tcsh the name of the file being sourced is available in | |
# $_. | |
set script_name = `basename $_` | |
else | |
# Fall back to $0 which, sometimes, will be the name of the |
#!/usr/bin/env python | |
from subprocess import call, PIPE | |
import os | |
user = '<user>' | |
vpn_servers = ['<server1>', '<server2>'] | |
for vpn_server in vpn_servers: |
This is a simple example that creates a NetCDF file for 1 degree global 2m temperature. There is no time coordinate.
For this portion of code:
ds = xr.DataArray(data, ...)
data
is a NumPy array, assumed to have a shape of num_lats x num_lons
To deploy your app, you'll need to install Ansible and the Ansistrano deploy and rollback Ansible Galaxy roles.
Then create a directory in your app (eg. named ansible
) and put these files in there. You should only need to modify the top few variables in vars.yml
to get the deployment working for your app.
To do the deployment, use a command like this:
ansible-playbook --limit ansible/deploy.yml
#!/usr/bin/env python | |
from datetime import date, datetime, timedelta | |
import os | |
import sys | |
import jinja2 | |
script_name = os.path.basename(__file__) | |
def usage(): |