-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: Various fixes and improvements #41
Conversation
... | ||
|
||
|
||
def _budget_ow( |
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.
I guess, there should be some dynamic type checker in python. But I like the name maybe you should create package of it 😄
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.
Cool! Just a few small comments 🙂
|
||
|
||
@overload | ||
def _budget_ow(value: Union[str, int, float, bool], predicate: Tuple[Type, bool], value_name: str) -> None: # noqa: U100 |
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.
😄 😄 great name
src/apify/_utils.py
Outdated
def validate_single(field_value: Any, expected_type: Type, required: bool, name: str) -> None: | ||
if field_value is None and required: | ||
raise ValueError(f'"{name}" is required!') | ||
actual_type = type(field_value) |
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.
I think this is too strict, it won't work for subclasses for example. I'd rather use isinstance
here.
self._datasets_directory = os.path.join(self._local_data_directory, 'datasets') | ||
self._key_value_stores_directory = os.path.join(self._local_data_directory, 'key_value_stores') | ||
self._request_queues_directory = os.path.join(self._local_data_directory, 'request_queues') | ||
self._write_metadata = write_metadata if write_metadata is not None else '*' in os.getenv('DEBUG', '') | ||
self._persist_storage = persist_storage if persist_storage is not None else not any( | ||
os.getenv('APIFY_PERSIST_STORAGE', 'true') == s for s in ['false', '0', '']) | ||
os.getenv(ApifyEnvVars.PERSIST_STORAGE, 'true') == s for s in ['false', '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.
You could use _maybe_parse_bool
here
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.
yeah, code will be nicer
from apify.storages import StorageManager | ||
|
||
|
||
async def run_e2e_test(monkeypatch: pytest.MonkeyPatch, tmp_path: str, purge_on_start: bool = True) -> None: |
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.
You could use pytest.mark.parametrize
here:
async def run_e2e_test(monkeypatch: pytest.MonkeyPatch, tmp_path: str, purge_on_start: bool = True) -> None: | |
@pytest.mark.parametrize('purge_on_start', [True, False]) | |
async def test_actor_memory_storage_e2e(monkeypatch: pytest.MonkeyPatch, tmp_path: str, purge_on_start: bool = True) -> None: |
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.
nice, didn't know that decorator
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.
I wanted to click "Request changes", sorry 😄
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.
Cool!
Fixes:
Improvements: