-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved MongoClient to fw_config.py; pylint & flakes
- Loading branch information
Showing
5 changed files
with
30 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import os | ||
|
||
import json | ||
from glob import glob | ||
from pymongo import DESCENDING | ||
from ruamel.yaml import YAML | ||
from fireworks.core.firework import FiretaskBase | ||
from fireworks.utilities.filepad import FilePad | ||
from fireworks.utilities.dict_mods import arrow_to_dot | ||
|
||
__author__ = "Kiran Mathew, Johannes Hoermann" | ||
__email__ = "[email protected], [email protected]" | ||
|
@@ -28,7 +32,6 @@ class AddFilesTask(FiretaskBase): | |
optional_params = ["identifiers", "directory", "filepad_file", "compress", "metadata"] | ||
|
||
def run_task(self, fw_spec): | ||
from glob import glob | ||
|
||
directory = os.path.abspath(self.get("directory", ".")) | ||
|
||
|
@@ -143,19 +146,12 @@ class GetFilesByQueryTask(FiretaskBase): | |
] | ||
|
||
def run_task(self, fw_spec): | ||
import json | ||
|
||
import pymongo | ||
from ruamel.yaml import YAML | ||
|
||
from fireworks.utilities.dict_mods import arrow_to_dot | ||
|
||
fpad = get_fpad(self.get("filepad_file", None)) | ||
dest_dir = self.get("dest_dir", os.path.abspath(".")) | ||
new_file_names = self.get("new_file_names", []) | ||
query = self.get("query", {}) | ||
sort_key = self.get("sort_key", None) | ||
sort_direction = self.get("sort_direction", pymongo.DESCENDING) | ||
sort_direction = self.get("sort_direction", DESCENDING) | ||
limit = self.get("limit", None) | ||
fizzle_empty_result = self.get("fizzle_empty_result", True) | ||
fizzle_degenerate_file_name = self.get("fizzle_degenerate_file_name", True) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,22 +7,19 @@ | |
import zlib | ||
|
||
import gridfs | ||
import pymongo | ||
from pymongo import DESCENDING | ||
from monty.json import MSONable | ||
from monty.serialization import loadfn | ||
from bson.objectid import ObjectId | ||
|
||
import mongomock.gridfs | ||
from mongomock import MongoClient | ||
|
||
from fireworks.fw_config import MongoClient | ||
from fireworks.fw_config import LAUNCHPAD_LOC, MONGO_SOCKET_TIMEOUT_MS | ||
from fireworks.utilities.fw_utilities import get_fw_logger | ||
|
||
__author__ = "Kiran Mathew" | ||
__email__ = "[email protected]" | ||
__credits__ = "Anubhav Jain" | ||
|
||
mongomock.gridfs.enable_gridfs_integration() | ||
|
||
|
||
class FilePad(MSONable): | ||
def __init__( | ||
|
@@ -180,7 +177,7 @@ def get_file_by_id(self, gfs_id): | |
doc = self.filepad.find_one({"gfs_id": gfs_id}) | ||
return self._get_file_contents(doc) | ||
|
||
def get_file_by_query(self, query, sort_key=None, sort_direction=pymongo.DESCENDING): | ||
def get_file_by_query(self, query, sort_key=None, sort_direction=DESCENDING): | ||
""" | ||
Args: | ||
|
@@ -293,8 +290,6 @@ def _get_file_contents(self, doc): | |
Returns: | ||
(str, dict): the file content as a string, document dictionary | ||
""" | ||
from bson.objectid import ObjectId | ||
|
||
if doc: | ||
gfs_id = doc["gfs_id"] | ||
file_contents = self.gridfs.get(ObjectId(gfs_id)).read() | ||
|