IMP: vscode-specific project structuring (#6)

This commit is contained in:
Matthew Ryan Dillon 2020-05-12 14:32:17 -07:00 committed by GitHub
parent cba51bb5c7
commit 4e388ed79a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 1161 additions and 982 deletions

View file

@ -0,0 +1,54 @@
import json
import os
import subprocess
from qiime2_projects import PROJECTS as Q2_PROJECTS
from mds_projects import PROJECTS as MDS_PROJECTS
from personal_projects import PROJECTS as PERSONAL_PROJECTS
def fetch_projects(projects, base_fp, remotes):
for org, repos in projects.items():
base_fp = os.path.join('~', 'projects', base_fp)
base_fp = os.path.expanduser(base_fp)
for repo in repos:
print('repo: %s/%s' % (org, repo))
repo_fp = os.path.join(base_fp, repo)
repo_fp = os.path.expanduser(repo_fp)
if not os.path.isdir(repo_fp):
url = 'https://github.com/%s/%s' % (org, repo)
subprocess.run(['git', 'clone', url, repo_fp])
subprocess.run(['git', 'remote', 'rename', 'origin', org],
cwd=repo_fp)
for remote in remotes:
url = 'https://github.com/%s/%s' % (remote, repo)
try:
subprocess.run(['git', 'remote', 'add', remote, url],
cwd=repo_fp, check=True,
capture_output=True)
except subprocess.CalledProcessError as e:
msg = 'remote %s already exists' % (remote, )
if msg not in str(e.stderr):
raise
try:
subprocess.run(['git', 'fetch', remote],
cwd=repo_fp, check=True,
capture_output=True)
except subprocess.CalledProcessError as e:
if url not in str(e.stderr):
raise
else:
subprocess.run(['git', 'remote', 'remove', remote],
cwd=repo_fp)
if __name__ == '__main__':
remotes = ['thermokarst', 'ebolyen', 'gregcaporaso', 'ChrisKeefe',
'Oddant1', 'nbokulich', 'andrewsanchez', 'David-Rod']
fetch_projects(Q2_PROJECTS, 'qiime2', remotes)
fetch_projects(MDS_PROJECTS, 'mds', [])
fetch_projects(PERSONAL_PROJECTS, 'personal', [])

View file

@ -0,0 +1,57 @@
import json
import os
from qiime2_projects import PROJECTS as Q2_PROJECTS
from mds_projects import PROJECTS as MDS_PROJECTS
from personal_projects import PROJECTS as PERSONAL_PROJECTS
def render_vscode_workspace(projects, project_name, output_fp,
include_dotfiles=True, extra_dirs=None):
folders = []
for org, repos in projects.items():
for repo in repos:
fp = os.path.join('~', 'projects', project_name, repo)
fp = os.path.expanduser(fp)
folders.append({'name': repo.lower(),
'path': fp})
if include_dotfiles:
dotfile_fp = os.path.join(os.sep, 'Users', 'matthew', '.dotfiles')
folders.append({'name': 'dotfiles',
'path': dotfile_fp})
if extra_dirs is not None:
for name, path in extra_dirs.items():
fp = os.path.join('~', 'projects', project_name, path)
fp = os.path.expanduser(fp)
folders.append({'name': name,
'path': fp})
with open(output_fp, 'w') as fh:
json.dump({'folders': sorted(folders, key=lambda x: x['name'])},
fh, sort_keys=True, indent=4)
if __name__ == '__main__':
def qws(ws_number: int):
return render_vscode_workspace(
Q2_PROJECTS,
'qiime2',
os.path.join('vscode', 'qiime2-%d.code-workspace' % (ws_number, )),
extra_dirs={'data': 'data'},
)
[qws(i) for i in range(1, 4)]
render_vscode_workspace(
MDS_PROJECTS,
'mds',
os.path.join('vscode', 'mds.code-workspace'),
)
render_vscode_workspace(
PERSONAL_PROJECTS,
'personal',
os.path.join('vscode', 'personal.code-workspace'),
)

10
bin/mds_projects.py Normal file
View file

@ -0,0 +1,10 @@
PROJECTS = {
'thermokarst': [
'ccdb-api',
'ccdb-web',
'tucotuco',
'fathm',
'hibernators',
'hibernators-web',
],
}

5
bin/personal_projects.py Normal file
View file

@ -0,0 +1,5 @@
PROJECTS = {
'thermokarst': [
'elixir-class',
],
}

77
bin/qiime2_projects.py Normal file
View file

@ -0,0 +1,77 @@
PROJECTS = {
'qiime2': [
'Keemei',
'action-library-packaging',
'busywork',
'data302',
'dev-docs',
'discourse-unhandled-tagger',
'docs',
'environment-files',
'library',
'logos',
'paper2',
'q2-alignment',
'q2-composition',
'q2-cutadapt',
'q2-dada2',
'q2-deblur',
'q2-demux',
'q2-diversity',
'q2-diversity-lib',
'q2-emperor',
'q2-feature-classifier',
'q2-feature-table',
'q2-fragment-insertion',
'q2-gneiss',
'q2-longitudinal',
'q2-metadata',
'q2-mystery-stew',
'q2-phylogenomics',
'q2-phylogeny',
'q2-quality-control',
'q2-quality-filter',
'q2-sample-classifier',
'q2-shogun',
'q2-taxa',
'q2-types',
'q2-vsearch',
'q2cli',
'q2cwl',
'q2galaxy',
'q2studio',
'q2templates',
'q2view',
'qiime2',
'qiime2.github.io',
'template-repo',
'view.qiime2.org',
'vm-playbooks',
'workshop-playbooks',
'workshops.qiime2.org',
],
'caporaso-lab': [
'caporaso-lab.github.io',
'pretrained-feature-classifiers',
],
'gregcaporaso': [
'caporaso-lab-secrets',
'qiime2-meta-figures',
],
'biocore': [
'scikit-bio',
'deblur',
],
'thermokarst': [
'q2-no-op',
'busywork2_action_playground',
],
'bioconda': [
'bioconda-recipes',
]
}