id int64 1 6.07M | name stringlengths 1 295 | code stringlengths 12 426k | language stringclasses 1
value | source_file stringlengths 5 202 | start_line int64 1 158k | end_line int64 1 158k | repo dict |
|---|---|---|---|---|---|---|---|
1,601 | __iter__ | def __iter__(self):
self.page_offset = self.min_step
self.scan_offset = 0
self.rows = []
return self | python | wandb/apis/public.py | 3,496 | 3,500 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,602 | __next__ | def __next__(self):
while True:
if self.scan_offset < len(self.rows):
row = self.rows[self.scan_offset]
self.scan_offset += 1
return row
if self.page_offset >= self.max_step:
raise StopIteration()
self._load_next() | python | wandb/apis/public.py | 3,502 | 3,510 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,603 | _load_next | def _load_next(self):
max_step = self.page_offset + self.page_size
if max_step > self.max_step:
max_step = self.max_step
variables = {
"entity": self.run.entity,
"project": self.run.project,
"run": self.run.id,
"minStep": int(self.page_offset),
"maxStep": int(max_step),
"pageSize": int(self.page_size),
}
res = self.client.execute(self.QUERY, variable_values=variables)
res = res["project"]["run"]["history"]
self.rows = [json.loads(row) for row in res]
self.page_offset += self.page_size
self.scan_offset = 0 | python | wandb/apis/public.py | 3,519 | 3,536 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,604 | __init__ | def __init__(self, client, run, keys, min_step, max_step, page_size=1000):
self.client = client
self.run = run
self.keys = keys
self.page_size = page_size
self.min_step = min_step
self.max_step = max_step
self.page_offset = min_step # minStep for next page
self.scan_offset = 0 # index within current page of rows
self.rows = [] # current page of rows | python | wandb/apis/public.py | 3,552 | 3,561 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,605 | __iter__ | def __iter__(self):
self.page_offset = self.min_step
self.scan_offset = 0
self.rows = []
return self | python | wandb/apis/public.py | 3,563 | 3,567 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,606 | __next__ | def __next__(self):
while True:
if self.scan_offset < len(self.rows):
row = self.rows[self.scan_offset]
self.scan_offset += 1
return row
if self.page_offset >= self.max_step:
raise StopIteration()
self._load_next() | python | wandb/apis/public.py | 3,569 | 3,577 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,607 | _load_next | def _load_next(self):
max_step = self.page_offset + self.page_size
if max_step > self.max_step:
max_step = self.max_step
variables = {
"entity": self.run.entity,
"project": self.run.project,
"run": self.run.id,
"spec": json.dumps(
{
"keys": self.keys,
"minStep": int(self.page_offset),
"maxStep": int(max_step),
"samples": int(self.page_size),
}
),
}
res = self.client.execute(self.QUERY, variable_values=variables)
res = res["project"]["run"]["sampledHistory"]
self.rows = res[0]
self.page_offset += self.page_size
self.scan_offset = 0 | python | wandb/apis/public.py | 3,586 | 3,608 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,608 | __init__ | def __init__(
self,
client: Client,
entity: str,
project: str,
name: Optional[str] = None,
per_page: Optional[int] = 50,
):
self.entity = entity
self.project = project
variable_values = {
"entityName": entity,
"projectName": project,
}
super().__init__(client, variable_values, per_page) | python | wandb/apis/public.py | 3,630 | 3,646 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,609 | length | def length(self):
# TODO
return None | python | wandb/apis/public.py | 3,649 | 3,651 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,610 | more | def more(self):
if self.last_response:
return self.last_response["project"]["artifactTypes"]["pageInfo"][
"hasNextPage"
]
else:
return True | python | wandb/apis/public.py | 3,654 | 3,660 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,611 | cursor | def cursor(self):
if self.last_response:
return self.last_response["project"]["artifactTypes"]["edges"][-1]["cursor"]
else:
return None | python | wandb/apis/public.py | 3,663 | 3,667 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,612 | update_variables | def update_variables(self):
self.variables.update({"cursor": self.cursor}) | python | wandb/apis/public.py | 3,669 | 3,670 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,613 | convert_objects | def convert_objects(self):
if self.last_response["project"] is None:
return []
return [
ArtifactType(
self.client, self.entity, self.project, r["node"]["name"], r["node"]
)
for r in self.last_response["project"]["artifactTypes"]["edges"]
] | python | wandb/apis/public.py | 3,672 | 3,680 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,614 | server_supports_artifact_collections_gql_edges | def server_supports_artifact_collections_gql_edges(
client: RetryingClient, warn: bool = False
) -> bool:
# TODO: Validate this version
# Edges were merged into core on Mar 2, 2022: https://github.com/wandb/core/commit/81c90b29eaacfe0a96dc1ebd83c53560ca763e8b
# CLI version was bumped to "0.12.11" on Mar 3, 2022: https://github.com/wandb/core/commit/328396fa7c89a2178d510a1be9c0d4451f350d7b
supported = client.version_supported("0.12.11") # edges were merged on
if not supported and warn:
# First local release to include the above is 0.9.50: https://github.com/wandb/local/releases/tag/0.9.50
wandb.termwarn(
"W&B Local Server version does not support ArtifactCollection gql edges; falling back to using legacy ArtifactSequence. Please update server to at least version 0.9.50."
)
return supported | python | wandb/apis/public.py | 3,683 | 3,695 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,615 | artifact_collection_edge_name | def artifact_collection_edge_name(server_supports_artifact_collections: bool) -> str:
return (
"artifactCollection"
if server_supports_artifact_collections
else "artifactSequence"
) | python | wandb/apis/public.py | 3,698 | 3,703 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,616 | artifact_collection_plural_edge_name | def artifact_collection_plural_edge_name(
server_supports_artifact_collections: bool,
) -> str:
return (
"artifactCollections"
if server_supports_artifact_collections
else "artifactSequences"
) | python | wandb/apis/public.py | 3,706 | 3,713 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,617 | __init__ | def __init__(
self,
client: Client,
entity: str,
project: str,
type_name: str,
per_page: Optional[int] = 50,
):
self.entity = entity
self.project = project
self.type_name = type_name
variable_values = {
"entityName": entity,
"projectName": project,
"artifactTypeName": type_name,
}
self.QUERY = gql(
"""
query ProjectArtifactCollections(
$entityName: String!,
$projectName: String!,
$artifactTypeName: String!
$cursor: String,
) {
project(name: $projectName, entityName: $entityName) {
artifactType(name: $artifactTypeName) {
artifactCollections: %s(after: $cursor) {
pageInfo {
endCursor
hasNextPage
}
totalCount
edges {
node {
id
name
description
createdAt
}
cursor
}
}
}
}
}
"""
% artifact_collection_plural_edge_name(
server_supports_artifact_collections_gql_edges(client)
)
)
super().__init__(client, variable_values, per_page) | python | wandb/apis/public.py | 3,717 | 3,770 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,618 | length | def length(self):
if self.last_response:
return self.last_response["project"]["artifactType"]["artifactCollections"][
"totalCount"
]
else:
return None | python | wandb/apis/public.py | 3,773 | 3,779 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,619 | more | def more(self):
if self.last_response:
return self.last_response["project"]["artifactType"]["artifactCollections"][
"pageInfo"
]["hasNextPage"]
else:
return True | python | wandb/apis/public.py | 3,782 | 3,788 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,620 | cursor | def cursor(self):
if self.last_response:
return self.last_response["project"]["artifactType"]["artifactCollections"][
"edges"
][-1]["cursor"]
else:
return None | python | wandb/apis/public.py | 3,791 | 3,797 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,621 | update_variables | def update_variables(self):
self.variables.update({"cursor": self.cursor}) | python | wandb/apis/public.py | 3,799 | 3,800 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,622 | convert_objects | def convert_objects(self):
return [
ArtifactCollection(
self.client,
self.entity,
self.project,
r["node"]["name"],
self.type_name,
)
for r in self.last_response["project"]["artifactType"][
"artifactCollections"
]["edges"]
] | python | wandb/apis/public.py | 3,802 | 3,814 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,623 | __init__ | def __init__(
self, client: Client, run: "Run", mode="logged", per_page: Optional[int] = 50
):
self.run = run
if mode == "logged":
self.run_key = "outputArtifacts"
self.QUERY = self.OUTPUT_QUERY
elif mode == "used":
self.run_key = "inputArtifacts"
self.QUERY = self.INPUT_QUERY
else:
raise ValueError("mode must be logged or used")
variable_values = {
"entity": run.entity,
"project": run.project,
"runName": run.id,
}
super().__init__(client, variable_values, per_page) | python | wandb/apis/public.py | 3,874 | 3,893 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,624 | length | def length(self):
if self.last_response:
return self.last_response["project"]["run"][self.run_key]["totalCount"]
else:
return None | python | wandb/apis/public.py | 3,896 | 3,900 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,625 | more | def more(self):
if self.last_response:
return self.last_response["project"]["run"][self.run_key]["pageInfo"][
"hasNextPage"
]
else:
return True | python | wandb/apis/public.py | 3,903 | 3,909 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,626 | cursor | def cursor(self):
if self.last_response:
return self.last_response["project"]["run"][self.run_key]["edges"][-1][
"cursor"
]
else:
return None | python | wandb/apis/public.py | 3,912 | 3,918 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,627 | convert_objects | def convert_objects(self):
return [
Artifact(
self.client,
self.run.entity,
self.run.project,
"{}:v{}".format(
r["node"]["artifactSequence"]["name"], r["node"]["versionIndex"]
),
r["node"],
)
for r in self.last_response["project"]["run"][self.run_key]["edges"]
] | python | wandb/apis/public.py | 3,920 | 3,932 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,628 | __init__ | def __init__(
self,
client: Client,
entity: str,
project: str,
type_name: str,
attrs: Optional[Mapping[str, Any]] = None,
):
self.client = client
self.entity = entity
self.project = project
self.type = type_name
self._attrs = attrs
if self._attrs is None:
self.load() | python | wandb/apis/public.py | 3,936 | 3,950 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,629 | load | def load(self):
query = gql(
"""
query ProjectArtifactType(
$entityName: String!,
$projectName: String!,
$artifactTypeName: String!
) {
project(name: $projectName, entityName: $entityName) {
artifactType(name: $artifactTypeName) {
id
name
description
createdAt
}
}
}
"""
)
response: Optional[Mapping[str, Any]] = self.client.execute(
query,
variable_values={
"entityName": self.entity,
"projectName": self.project,
"artifactTypeName": self.type,
},
)
if (
response is None
or response.get("project") is None
or response["project"].get("artifactType") is None
):
raise ValueError("Could not find artifact type %s" % self.type)
self._attrs = response["project"]["artifactType"]
return self._attrs | python | wandb/apis/public.py | 3,952 | 3,986 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,630 | id | def id(self):
return self._attrs["id"] | python | wandb/apis/public.py | 3,989 | 3,990 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,631 | name | def name(self):
return self._attrs["name"] | python | wandb/apis/public.py | 3,993 | 3,994 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,632 | collections | def collections(self, per_page=50):
"""Artifact collections."""
return ProjectArtifactCollections(
self.client, self.entity, self.project, self.type
) | python | wandb/apis/public.py | 3,997 | 4,001 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,633 | collection | def collection(self, name):
return ArtifactCollection(
self.client, self.entity, self.project, name, self.type
) | python | wandb/apis/public.py | 4,003 | 4,006 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,634 | __repr__ | def __repr__(self):
return f"<ArtifactType {self.type}>" | python | wandb/apis/public.py | 4,008 | 4,009 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,635 | __init__ | def __init__(
self,
client: Client,
entity: str,
project: str,
name: str,
type: str,
attrs: Optional[Mapping[str, Any]] = None,
):
self.client = client
self.entity = entity
self.project = project
self.name = name
self.type = type
self._attrs = attrs
if self._attrs is None:
self.load()
self._aliases = [a["node"]["alias"] for a in self._attrs["aliases"]["edges"]] | python | wandb/apis/public.py | 4,013 | 4,030 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,636 | id | def id(self):
return self._attrs["id"] | python | wandb/apis/public.py | 4,033 | 4,034 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,637 | versions | def versions(self, per_page=50):
"""Artifact versions."""
return ArtifactVersions(
self.client,
self.entity,
self.project,
self.name,
self.type,
per_page=per_page,
) | python | wandb/apis/public.py | 4,037 | 4,046 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,638 | aliases | def aliases(self):
"""Artifact Collection Aliases."""
return self._aliases | python | wandb/apis/public.py | 4,049 | 4,051 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,639 | load | def load(self):
query = gql(
"""
query ArtifactCollection(
$entityName: String!,
$projectName: String!,
$artifactTypeName: String!,
$artifactCollectionName: String!,
$cursor: String,
$perPage: Int = 1000
) {
project(name: $projectName, entityName: $entityName) {
artifactType(name: $artifactTypeName) {
artifactCollection: %s(name: $artifactCollectionName) {
id
name
description
createdAt
aliases(after: $cursor, first: $perPage){
edges {
node {
alias
}
cursor
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
}
}
"""
% artifact_collection_edge_name(
server_supports_artifact_collections_gql_edges(self.client)
)
)
response = self.client.execute(
query,
variable_values={
"entityName": self.entity,
"projectName": self.project,
"artifactTypeName": self.type,
"artifactCollectionName": self.name,
},
)
if (
response is None
or response.get("project") is None
or response["project"].get("artifactType") is None
or response["project"]["artifactType"].get("artifactCollection") is None
):
raise ValueError("Could not find artifact type %s" % self.type)
self._attrs = response["project"]["artifactType"]["artifactCollection"]
return self._attrs | python | wandb/apis/public.py | 4,053 | 4,109 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,640 | __repr__ | def __repr__(self):
return f"<ArtifactCollection {self.name} ({self.type})>" | python | wandb/apis/public.py | 4,111 | 4,112 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,641 | __init__ | def __init__(
self,
name: str,
entry: "artifacts.ArtifactManifestEntry",
parent_artifact: "Artifact",
):
super().__init__(
path=entry.path,
digest=entry.digest,
ref=entry.ref,
birth_artifact_id=entry.birth_artifact_id,
size=entry.size,
extra=entry.extra,
local_path=entry.local_path,
)
self.name = name
self._parent_artifact = parent_artifact | python | wandb/apis/public.py | 4,116 | 4,132 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,642 | parent_artifact | def parent_artifact(self):
return self._parent_artifact | python | wandb/apis/public.py | 4,134 | 4,135 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,643 | copy | def copy(self, cache_path, target_path):
raise NotImplementedError() | python | wandb/apis/public.py | 4,137 | 4,138 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,644 | download | def download(self, root=None):
root = root or self._parent_artifact._default_root()
dest_path = os.path.join(root, self.name)
self._parent_artifact._add_download_root(root)
manifest = self._parent_artifact._load_manifest()
# Skip checking the cache (and possibly downloading) if the file already exists
# and has the digest we're expecting.
entry = manifest.entries[self.name]
if os.path.exists(dest_path) and entry.digest == md5_file_b64(dest_path):
return dest_path
if self.ref is not None:
cache_path = manifest.storage_policy.load_reference(entry, local=True)
else:
cache_path = manifest.storage_policy.load_file(self._parent_artifact, entry)
return filesystem.copy_or_overwrite_changed(cache_path, dest_path) | python | wandb/apis/public.py | 4,140 | 4,158 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,645 | ref_target | def ref_target(self):
manifest = self._parent_artifact._load_manifest()
if self.ref is not None:
return manifest.storage_policy.load_reference(
manifest.entries[self.name],
local=False,
)
raise ValueError("Only reference entries support ref_target().") | python | wandb/apis/public.py | 4,160 | 4,167 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,646 | ref_url | def ref_url(self):
return (
"wandb-artifact://"
+ b64_to_hex_id(self._parent_artifact.id)
+ "/"
+ self.name
) | python | wandb/apis/public.py | 4,169 | 4,175 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,647 | __init__ | def __init__(
self,
nfiles: int,
clock_for_testing: Callable[[], float] = time.monotonic,
termlog_for_testing=termlog,
) -> None:
self._nfiles = nfiles
self._clock = clock_for_testing
self._termlog = termlog_for_testing
self._n_files_downloaded = 0
self._spinner_index = 0
self._last_log_time = self._clock()
self._lock = multiprocessing.dummy.Lock() | python | wandb/apis/public.py | 4,179 | 4,192 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,648 | notify_downloaded | def notify_downloaded(self) -> None:
with self._lock:
self._n_files_downloaded += 1
if self._n_files_downloaded == self._nfiles:
self._termlog(
f" {self._nfiles} of {self._nfiles} files downloaded. ",
# ^ trailing spaces to wipe out ellipsis from previous logs
newline=True,
)
self._last_log_time = self._clock()
elif self._clock() - self._last_log_time > 0.1:
self._spinner_index += 1
spinner = r"-\|/"[self._spinner_index % 4]
self._termlog(
f"{spinner} {self._n_files_downloaded} of {self._nfiles} files downloaded...\r",
newline=False,
)
self._last_log_time = self._clock() | python | wandb/apis/public.py | 4,194 | 4,211 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,649 | from_id | def from_id(cls, artifact_id: str, client: Client):
artifact = artifacts.get_artifacts_cache().get_artifact(artifact_id)
if artifact is not None:
return artifact
response: Mapping[str, Any] = client.execute(
Artifact.QUERY,
variable_values={"id": artifact_id},
)
name = None
if response.get("artifact") is not None:
if response["artifact"].get("aliases") is not None:
aliases = response["artifact"]["aliases"]
name = ":".join(
[aliases[0]["artifactCollectionName"], aliases[0]["alias"]]
)
if len(aliases) > 1:
for alias in aliases:
if alias["alias"] != "latest":
name = ":".join(
[alias["artifactCollectionName"], alias["alias"]]
)
break
p = response.get("artifact", {}).get("artifactType", {}).get("project", {})
project = p.get("name") # defaults to None
entity = p.get("entity", {}).get("name")
artifact = cls(
client=client,
entity=entity,
project=project,
name=name,
attrs=response["artifact"],
)
index_file_url = response["artifact"]["currentManifest"]["file"][
"directUrl"
]
with requests.get(index_file_url) as req:
req.raise_for_status()
artifact._manifest = artifacts.ArtifactManifest.from_manifest_json(
json.loads(util.ensure_text(req.content))
)
artifact._load_dependent_manifests()
return artifact | python | wandb/apis/public.py | 4,299 | 4,345 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,650 | __init__ | def __init__(self, client, entity, project, name, attrs=None):
self.client = client
self._entity = entity
self._project = project
self._artifact_name = name
self._artifact_collection_name = name.split(":")[0]
self._attrs = attrs
if self._attrs is None:
self._load()
# The entity and project above are taken from the passed-in artifact version path
# so if the user is pulling an artifact version from an artifact portfolio, the entity/project
# of that portfolio may be different than the birth entity/project of the artifact version.
self._birth_project = (
self._attrs.get("artifactType", {}).get("project", {}).get("name")
)
self._birth_entity = (
self._attrs.get("artifactType", {})
.get("project", {})
.get("entity", {})
.get("name")
)
self._metadata = json.loads(self._attrs.get("metadata") or "{}")
self._description = self._attrs.get("description", None)
self._sequence_name = self._attrs["artifactSequence"]["name"]
self._sequence_version_index = self._attrs.get("versionIndex", None)
# We will only show aliases under the Collection this artifact version is fetched from
# _aliases will be a mutable copy on which the user can append or remove aliases
self._aliases = [
a["alias"]
for a in self._attrs["aliases"]
if not re.match(r"^v\d+$", a["alias"])
and a["artifactCollectionName"] == self._artifact_collection_name
]
self._frozen_aliases = [a for a in self._aliases]
self._manifest = None
self._is_downloaded = False
self._dependent_artifacts = []
self._download_roots = set()
artifacts.get_artifacts_cache().store_artifact(self) | python | wandb/apis/public.py | 4,347 | 4,386 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,651 | id | def id(self):
return self._attrs["id"] | python | wandb/apis/public.py | 4,389 | 4,390 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,652 | file_count | def file_count(self):
return self._attrs["fileCount"] | python | wandb/apis/public.py | 4,393 | 4,394 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,653 | source_version | def source_version(self):
"""The artifact's version index under its parent artifact collection.
A string with the format "v{number}".
"""
return f"v{self._sequence_version_index}" | python | wandb/apis/public.py | 4,397 | 4,402 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,654 | version | def version(self):
"""The artifact's version index under the given artifact collection.
A string with the format "v{number}".
"""
for a in self._attrs["aliases"]:
if a[
"artifactCollectionName"
] == self._artifact_collection_name and util.alias_is_version_index(
a["alias"]
):
return a["alias"]
return None | python | wandb/apis/public.py | 4,405 | 4,417 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,655 | entity | def entity(self):
return self._entity | python | wandb/apis/public.py | 4,420 | 4,421 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,656 | project | def project(self):
return self._project | python | wandb/apis/public.py | 4,424 | 4,425 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,657 | metadata | def metadata(self):
return self._metadata | python | wandb/apis/public.py | 4,428 | 4,429 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,658 | metadata | def metadata(self, metadata):
self._metadata = metadata | python | wandb/apis/public.py | 4,432 | 4,433 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,659 | manifest | def manifest(self):
return self._load_manifest() | python | wandb/apis/public.py | 4,436 | 4,437 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,660 | digest | def digest(self):
return self._attrs["digest"] | python | wandb/apis/public.py | 4,440 | 4,441 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,661 | state | def state(self):
return self._attrs["state"] | python | wandb/apis/public.py | 4,444 | 4,445 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,662 | size | def size(self):
return self._attrs["size"] | python | wandb/apis/public.py | 4,448 | 4,449 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,663 | created_at | def created_at(self):
"""The time at which the artifact was created."""
return self._attrs["createdAt"] | python | wandb/apis/public.py | 4,452 | 4,454 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,664 | updated_at | def updated_at(self):
"""The time at which the artifact was last updated."""
return self._attrs["updatedAt"] or self._attrs["createdAt"] | python | wandb/apis/public.py | 4,457 | 4,459 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,665 | description | def description(self):
return self._description | python | wandb/apis/public.py | 4,462 | 4,463 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,666 | description | def description(self, desc):
self._description = desc | python | wandb/apis/public.py | 4,466 | 4,467 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,667 | type | def type(self):
return self._attrs["artifactType"]["name"] | python | wandb/apis/public.py | 4,470 | 4,471 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,668 | commit_hash | def commit_hash(self):
return self._attrs.get("commitHash", "") | python | wandb/apis/public.py | 4,474 | 4,475 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,669 | name | def name(self):
if self._sequence_version_index is None:
return self.digest
return f"{self._sequence_name}:v{self._sequence_version_index}" | python | wandb/apis/public.py | 4,478 | 4,481 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,670 | aliases | def aliases(self):
"""The aliases associated with this artifact.
Returns:
List[str]: The aliases associated with this artifact.
"""
return self._aliases | python | wandb/apis/public.py | 4,484 | 4,491 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,671 | aliases | def aliases(self, aliases):
for alias in aliases:
if any(char in alias for char in ["/", ":"]):
raise ValueError(
'Invalid alias "%s", slashes and colons are disallowed' % alias
)
self._aliases = aliases | python | wandb/apis/public.py | 4,494 | 4,500 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,672 | expected_type | def expected_type(client, name, entity_name, project_name):
"""Returns the expected type for a given artifact name and project."""
query = gql(
"""
query ArtifactType(
$entityName: String,
$projectName: String,
$name: String!
) {
project(name: $projectName, entityName: $entityName) {
artifact(name: $name) {
artifactType {
name
}
}
}
}
"""
)
if ":" not in name:
name += ":latest"
response = client.execute(
query,
variable_values={
"entityName": entity_name,
"projectName": project_name,
"name": name,
},
)
project = response.get("project")
if project is not None:
artifact = project.get("artifact")
if artifact is not None:
artifact_type = artifact.get("artifactType")
if artifact_type is not None:
return artifact_type.get("name")
return None | python | wandb/apis/public.py | 4,503 | 4,542 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,673 | _use_as | def _use_as(self):
return self._attrs.get("_use_as") | python | wandb/apis/public.py | 4,545 | 4,546 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,674 | _use_as | def _use_as(self, use_as):
self._attrs["_use_as"] = use_as
return use_as | python | wandb/apis/public.py | 4,549 | 4,551 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,675 | link | def link(self, target_path: str, aliases=None):
if ":" in target_path:
raise ValueError(
f"target_path {target_path} cannot contain `:` because it is not an alias."
)
portfolio, project, entity = util._parse_entity_project_item(target_path)
aliases = util._resolve_aliases(aliases)
EmptyRunProps = namedtuple("Empty", "entity project")
r = wandb.run if wandb.run else EmptyRunProps(entity=None, project=None)
entity = entity or r.entity or self.entity
project = project or r.project or self.project
mutation = gql(
"""
mutation LinkArtifact($artifactID: ID!, $artifactPortfolioName: String!, $entityName: String!, $projectName: String!, $aliases: [ArtifactAliasInput!]) {
linkArtifact(input: {artifactID: $artifactID, artifactPortfolioName: $artifactPortfolioName,
entityName: $entityName,
projectName: $projectName,
aliases: $aliases
}) {
versionIndex
}
}
"""
)
self.client.execute(
mutation,
variable_values={
"artifactID": self.id,
"artifactPortfolioName": portfolio,
"entityName": entity,
"projectName": project,
"aliases": [
{"alias": alias, "artifactCollectionName": portfolio}
for alias in aliases
],
},
)
return True | python | wandb/apis/public.py | 4,554 | 4,594 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,676 | delete | def delete(self, delete_aliases=False):
"""Delete an artifact and its files.
Examples:
Delete all the "model" artifacts a run has logged:
```
runs = api.runs(path="my_entity/my_project")
for run in runs:
for artifact in run.logged_artifacts():
if artifact.type == "model":
artifact.delete(delete_aliases=True)
```
Arguments:
delete_aliases: (bool) If true, deletes all aliases associated with the artifact.
Otherwise, this raises an exception if the artifact has existing aliases.
"""
mutation = gql(
"""
mutation DeleteArtifact($artifactID: ID!, $deleteAliases: Boolean) {
deleteArtifact(input: {
artifactID: $artifactID
deleteAliases: $deleteAliases
}) {
artifact {
id
}
}
}
"""
)
self.client.execute(
mutation,
variable_values={
"artifactID": self.id,
"deleteAliases": delete_aliases,
},
)
return True | python | wandb/apis/public.py | 4,597 | 4,635 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,677 | new_file | def new_file(self, name, mode=None):
raise ValueError("Cannot add files to an artifact once it has been saved") | python | wandb/apis/public.py | 4,637 | 4,638 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,678 | add_file | def add_file(self, local_path, name=None, is_tmp=False):
raise ValueError("Cannot add files to an artifact once it has been saved") | python | wandb/apis/public.py | 4,640 | 4,641 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,679 | add_dir | def add_dir(self, path, name=None):
raise ValueError("Cannot add files to an artifact once it has been saved") | python | wandb/apis/public.py | 4,643 | 4,644 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,680 | add_reference | def add_reference(self, uri, name=None, checksum=True, max_objects=None):
raise ValueError("Cannot add files to an artifact once it has been saved") | python | wandb/apis/public.py | 4,646 | 4,647 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,681 | add | def add(self, obj, name):
raise ValueError("Cannot add files to an artifact once it has been saved") | python | wandb/apis/public.py | 4,649 | 4,650 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,682 | _add_download_root | def _add_download_root(self, dir_path):
"""Make `dir_path` a root directory for this artifact."""
self._download_roots.add(os.path.abspath(dir_path)) | python | wandb/apis/public.py | 4,652 | 4,654 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,683 | _is_download_root | def _is_download_root(self, dir_path):
"""Determine if `dir_path` is a root directory for this artifact."""
return dir_path in self._download_roots | python | wandb/apis/public.py | 4,656 | 4,658 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,684 | _local_path_to_name | def _local_path_to_name(self, file_path):
"""Convert a local file path to a path entry in the artifact."""
abs_file_path = os.path.abspath(file_path)
abs_file_parts = abs_file_path.split(os.sep)
for i in range(len(abs_file_parts) + 1):
if self._is_download_root(os.path.join(os.sep, *abs_file_parts[:i])):
return os.path.join(*abs_file_parts[i:])
return None | python | wandb/apis/public.py | 4,660 | 4,667 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,685 | _get_obj_entry | def _get_obj_entry(self, name):
"""Return an object entry by name, handling any type suffixes.
When objects are added with `.add(obj, name)`, the name is typically changed to
include the suffix of the object type when serializing to JSON. So we need to be
able to resolve a name, without tasking the user with appending .THING.json.
This method returns an entry if it exists by a suffixed name.
Args:
name: (str) name used when adding
"""
self._load_manifest()
type_mapping = WBValue.type_mapping()
for artifact_type_str in type_mapping:
wb_class = type_mapping[artifact_type_str]
wandb_file_name = wb_class.with_suffix(name)
entry = self._manifest.entries.get(wandb_file_name)
if entry is not None:
return entry, wb_class
return None, None | python | wandb/apis/public.py | 4,669 | 4,689 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,686 | get_path | def get_path(self, name):
manifest = self._load_manifest()
entry = manifest.entries.get(name)
if entry is None:
entry = self._get_obj_entry(name)[0]
if entry is None:
raise KeyError("Path not contained in artifact: %s" % name)
else:
name = entry.path
return _DownloadedArtifactEntry(name, entry, self) | python | wandb/apis/public.py | 4,691 | 4,701 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,687 | get | def get(self, name):
entry, wb_class = self._get_obj_entry(name)
if entry is not None:
# If the entry is a reference from another artifact, then get it directly from that artifact
if self._manifest_entry_is_artifact_reference(entry):
artifact = self._get_ref_artifact_from_entry(entry)
return artifact.get(util.uri_from_path(entry.ref))
# Special case for wandb.Table. This is intended to be a short term optimization.
# Since tables are likely to download many other assets in artifact(s), we eagerly download
# the artifact using the parallelized `artifact.download`. In the future, we should refactor
# the deserialization pattern such that this special case is not needed.
if wb_class == wandb.Table:
self.download(recursive=True)
# Get the ArtifactManifestEntry
item = self.get_path(entry.path)
item_path = item.download()
# Load the object from the JSON blob
result = None
json_obj = {}
with open(item_path) as file:
json_obj = json.load(file)
result = wb_class.from_json(json_obj, self)
result._set_artifact_source(self, name)
return result | python | wandb/apis/public.py | 4,703 | 4,729 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,688 | download | def download(self, root=None, recursive=False):
dirpath = root or self._default_root()
self._add_download_root(dirpath)
manifest = self._load_manifest()
nfiles = len(manifest.entries)
size = sum(e.size for e in manifest.entries.values())
log = False
if nfiles > 5000 or size > 50 * 1024 * 1024:
log = True
termlog(
"Downloading large artifact %s, %.2fMB. %s files... "
% (self._artifact_name, size / (1024 * 1024), nfiles),
)
start_time = datetime.datetime.now()
# Force all the files to download into the same directory.
# Download in parallel
import multiprocessing.dummy # this uses threads
download_logger = _ArtifactDownloadLogger(nfiles=nfiles)
pool = multiprocessing.dummy.Pool(32)
pool.map(
partial(self._download_file, root=dirpath, download_logger=download_logger),
manifest.entries,
)
if recursive:
pool.map(lambda artifact: artifact.download(), self._dependent_artifacts)
pool.close()
pool.join()
self._is_downloaded = True
if log:
now = datetime.datetime.now()
delta = abs((now - start_time).total_seconds())
hours = int(delta // 3600)
minutes = int((delta - hours * 3600) // 60)
seconds = delta - hours * 3600 - minutes * 60
termlog(
f"Done. {hours}:{minutes}:{seconds:.1f}",
prefix=False,
)
return dirpath | python | wandb/apis/public.py | 4,731 | 4,774 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,689 | checkout | def checkout(self, root=None):
dirpath = root or self._default_root(include_version=False)
for root, _, files in os.walk(dirpath):
for file in files:
full_path = os.path.join(root, file)
artifact_path = util.to_forward_slash_path(
os.path.relpath(full_path, start=dirpath)
)
try:
self.get_path(artifact_path)
except KeyError:
# File is not part of the artifact, remove it.
os.remove(full_path)
return self.download(root=dirpath) | python | wandb/apis/public.py | 4,776 | 4,791 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,690 | verify | def verify(self, root=None):
dirpath = root or self._default_root()
manifest = self._load_manifest()
ref_count = 0
for root, _, files in os.walk(dirpath):
for file in files:
full_path = os.path.join(root, file)
artifact_path = util.to_forward_slash_path(
os.path.relpath(full_path, start=dirpath)
)
try:
self.get_path(artifact_path)
except KeyError:
raise ValueError(
"Found file {} which is not a member of artifact {}".format(
full_path, self.name
)
)
for entry in manifest.entries.values():
if entry.ref is None:
if md5_file_b64(os.path.join(dirpath, entry.path)) != entry.digest:
raise ValueError("Digest mismatch for file: %s" % entry.path)
else:
ref_count += 1
if ref_count > 0:
print("Warning: skipped verification of %s refs" % ref_count) | python | wandb/apis/public.py | 4,793 | 4,820 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,691 | file | def file(self, root=None):
"""Download a single file artifact to dir specified by the root.
Arguments:
root: (str, optional) The root directory in which to place the file. Defaults to './artifacts/self.name/'.
Returns:
(str): The full path of the downloaded file.
"""
if root is None:
root = os.path.join(".", "artifacts", self.name)
manifest = self._load_manifest()
nfiles = len(manifest.entries)
if nfiles > 1:
raise ValueError(
"This artifact contains more than one file, call `.download()` to get all files or call "
'.get_path("filename").download()'
)
return self._download_file(list(manifest.entries)[0], root=root) | python | wandb/apis/public.py | 4,822 | 4,842 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,692 | _download_file | def _download_file(
self, name, root, download_logger: Optional[_ArtifactDownloadLogger] = None
):
# download file into cache and copy to target dir
downloaded_path = self.get_path(name).download(root)
if download_logger is not None:
download_logger.notify_downloaded()
return downloaded_path | python | wandb/apis/public.py | 4,844 | 4,851 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,693 | _default_root | def _default_root(self, include_version=True):
root = (
os.path.join(".", "artifacts", self.name)
if include_version
else os.path.join(".", "artifacts", self._sequence_name)
)
if platform.system() == "Windows":
head, tail = os.path.splitdrive(root)
root = head + tail.replace(":", "-")
return root | python | wandb/apis/public.py | 4,853 | 4,862 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,694 | json_encode | def json_encode(self):
return util.artifact_to_json(self) | python | wandb/apis/public.py | 4,864 | 4,865 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,695 | save | def save(self):
"""Persists artifact changes to the wandb backend."""
mutation = gql(
"""
mutation updateArtifact(
$artifactID: ID!,
$description: String,
$metadata: JSONString,
$aliases: [ArtifactAliasInput!]
) {
updateArtifact(input: {
artifactID: $artifactID,
description: $description,
metadata: $metadata,
aliases: $aliases
}) {
artifact {
id
}
}
}
"""
)
introspect_query = gql(
"""
query ProbeServerAddAliasesInput {
AddAliasesInputInfoType: __type(name: "AddAliasesInput") {
name
inputFields {
name
}
}
}
"""
)
res = self.client.execute(introspect_query)
valid = res.get("AddAliasesInputInfoType")
aliases = None
if not valid:
# If valid, wandb backend version >= 0.13.0.
# This means we can safely remove aliases from this updateArtifact request since we'll be calling
# the alias endpoints below in _save_alias_changes.
# If not valid, wandb backend version < 0.13.0. This requires aliases to be sent in updateArtifact.
aliases = [
{
"artifactCollectionName": self._artifact_collection_name,
"alias": alias,
}
for alias in self._aliases
]
self.client.execute(
mutation,
variable_values={
"artifactID": self.id,
"description": self.description,
"metadata": util.json_dumps_safer(self.metadata),
"aliases": aliases,
},
)
# Save locally modified aliases
self._save_alias_changes()
return True | python | wandb/apis/public.py | 4,868 | 4,930 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,696 | wait | def wait(self):
return self | python | wandb/apis/public.py | 4,932 | 4,933 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,697 | _save_alias_changes | def _save_alias_changes(self):
"""Persist alias changes on this artifact to the wandb backend.
Called by artifact.save().
"""
aliases_to_add = set(self._aliases) - set(self._frozen_aliases)
aliases_to_remove = set(self._frozen_aliases) - set(self._aliases)
# Introspect
introspect_query = gql(
"""
query ProbeServerAddAliasesInput {
AddAliasesInputInfoType: __type(name: "AddAliasesInput") {
name
inputFields {
name
}
}
}
"""
)
res = self.client.execute(introspect_query)
valid = res.get("AddAliasesInputInfoType")
if not valid:
return
if len(aliases_to_add) > 0:
add_mutation = gql(
"""
mutation addAliases(
$artifactID: ID!,
$aliases: [ArtifactCollectionAliasInput!]!,
) {
addAliases(
input: {
artifactID: $artifactID,
aliases: $aliases,
}
) {
success
}
}
"""
)
self.client.execute(
add_mutation,
variable_values={
"artifactID": self.id,
"aliases": [
{
"artifactCollectionName": self._artifact_collection_name,
"alias": alias,
"entityName": self._entity,
"projectName": self._project,
}
for alias in aliases_to_add
],
},
)
if len(aliases_to_remove) > 0:
delete_mutation = gql(
"""
mutation deleteAliases(
$artifactID: ID!,
$aliases: [ArtifactCollectionAliasInput!]!,
) {
deleteAliases(
input: {
artifactID: $artifactID,
aliases: $aliases,
}
) {
success
}
}
"""
)
self.client.execute(
delete_mutation,
variable_values={
"artifactID": self.id,
"aliases": [
{
"artifactCollectionName": self._artifact_collection_name,
"alias": alias,
"entityName": self._entity,
"projectName": self._project,
}
for alias in aliases_to_remove
],
},
)
# reset local state
self._frozen_aliases = self._aliases
return True | python | wandb/apis/public.py | 4,936 | 5,032 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,698 | _list | def _list(self):
manifest = self._load_manifest()
return manifest.entries.keys() | python | wandb/apis/public.py | 5,035 | 5,037 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,699 | __repr__ | def __repr__(self):
return f"<Artifact {self.id}>" | python | wandb/apis/public.py | 5,039 | 5,040 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
1,700 | _load | def _load(self):
query = gql(
"""
query Artifact(
$entityName: String,
$projectName: String,
$name: String!
) {
project(name: $projectName, entityName: $entityName) {
artifact(name: $name) {
...ArtifactFragment
}
}
}
%s
"""
% ARTIFACT_FRAGMENT
)
response = None
try:
response = self.client.execute(
query,
variable_values={
"entityName": self.entity,
"projectName": self.project,
"name": self._artifact_name,
},
)
except Exception:
# we check for this after doing the call, since the backend supports raw digest lookups
# which don't include ":" and are 32 characters long
if ":" not in self._artifact_name and len(self._artifact_name) != 32:
raise ValueError(
'Attempted to fetch artifact without alias (e.g. "<artifact_name>:v3" or "<artifact_name>:latest")'
)
if (
response is None
or response.get("project") is None
or response["project"].get("artifact") is None
):
raise ValueError(
'Project %s/%s does not contain artifact: "%s"'
% (self.entity, self.project, self._artifact_name)
)
self._attrs = response["project"]["artifact"]
return self._attrs | python | wandb/apis/public.py | 5,042 | 5,087 | {
"name": "Git-abouvier/wandb",
"url": "https://github.com/Git-abouvier/wandb.git",
"license": "MIT",
"stars": 0,
"forks": 0
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.