Projects

These APIs allow you to interact with datasets that have been attached to projects.

Automatic project authentication

The Authentication object can be associated with a default project UUID, which will then be used to for all project operations, unless an explicit project gets passed to override the default.

Importantly, JuliaHub.authenticate will automatically pick up the the JuliaHub project UUID from the JULIAHUB_PROJECT_UUID environment variable. This means in JuliaHub cloud jobs and IDEs, it is not necessary to manually set the project, and JuliaHub.jl will automatically. However, you can opt-out of this behavior by explicitly passing a project=nothing to JuliaHub.authenticate.

You can always verify that your operations are running in the context of the correct project by checking the Authentication object, e.g. via current_authentication:

julia> JuliaHub.current_authentication()
JuliaHub.Authentication("https://juliahub.com", "username", *****; project_id = "cd6c9ee3-d15f-414f-a762-7e1d3faed835")

Reference

JuliaHub.project_datasetsFunction
JuliaHub.project_datasets([project::ProjectReference]; [auth::Authentication]) -> Vector{Dataset}

Returns the list of datasets attached to the project, as a list of Dataset objects. If the project is not explicitly specified, it uses the project of the authentication object.

May throw a ProjectNotSetError. Will throw an [InvalidRequestError] if the currently authenticated user does not have access to the project or the project does not exists.

julia> JuliaHub.current_authentication()
JuliaHub.Authentication("https://juliahub.com", "username", *****; project_id = "cd6c9ee3-d15f-414f-a762-7e1d3faed835")

julia> JuliaHub.project_datasets()
3-element Vector{JuliaHub.Dataset}:
 JuliaHub.project_dataset(("username", "example-dataset"); project="cd6c9ee3-d15f-414f-a762-7e1d3faed835")
 JuliaHub.project_dataset(("anotheruser", "publicdataset"); project="cd6c9ee3-d15f-414f-a762-7e1d3faed835")
 JuliaHub.project_dataset(("username", "blobtree/example"); project="cd6c9ee3-d15f-414f-a762-7e1d3faed835")
source
JuliaHub.project_datasetFunction
JuliaHub.project_dataset(dataset::DatasetReference; [project::ProjectReference], [auth]) -> Dataset

Looks up the specified dataset among the datasets attached to the project, returning a Dataset object, or throwing an InvalidRequestError if the project does not have such dataset attached.

julia> JuliaHub.project_dataset(("username", "blobtree/example"))
Dataset: blobtree/example (BlobTree)
 owner: username
 description: An example dataset
 versions: 1
 size: 57 bytes
 tags: tag1, tag2
 project: cd6c9ee3-d15f-414f-a762-7e1d3faed835 (not writable)
Implicit dataset owner

When passing just the dataset name for dataset (i.e. <: AbstractString), then, just like for the non-project JuliaHub.dataset function, it is assumed that the owner of the dataset should be the currently authenticated user.

However, a project may have multiple datasets with the same name attached to it (if they are owned by different users). The best practice when accessing datasets in the context of projects is to fully specify their name (i.e. also include the username).

Non-dynamic dataset objects

Dataset objects represents the dataset metadata when the Julia object was created (e.g. with dataset), and are not automatically kept up to date. To refresh the dataset metadata, you can pass an existing Dataset object to JuliaHub.dataset or project_dataset.

source
JuliaHub.upload_project_datasetFunction
JuliaHub.upload_project_dataset(
    dataset::DatasetReference, local_path;
    progress=true,
    [project::ProjectReference],
    [auth::Authentication],
) -> Dataset

Uploads a new version of a project-linked dataset.

By default, the new dataset version will be associated with the project of the current authentication session (if any), but this can be overridden by passing project.

Permissions

Note that in order for this to work, you need to have edit rights on the projects and the dataset needs to have been marked writable by the dataset owner. However, unlike for normal datasets uploads (with upload_dataset), you do not need to be the dataset owner to upload new versions.

Tip

The function call is functionally equivalent to the following upload_dataset call

JuliaHub.upload_dataset(
    dataset, local_path;
    create=false, update=true, replace=false,
)

except that the upload is associated with a project.

source
JuliaHub.ProjectReferenceType
const ProjectReference :: Type

Type constraint on the argument that specifies the project in projects-related APIs that (e.g. project_datasets).

Presently, you can specify the project by directly passing the project UUID. The UUID should be either a string (<: AbstractString) or an UUIDs.UUID object.

source

Index