GWLandscape class

The GWLandscape class is a link to the GWLandscape service, being primarily used as a means by which to manipulate publications, models and datasets.

class gwlandscape_python.gwlandscape.GWLandscape(token='', auth_endpoint='https://gwlandscape.org.au/auth/graphql', endpoint='https://gwlandscape.org.au/compas/graphql')

Bases: object

GWLandscape class provides an API for interacting with COMPAS, allowing jobs to be submitted and acquired.

Parameters
  • token (str) – API token for a GWDC user

  • endpoint (str, optional) – URL to which we send the queries, by default GWLANDSCAPE_ENDPOINT

client

Handles a lot of the underlying logic surrounding the queries

Type

GWDC

create_dataset(publication, model, datafile)

Creates a new dataset object with the specified publication and model. Datasets must contain exactly one hdf5 file, and should either be a hdf5 file or a tarfile containing the hdf5 file.

Parameters
  • publication (Publication) – The Publication this dataset is for

  • model (Model) – The model this dataset is for

  • datafile (str or Path) – Local path to the COMPAS h5 file or tarfile

Returns

Created Dataset

Return type

Dataset

create_keyword(tag)

Creates a new keyword object with the specified tag.

Parameters

tag (str) – The tag of the keyword to be created

Returns

Created Keyword

Return type

Keyword

create_model(name, summary=None, description=None)

Creates a new model object with the specified parameters.

Parameters
  • name (str) – The name of the model to be created

  • summary (str, optional) – The summary of the model to be created, by default None

  • description (str, optional) – The description of the model to be created, by default None

Returns

Created Model

Return type

Model

create_publication(author, title, arxiv_id, published=None, year=None, journal=None, journal_doi=None, dataset_doi=None, description=None, public=None, download_link=None, keywords=None)

Creates a new keyword object with the specified tag.

Parameters
  • author (str) – The author of the publication

  • title (str) – The title of the publication

  • arxiv_id (str) – The arxiv id of the publication

  • published (bool, optional) – If the publication was published in a journal/arXiv, by default None

  • year (int, optional) – The year of the publication, by default None

  • journal (str, optional) – The name of the journal, by default None

  • journal_doi (str, optional) – The DOI of the publication, by default None

  • dataset_doi (str, optional) – The DOI of the dataset, by default None

  • description (str, optional) – A description of the publication, by default None

  • public (bool, optional) – If the publication has been made public (visible to the public), by default None

  • download_link (str, optional) – A link to download the publication/dataset, by default None

  • keywords (list, optional) – A list of str or Keyword objects for the publication, by default None

Returns

Created Publication

Return type

Publication

get_datasets(publication=None, model=None, _id=None)

Fetch all dataset models with publication/model matching the provided parameters. Also allows fetching models by the provided ID

At most, only one of (publication, model) or _id must be provided. If no parameter is provided, all dataset models are returned.

Parameters
  • publication (Publication, optional) – Match all dataset models with this publication, by default None

  • model (Model, optional) – Match all dataset models with this publication, by default None

  • _id (str, optional) – Match model by the provided ID, by default None

Returns

A list of Dataset instances

Return type

list

get_files_by_reference(file_references)

Obtains file data when provided a FileReferenceList

Parameters

file_references (FileReferenceList) – Contains the FileReference objects for which to download the contents

Returns

List of tuples containing the file path and file contents as a byte string

Return type

list

get_keywords(exact=None, contains=None, _id=None)

Fetch all keywords matching exactly the provided parameter, any keywords with tags containing the term in the contains parameter, or the keyword with the specified id.

At most, only one of exact, contains, or _id must be provided. If neither the exact, contains, or _id parameter is supplied, then all keywords are returned.

Parameters
  • exact (str, optional) – Match keywords with this exact tag (case-insensitive), by default None

  • contains (str, optional) – Match keywords containing this text (case-insensitive)), by default None

  • _id (str, optional) – Match keyword by the provided ID, by default None

Returns

A list of Keyword instances

Return type

list

get_models(name=None, summary=None, description=None, _id=None)

Fetch all models with name/summary/description containing the values specified. Also allows fetching models by the provided ID

At most, only one of (name, summary, description) or _id must be provided. If no parameter is provided, all models are returned.

Parameters
  • name (str, optional) – Match model name containing this value (case-insensitive), by default None

  • summary (str, optional) – Match model summary contains this value (case-insensitive), by default None

  • description (str, optional) – Match model description contains this value (case-insensitive), by default None

  • _id (str, optional) – Match model by the provided ID, by default None

Returns

A list of Model instances

Return type

list

get_publications(author=None, title=None, _id=None)

Fetch all publications with author/title/arxiv id containing the values specified. Also allows fetching publication by the provided ID

At most, only one of (author, title) or _id must be provided. If no parameter is provided, all publications are returned.

Parameters
  • author (str, optional) – Match publication author contains this value (case-insensitive), by default None

  • title (str, optional) – Match publication arxiv id exactly equals this value (case-insensitive), by default None

  • _id (str, optional) – Match publication by the provided ID, by default None

Returns

A list of Publication instances

Return type

list

save_files_by_reference(file_references, root_path)

Save files when provided a FileReferenceList and a root path

Parameters
  • file_references (FileReferenceList) – Contains the FileReference objects for which to save the associated files

  • root_path (str or Path) – Directory into which to save the files

  • preserve_directory_structure (bool, optional) – Remove any directory structure for the downloaded files, by default True