Client: Updates to new YAPF standard and adds a html repr
@@ -23,9 +23,9 @@ _ssl_error_msg = (
"If you trust the server you are connecting to, try 'FractalClient(... verify=False)'")
_connection_error_msg = "\n\nCould not connect to server {}, please check the address and try again."
-
### Helper functions
+
def _version_list(version):
version_match = re.search(r"\d+\.\d+\.\d+", version)
if version_match is None:
@@ -34,6 +34,7 @@ def _version_list(version):
version = version_match.group(0)
return [int(x) for x in version.split(".")]
+
### Fractal Client
@@ -111,8 +112,7 @@ class FractalClient(object):
f"the one of following commands (pip or conda):"
f"\n\t- pip install qcportal=={self.server_info['version']}"
f"\n\t- conda install -c conda-forge qcportal=={self.server_info['version']}"
- f"\n(Only MAJOR.MINOR versions are checked)"
- )
+ f"\n(Only MAJOR.MINOR versions are checked)")
client_version = _version_list(__version__)[:2]
if not server_version_min_client <= client_version <= server_version_max_client:
raise IOError(f"This Client of version {client_version} does not fall within the Server's allowed "
@@ -121,10 +121,9 @@ class FractalClient(object):
f"following commands:"
f"\n\t- pip install qcportal=={server_version_max_client}.*"
f"\n\t- conda install -c conda-forge qcportal=={server_version_max_client}.*"
- f"\n(Only MAJOR.MINOR versions are checked and shown)"
- )
+ f"\n(Only MAJOR.MINOR versions are checked and shown)")
- def __str__(self) -> str:
+ def __repr__(self) -> str:
"""A short representation of the current FractalClient.
Returns
@@ -136,13 +135,18 @@ class FractalClient(object):
self.server_name, self.address, self.username)
return ret
- def _request(self,
- method: str,
- service: str,
- *,
- data: str=None,
- noraise: bool=False,
- timeout:int=None):
+ def _repr_html_(self) -> str:
+
+ return f"""
+<h3>FractalClient</h3>
+<ul>
+ <li><b>Server: &nbsp; </b>{self.server_name}</li>
+ <li><b>Address: &nbsp; </b>{self.address}</li>
+ <li><b>Username: &nbsp; </b>{self.username}</li>
+</ul>
+"""
+
+ def _request(self, method: str, service: str, *, data: str = None, noraise: bool = False, timeout: int = None):
addr = self.address + service
kwargs = {
@@ -500,6 +504,7 @@ class FractalClient(object):
payload = {"meta": {"overwrite": overwrite}, "data": collection}
return self._automodel_request("collection", "post", payload, full_return=full_return)
+
### Results section
def query_results(self,
