Skip to content
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

[#201] Implement fetch() in the DAS API #207

Merged
merged 15 commits into from
Mar 28, 2024

Conversation

marcocapozzoli
Copy link
Collaborator

Resolves #201

das = DistributedAtomSpace()
das.fetch(query, host='123.4.5.6', port=8080)
"""
if not kwargs.get('running_on_server') and not host and not port:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check seems to be wrong. If it's not running on server then it's running in a local DAS. But if it's running in a local DAS, fetch will need both host and port. However, your check will not raise if one of them is None but the other is OK.

das = DistributedAtomSpace()
das.fetch(query, host='123.4.5.6', port=8080)
"""
if not kwargs.get('running_on_server') and not host and not port:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to have a KW parameter to check if it's a local or a remote DAS. There should be a more elegant way to identify if it's running on a local or a remote DAS. This is a method in DAS public API so you are expecting that the user will pass this parameter... This seems like bad UX.

Copy link
Contributor

@andre-senna andre-senna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please read my comments before merging


if atomdb_parameter == "ram":
def __init__(self, system_parameters: Dict[str, Any] = {}, **kwargs) -> None:
if not system_parameters.get('running_on_server'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make an explicit private method _set_default_system_parameters() to setup default parameters as we'll probably have other cases where we'll want to do the same. I believe the algorithm should be as you did:

def __init__(self, system_parameters...):
   ...
   self.system_parameters = system_parameters
   self._set_default_system_parameters()
   ...
def _set_default_system_parameters():
    if not system_parameters.get('running_on_server'):
        system_parameters['running_on_server'] = False

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative design would be to use a dataclass SystemParameters instead of a dict. This way defaults would be put in the dataclass' constructor. This option has the advantage ensuring the use of the right parameter name across the code, which otherwise would be detected only in runtime. I'll let you decide.

@marcocapozzoli marcocapozzoli merged commit 833a1f0 into master Mar 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow in-RAM DAS to fetch its data from a remote DAS server
2 participants