Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Use external database in crowdsourcing code (#4272)
Browse files Browse the repository at this point in the history
* Add flag for external DB

* [WIP] Fix crowdsourcing CI check

* [TOD] World, world metrics, script, tests (#4178)

* [TOD][straightforward] Tod world output jsonl structure to teacher task (#4180)

* [TOD][Dataset][Easy] Google SGD in TOD Conversations format (#4181)

* Add flag for external DB

* Try to fix unit test

* Minor

Co-authored-by: Moya Chen <72097364+moyapchen@users.noreply.github.com>
  • Loading branch information
EricMichaelSmith and moyapchen committed Dec 23, 2021
1 parent 177e97f commit 339a29e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion parlai/crowdsourcing/utils/analysis.py
Expand Up @@ -50,12 +50,19 @@ def setup_args(cls):
parser.add_argument(
'--task-name', type=str, help='Name of the Mephisto task to open'
)
parser.add_argument(
'--database-path',
type=str,
default=None,
help='Path to local Mephisto database. Leave empty for default location.',
)
return parser

def __init__(self, opt: Opt):
self.task_name = opt['task_name']
self.output_folder = opt['output_folder']
self.results_format = opt.get('results_format', 'json')
self.database_path = opt['database_path']

# We lazily load these later, or inject their mock version during testing.
self._mephisto_db = None
Expand All @@ -69,7 +76,7 @@ def get_mephisto_data_browser(self) -> MephistoDataBrowser:

def get_mephisto_db(self) -> LocalMephistoDB:
if not self._mephisto_db:
self._mephisto_db = LocalMephistoDB()
self._mephisto_db = LocalMephistoDB(self.database_path)
return self._mephisto_db

def get_results_path_base(self) -> str:
Expand Down
5 changes: 4 additions & 1 deletion tests/crowdsourcing/test_analysis.py
Expand Up @@ -32,7 +32,10 @@ def __init__(self, *args, **kwargs) -> None:
######################################################################


DUMMY_OPT = {'task_name': 'mock_task_name', 'output_folder': '/dummy/tmp'}
parser_ = AbstractResultsCompiler.setup_args()
opt_string = '--task-name mock_task_name --output-folder /dummy/tmp'
args_ = parser_.parse_args(opt_string.split())
DUMMY_OPT = vars(args_)
LEN_MOCK_DATA = 5


Expand Down

0 comments on commit 339a29e

Please sign in to comment.