def get_by_name(self, name, username=None): username = username or AuthConfigManager.get_access_token().username try: response = self.request('GET', '%s/%s/%s' % (self.url, username, name)) return Dataset.from_dict(response.json()) except NotFoundException: return None
def get_by_name(self, name, namespace=None): """ name: can be either <namespace>/<dataset_name> or just <dataset_name> namespace: if specified, will skip name parsing, defaults to current user's username """ if not namespace: namespace, name = get_namespace_from_name(name) if not namespace: namespace = AuthConfigManager.get_access_token().username try: response = self.request('GET', '%s/%s/%s' % (self.url, namespace, name)) return Dataset.from_dict(response.json()) except NotFoundException: return None
def get_datasets(self): try: response = self.request("GET", self.url) datasets_dict = response.json() return [ Dataset.from_dict(dataset) for dataset in datasets_dict.get("datasets", []) ] except FloydException as e: if isinstance(e, AuthenticationException): # exit now since there is nothing we can do without login sys.exit(1) floyd_logger.info("Error while retrieving datasets: {}".format( e.message)) return []