Projects
These APIs allow you to interact with datasets that have been attached to projects.
project_datasets
andproject_dataset
let you list and access datasets linked to a projectupload_project_dataset
allows uploading new versions of project-linked datasets
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_datasets
— FunctionJuliaHub.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")
JuliaHub.project_dataset
— FunctionJuliaHub.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)
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).
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
.
JuliaHub.upload_project_dataset
— FunctionJuliaHub.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
.
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.
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.
JuliaHub.ProjectReference
— Typeconst 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.