hub

package
v0.0.46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PUBLIC_STORAGE_HUB_URL   = "https://hub.tensorleap.ai"
	DEFAULT_NAMESPACE        = "demo"
	NAMESPACE_META_FILE_NAME = "meta.yaml"
	PROJECT_META_FILE_NAME   = "meta.json"
	// todo: remove this
	PROJECT_TAR_FILE_SUFFIX_NAME_OLD = "project.tar"
	PROJECT_TAR_FILE_SUFFIX_NAME     = "project.tar.zip"
	PROJECT_BG_IMAGE_FILE_NAME       = "bgImage"
	GOOGLE_PROJECT_ID                = "tensorleap-ops3"
	GOOGLE_BUCKET_NAME_PREFIX        = "project-hub-"
)

Variables

View Source
var ErrProjectExists = fmt.Errorf("project already exists, use -o, --override to re-upload")

Functions

func CalcProjectPath

func CalcProjectPath(projectName string) string

func CalcProjectVersionPath

func CalcProjectVersionPath(projectName string, projectVersion int) string

func GetPublicUrl

func GetPublicUrl() string

func HandleProjectExistsOnPublish

func HandleProjectExistsOnPublish(ctx context.Context, hubApi *HubApi, meta *HubMetaWrapper, projectMeta *ProjectMeta, override bool) error

func IsHubEnabled

func IsHubEnabled() bool

func ValidateOrSelectLatestVersion

func ValidateOrSelectLatestVersion(projectName string, versionFlag string, versions []int) (int, error)

func ValidateOrSelectProject

func ValidateOrSelectProject(projectFromFlag string, projectNames []string) (string, error)

Types

type FileAccessBySignedUrl added in v0.0.45

type FileAccessBySignedUrl struct {
	Get, Put, Head string
}

type HubApi

type HubApi struct {
	// contains filtered or unexported fields
}

func NewHubApi

func NewHubApi(hubStorage *HubStorageApi) *HubApi

func (*HubApi) DeleteProject

func (h *HubApi) DeleteProject(projectName string) error

func (*HubApi) DeleteProjectVersion

func (h *HubApi) DeleteProjectVersion(projectName string, projectVersion int) error

func (*HubApi) DownloadProject

func (h *HubApi) DownloadProject(projectName string, version int, destFileName string) error

func (*HubApi) PublishProject

func (h *HubApi) PublishProject(file io.Reader, ctx *ProjectContext) error

func (*HubApi) PublishProjectContentBySignedUrl

func (h *HubApi) PublishProjectContentBySignedUrl(meta *ProjectMeta) (*FileAccessBySignedUrl, *ProjectFilePaths, error)

func (*HubApi) PublishProjectMeta

func (h *HubApi) PublishProjectMeta(files *ProjectFilePaths, projectCtx *ProjectContext) error

type HubMeta

type HubMeta struct {
	Namespace string                `json:"namespace" yaml:"namespace"`
	Projects  map[string]HubProject `json:"projects" yaml:"projects"`
}

func UnmarshalHubMeta

func UnmarshalHubMeta(data []byte) (*HubMeta, error)

type HubMetaWrapper

type HubMetaWrapper struct {
	Data HubMeta `json:"data" yaml:"data"`
}

func CreateWrapperMetaFromUrl

func CreateWrapperMetaFromUrl(url string) (*HubMetaWrapper, error)

func NewHubMetaWrapper

func NewHubMetaWrapper(hubMeta HubMeta) *HubMetaWrapper

func (*HubMetaWrapper) DeleteProject

func (h *HubMetaWrapper) DeleteProject(projectName string) bool

func (*HubMetaWrapper) DeleteProjectVersion

func (h *HubMetaWrapper) DeleteProjectVersion(projectName string, projectVersion int) bool

func (*HubMetaWrapper) GetProjectNames

func (h *HubMetaWrapper) GetProjectNames() []string

func (*HubMetaWrapper) GetProjectNamesByVersion

func (h *HubMetaWrapper) GetProjectNamesByVersion(schemeVersion int) []string

func (*HubMetaWrapper) GetProjectVersions

func (h *HubMetaWrapper) GetProjectVersions(projectName string) []int

func (*HubMetaWrapper) GetVersionMeta

func (h *HubMetaWrapper) GetVersionMeta(projectName string, projectVersion int) (*HubProjectVersion, error)

func (*HubMetaWrapper) ProjectVersionExists

func (h *HubMetaWrapper) ProjectVersionExists(projectName string, projectVersion int) bool

func (*HubMetaWrapper) UpdateVersions

func (h *HubMetaWrapper) UpdateVersions(projectVersions []HubProjectVersion)

type HubProject

type HubProject struct {
	CreatedAt int64                        `json:"createdAt" yaml:"createdAt"`
	Versions  map[string]HubProjectVersion `json:"versions" yaml:"versions"`
}

type HubProjectVersion

type HubProjectVersion struct {
	ProjectMeta `yaml:",inline"`
	CreatedAt   int64  `json:"createdAt" yaml:"createdAt"`
	Path        string `json:"path" yaml:"path"`
	Size        int    `json:"size" yaml:"size"` // bytes
}

type HubStorageApi

type HubStorageApi struct {
	Namespace   string
	FilesClient storage.StorageClient
}

func NewHubStorageApi

func NewHubStorageApi(namespace string, filesClient storage.StorageClient) *HubStorageApi

func (*HubStorageApi) DeleteProject

func (hs *HubStorageApi) DeleteProject(projectName string) (bool, error)

func (*HubStorageApi) DeleteProjectVersion

func (hs *HubStorageApi) DeleteProjectVersion(projectName string, projectVersion int) (bool, error)

func (*HubStorageApi) DownloadProject

func (hs *HubStorageApi) DownloadProject(projectName string, projectVersion int, destFileName string) error

func (*HubStorageApi) GetMeta

func (hs *HubStorageApi) GetMeta() (*HubMeta, error)

func (*HubStorageApi) GetMetaWrapper

func (hs *HubStorageApi) GetMetaWrapper() (*HubMetaWrapper, error)

func (*HubStorageApi) SetMeta

func (hs *HubStorageApi) SetMeta(meta HubMeta) error

func (*HubStorageApi) UpdateProjectMeta

func (hs *HubStorageApi) UpdateProjectMeta(filePaths *ProjectFilePaths, ctx *ProjectContext) (*HubProjectVersion, error)

func (*HubStorageApi) UploadProjectContent

func (hs *HubStorageApi) UploadProjectContent(fileStream io.Reader, meta *ProjectMeta) (*ProjectFilePaths, error)

func (*HubStorageApi) UploadProjectContentBySignedUrl

func (hs *HubStorageApi) UploadProjectContentBySignedUrl(meta *ProjectMeta) (*FileAccessBySignedUrl, *ProjectFilePaths, error)

type Image

type Image struct {
	Name   string
	Buffer []byte
}

type ProjectContext

type ProjectContext struct {
	Meta    ProjectMeta
	BgImage Image
}

func ExtractProjectContextFromTar

func ExtractProjectContextFromTar(tarStream io.Reader) (*ProjectContext, error)

type ProjectFilePaths

type ProjectFilePaths struct {
	BgImagePath string
	TarPath     string
	MetaPath    string
}

func GenerateProjectFilePaths

func GenerateProjectFilePaths(namespace string, meta *ProjectMeta) *ProjectFilePaths

type ProjectMeta

type ProjectMeta struct {
	Name            string                 `json:"name" yaml:"name"`
	Description     string                 `json:"description,omitempty" yaml:"description,omitempty"`
	Tags            []string               `json:"tags" yaml:"tags"`
	Categories      map[string]interface{} `json:"categories" yaml:"categories"`
	BgImagePath     string                 `json:"bgImagePath" yaml:"bgImagePath"`
	SchemaVersion   int                    `json:"schemaVersion" yaml:"schemaVersion"`
	SourceProjectId string                 `json:"sourceProjectId" yaml:"sourceProjectId"`
}

type UploadCtx

type UploadCtx struct {
	Meta  ProjectMeta
	Files ProjectFilePaths
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL