-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for static_react_task example #795
Changes from 1 commit
b116336
a091438
379c9e9
481433f
8bcd15c
ee4d978
0aee860
7bc4f1b
9ee7203
ac59bbd
3c392a5
113b8a8
b944d78
a5cc65f
2e989e9
f904089
721b4e6
0fc65a1
5702d9e
41cc544
6b40eed
d5e846d
eb27dc9
00e0023
35b3f28
d34a2ef
e1393b9
14beded
db879d5
28c8431
ff7ae27
cd3a36c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
Utilities that are useful for Mephisto-related scripts. | ||
""" | ||
|
||
import warnings | ||
from mephisto.abstractions.databases.local_database import LocalMephistoDB | ||
from mephisto.operations.operator import Operator | ||
from mephisto.abstractions.databases.local_singleton_database import MephistoSingletonDB | ||
|
@@ -24,12 +25,14 @@ | |
import hydra | ||
import subprocess | ||
from typing import ( | ||
Dict, | ||
Tuple, | ||
Any, | ||
Type, | ||
TypeVar, | ||
Callable, | ||
Optional, | ||
Union, | ||
cast, | ||
TYPE_CHECKING, | ||
) | ||
|
@@ -221,7 +224,7 @@ def augment_config_from_db(script_cfg: DictConfig, db: "MephistoDB") -> DictConf | |
return script_cfg | ||
|
||
|
||
def build_custom_bundle(custom_src_dir, run_config: DictConfig): | ||
def build_custom_bundle(custom_src_dir, **kwargs: Union[str, bool]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kwargs is type Union[str, bool] because the parameter value can be a string(post_install_script) or bool(force_rebuild) currently. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't you be able to just write this as:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I can do it like that, I was just following Pratik's suggestion here: #791 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Etesam913, you'd still be using kwargs with @JackUrb's suggestion above by naming the arguments in the list more info: https://treyhunner.com/2018/04/keyword-arguments-in-python/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh so kwargs just refers to passing the arguments with keywords as opposed to using the **kwargs parameter. I got it 👍 |
||
"""Locate all of the custom files used for a custom build, create | ||
a prebuild directory containing all of them, then build the | ||
custom source. | ||
|
@@ -234,8 +237,21 @@ def build_custom_bundle(custom_src_dir, run_config: DictConfig): | |
|
||
IGNORE_FOLDERS = {os.path.join(prebuild_path, f) for f in IGNORE_FOLDERS} | ||
build_path = os.path.join(prebuild_path, "build", "bundle.js") | ||
|
||
if "force_rebuild" not in kwargs: | ||
warnings.warn( | ||
"Consider adding the force_rebuild property to your hydra config and passing it into build_custom_bundle()\nSteps on how to do this: \nhttps://github.com/facebookresearch/Mephisto/issues/811", | ||
stacklevel=2, | ||
) | ||
|
||
if "post_install_script" not in kwargs: | ||
warnings.warn( | ||
"Consider adding the post_install_script property to your hydra config and passing it into build_custom_bundle()\nSteps on how to do this: \nhttps://github.com/facebookresearch/Mephisto/issues/811", | ||
stacklevel=2, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New warning messages |
||
|
||
# see if we need to rebuild | ||
Etesam913 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if run_config.task.force_rebuild is False: | ||
if "force_rebuild" not in kwargs or kwargs["force_rebuild"] == False: | ||
if os.path.exists(build_path): | ||
created_date = os.path.getmtime(build_path) | ||
up_to_date = True | ||
|
@@ -269,10 +285,13 @@ def build_custom_bundle(custom_src_dir, run_config: DictConfig): | |
) | ||
|
||
if ( | ||
run_config.task.post_install_script is not None | ||
and len(run_config.task.post_install_script) > 0 | ||
"post_install_script" in kwargs | ||
and kwargs["post_install_script"] is not None | ||
and isinstance(kwargs["post_install_script"], str) | ||
): | ||
subprocess.call(["bash", run_config.task.post_install_script]) | ||
post_install_string: str = str(kwargs["post_install_script"]) | ||
if len(post_install_string) > 0: | ||
subprocess.call(["bash", post_install_string]) | ||
|
||
webpack_complete = subprocess.call(["npm", "run", "dev"]) | ||
if webpack_complete != 0: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of passing in the new parameters