scitacean.Profile#

class scitacean.Profile(url, file_transfer, frontend_url=None, scientific_metadata_schema='plain', field_factories=<factory>)[source]#

Parameters for connecting to a specific instance of SciCat.

The fields of a profile correspond to the arguments of the constructors of Client. They can be overridden by the explicit constructor arguments.

When constructing a client from a profile, the profile argument may be one of:

  • If profile is a Profile, it is returned as is.

  • If profile is a str, a builtin profile with that

    name is constructed if possible.

Constructors

__init__(url, file_transfer[, frontend_url, ...])

Attributes

url

URL of the SciCat API.

file_transfer

A file transfer object for uploading and downloading files.

frontend_url

URL of the SciCat frontend.

scientific_metadata_schema

The schema used for scientific metadata.

field_factories

Mapping of field names to functions that compute field values.

__init__(url, file_transfer, frontend_url=None, scientific_metadata_schema='plain', field_factories=<factory>)#
field_factories: dict[str, Callable[..., Any]]#

Mapping of field names to functions that compute field values.

Each item is a pair of field name and a function that computes a value for that field from other fields. The function can take any number of arguments. When calling a factory the arguments are provided based on the dataset that a field is being built for. See the example below.

Field names can be any dataset field plus the following:

  • instrumentNames: The names of the instruments based on instrument IDs if the Ids are known.

Scitacean itself does not currently use this field. It is only used by the Scitacean widget.

Note

All field names use the SciCat names (see Models) instead of the names used in scitacean.Dataset. That is, e.g., proposalIds instead of proposal_ids or sourceFolder instead of source_folder.

Examples

Use the proposal ID of a dataset to construct the owner group:

>>> field_factories = {
...     "ownerGroup": lambda proposalId: str(proposalIds[0]).strip(),
... }

Using str() and strip() here is just a cautionary measure, typically, the proposal ID should already be a stripped string.

file_transfer: FileTransfer | None#

A file transfer object for uploading and downloading files.

See the File transfer. section for implementations provided by Scitacean.

frontend_url: str | None#

URL of the SciCat frontend.

See Profile.url for more information.

scientific_metadata_schema: Literal['plain', 'value-unit']#

The schema used for scientific metadata.

  • “plain”: No special handling. The metadata is used as provided by the user.

  • “value-unit”: The metadata is expected to be a dictionary with keys “value” and “unit”.

This is currently unused by Scitacean.

url: str#

URL of the SciCat API.

Note that this is the URL to the API, not the web interface. For example, at ESS, the web interface URL is "https://scicat.ess.eu". But the API URL is "https://scicat.ess.eu/api/v3" (at the time of writing).