Skip to content

Commit

Permalink
cli: github3.authorize not supported anymore, mv mp_logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Jan 6, 2023
1 parent e3d66fb commit 7daa093
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion emmet-cli/emmet/cli/decorators.py
Expand Up @@ -52,7 +52,7 @@ def wrapper(*args, **kwargs):
with open(ETAG, "r") as fd:
etag = fd.readline().strip()

gists_iterator = gh.gists(etag=etag)
gists_iterator = gh.gists(number=20, etag=etag)
if gists_iterator.etag != etag:
with open(ETAG, "w") as fd:
fd.write(gists_iterator.etag)
Expand Down
14 changes: 7 additions & 7 deletions emmet-cli/emmet/cli/entry_point.py
@@ -1,10 +1,10 @@
import logging
import os
from io import StringIO

import click
from github3 import authorize, login
from multiprocessing_logging import install_mp_handler

from io import StringIO
from github3 import GitHub
from github3.session import GitHubSession

from emmet.cli.admin import admin
from emmet.cli.calc import calc
Expand Down Expand Up @@ -80,6 +80,7 @@ def emmet(spec_or_dbfile, run, issue, sbatch, ntries, bb, yes, no_dupe_check, ve

CREDENTIALS = os.path.join(os.path.expanduser("~"), ".emmet_credentials")
if not os.path.exists(CREDENTIALS):
from github3 import authorize # TODO not supported anymore
user = click.prompt("GitHub Username")
password = click.prompt("GitHub Password", hide_input=True)
auth = authorize(
Expand All @@ -94,12 +95,11 @@ def emmet(spec_or_dbfile, run, issue, sbatch, ntries, bb, yes, no_dupe_check, ve

with open(CREDENTIALS, "r") as fd:
token = fd.readline().strip()
ctx.obj["GH"] = login(token=token)
ctx.obj["GH"] = gh = GitHub(session=GitHubSession(default_read_timeout=30))
gh.login(token=token)
else:
click.secho("DRY RUN! Add --run flag to execute changes.", fg="green")

install_mp_handler(logger=logger)


def safe_entry_point():
try:
Expand Down
3 changes: 3 additions & 0 deletions emmet-cli/emmet/cli/tasks.py
Expand Up @@ -432,6 +432,9 @@ def parse(task_ids, snl_metas, nproc, store_volumetric_data): # noqa: C901
f"nmax = {nmax} but chunk size = {chunk_size} -> sequential parsing."
)

from multiprocessing_logging import install_mp_handler
install_mp_handler(logger=logger)

pool = multiprocessing.Pool(processes=nproc)
gen = VaspDirsGenerator()
iterator = iterator_slice(gen, chunk_size) # process in chunks
Expand Down

0 comments on commit 7daa093

Please sign in to comment.