Skip to content

Commit

Permalink
Merge pull request #175 from fedevergara/updates
Browse files Browse the repository at this point in the history
Extraction of the mongodb connection for some plugins
  • Loading branch information
omazapa authored Jan 18, 2024
2 parents 1236642 + 9ab246c commit afba6c0
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ def parse_ranking_udea(reg, affiliation, empty_work):
return entry


def process_one(ranking_udea_reg, url, db_name, affiliation, empty_work, verbose=0):
client = MongoClient(url)
db = client[db_name]
collection = db["works"]
def process_one(ranking_udea_reg, db, collection, affiliation, empty_work, verbose=0):
# client = MongoClient(url)
# db = client[db_name]
# collection = db["works"]
doi = None
# register has doi
if ranking_udea_reg["DOI"]:
Expand All @@ -207,7 +207,7 @@ def process_one(ranking_udea_reg, url, db_name, affiliation, empty_work, verbose
# updated
for upd in colav_reg["updated"]:
if upd["source"] == "ranking_udea":
client.close()
# client.close()
return None # Register already on db
# Could be updated with new information when ranking file updates
entry = parse_ranking_udea(
Expand Down Expand Up @@ -371,7 +371,7 @@ def process_one(ranking_udea_reg, url, db_name, affiliation, empty_work, verbose
else: # does not have a doi identifier
# elasticsearch section
pass
client.close()
# client.close()


class Kahi_ranking_udea_works(KahiBase):
Expand Down Expand Up @@ -444,19 +444,23 @@ def __init__(self, config):
{"names.name": "Universidad de Antioquia"})

def process_ranking_udea(self):
Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
backend="threading")(
delayed(process_one)(
paper,
self.mongodb_url,
self.config["database_name"],
self.udea_reg,
self.empty_work(),
verbose=self.verbose
) for paper in self.ranking
)
with MongoClient(self.mongodb_url) as client:
db = client[self.config["database_name"]]
collection = db["works"]

Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
backend="threading")(
delayed(process_one)(
paper,
db,
collection,
self.udea_reg,
self.empty_work(),
verbose=self.verbose
) for paper in self.ranking
)

def run(self):
self.process_ranking_udea()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa
__version__ = '0.1.0-beta'
__version__ = '0.1.1-beta'


def get_version():
Expand Down
41 changes: 23 additions & 18 deletions Kahi_scholar_works/kahi_scholar_works/Kahi_scholar_works.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ def parse_scholar(reg, empty_work, verbose=0):
return entry


def process_one(scholar_reg, url, db_name, empty_work, verbose=0):
client = MongoClient(url)
db = client[db_name]
collection = db["works"]
def process_one(scholar_reg, db, collection, empty_work, verbose=0):
# client = MongoClient(url)
# db = client[db_name]
# collection = db["works"]
doi = None
# register has doi
if scholar_reg["doi"]:
Expand All @@ -276,7 +276,7 @@ def process_one(scholar_reg, url, db_name, empty_work, verbose=0):
# updated
for upd in colav_reg["updated"]:
if upd["source"] == "scholar":
client.close()
# client.close()
return None # Register already on db
# Could be updated with new information when scholar database changes
entry = parse_scholar(
Expand Down Expand Up @@ -471,7 +471,7 @@ def process_one(scholar_reg, url, db_name, empty_work, verbose=0):
else: # does not have a doi identifier
# elasticsearch section
pass
client.close()
# client.close()


class Kahi_scholar_works(KahiBase):
Expand Down Expand Up @@ -508,18 +508,23 @@ def __init__(self, config):

def process_scholar(self):
paper_list = list(self.scholar_collection.find())
Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
backend="threading")(
delayed(process_one)(
paper,
self.mongodb_url,
self.config["database_name"],
self.empty_work(),
verbose=self.verbose
) for paper in paper_list
)

with MongoClient(self.mongodb_url) as client:
db = client[self.config["database_name"]]
collection = db["works"]

Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
backend="threading")(
delayed(process_one)(
paper,
db,
collection,
self.empty_work(),
verbose=self.verbose
) for paper in paper_list
)

def run(self):
self.process_scholar()
Expand Down
2 changes: 1 addition & 1 deletion Kahi_scholar_works/kahi_scholar_works/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa
__version__ = '0.1.0-beta'
__version__ = '0.1.1-beta'


def get_version():
Expand Down
40 changes: 22 additions & 18 deletions Kahi_scopus_works/kahi_scopus_works/Kahi_scopus_works.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ def parse_scopus(reg, empty_work, verbose=0):
return entry


def process_one(scopus_reg, url, db_name, empty_work, verbose=0):
client = MongoClient(url)
db = client[db_name]
collection = db["works"]
def process_one(scopus_reg, db, collection, empty_work, verbose=0):
# client = MongoClient(url)
# db = client[db_name]
# collection = db["works"]
doi = None
# register has doi
if scopus_reg["DOI"]:
Expand All @@ -285,7 +285,7 @@ def process_one(scopus_reg, url, db_name, empty_work, verbose=0):
# updated
for upd in colav_reg["updated"]:
if upd["source"] == "scopus":
client.close()
# client.close()
return None # Register already on db
# Could be updated with new information when scopus database changes
entry = parse_scopus(
Expand Down Expand Up @@ -475,7 +475,7 @@ def process_one(scopus_reg, url, db_name, empty_work, verbose=0):
else: # does not have a doi identifier
# elasticsearch section
pass
client.close()
# client.close()


class Kahi_scopus_works(KahiBase):
Expand Down Expand Up @@ -513,18 +513,22 @@ def __init__(self, config):

def process_scopus(self):
paper_list = list(self.scopus_collection.find())
Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
backend="threading")(
delayed(process_one)(
paper,
self.mongodb_url,
self.config["database_name"],
self.empty_work(),
verbose=self.verbose
) for paper in paper_list
)
with MongoClient(self.mongodb_url) as client:
db = client[self.config["database_name"]]
collection = db["works"]

Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
backend="threading")(
delayed(process_one)(
paper,
db,
collection,
self.empty_work(),
verbose=self.verbose
) for paper in paper_list
)

def run(self):
self.process_scopus()
Expand Down
2 changes: 1 addition & 1 deletion Kahi_scopus_works/kahi_scopus_works/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa
__version__ = '0.1.0-beta'
__version__ = '0.1.1-beta'


def get_version():
Expand Down
41 changes: 23 additions & 18 deletions Kahi_wos_works/kahi_wos_works/Kahi_wos_works.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ def parse_wos(reg, empty_work, verbose=0):
return entry


def process_one(wos_reg, url, db_name, empty_work, verbose=0):
client = MongoClient(url)
db = client[db_name]
collection = db["works"]
def process_one(wos_reg, db, collection, empty_work, verbose=0):
# client = MongoClient(url)
# db = client[db_name]
# collection = db["works"]
doi = None
# register has doi
if wos_reg["DI"]:
Expand All @@ -336,7 +336,7 @@ def process_one(wos_reg, url, db_name, empty_work, verbose=0):
# updated
for upd in colav_reg["updated"]:
if upd["source"] == "wos":
client.close()
# client.close()
return None # Register already on db
# Could be updated with new information when wos database changes
entry = parse_wos(
Expand Down Expand Up @@ -538,7 +538,7 @@ def process_one(wos_reg, url, db_name, empty_work, verbose=0):
else: # does not have a doi identifier
# elasticsearch section
pass
client.close()
# client.close()


class Kahi_wos_works(KahiBase):
Expand Down Expand Up @@ -574,18 +574,23 @@ def __init__(self, config):

def process_wos(self):
paper_list = list(self.wos_collection.find())
Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
backend="threading")(
delayed(process_one)(
paper,
self.mongodb_url,
self.config["database_name"],
self.empty_work(),
verbose=self.verbose
) for paper in paper_list
)

with MongoClient(self.mongodb_url) as client:
db = client[self.config["database_name"]]
collection = db["works"]

Parallel(
n_jobs=self.n_jobs,
verbose=self.verbose,
backend="threading")(
delayed(process_one)(
paper,
db,
collection,
self.empty_work(),
verbose=self.verbose
) for paper in paper_list
)

def run(self):
self.process_wos()
Expand Down
2 changes: 1 addition & 1 deletion Kahi_wos_works/kahi_wos_works/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa
__version__ = '0.1.0-beta'
__version__ = '0.1.1-beta'


def get_version():
Expand Down

0 comments on commit afba6c0

Please sign in to comment.