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,901
from_json
def from_json(cls, spec: dict) -> "CodeBlock": code = [child["children"][0]["text"] for child in spec["children"]] language = spec.get("language", "python") return cls(code, language)
python
wandb/apis/reports/_blocks.py
579
582
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,902
spec
def spec(self) -> dict: language = self.language.lower() return { "type": "code-block", "children": [ { "type": "code-line", "children": [{"text": text}], "language": language, } for text in self.code ], "language": language, }
python
wandb/apis/reports/_blocks.py
585
598
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,903
__init__
def __init__(self, text="", *args, **kwargs): super().__init__(*args, **kwargs) self.text = text if isinstance(self.text, list): self.text = "\n".join(self.text)
python
wandb/apis/reports/_blocks.py
604
608
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,904
from_json
def from_json(cls, spec: dict) -> "MarkdownBlock": text = spec["content"] return cls(text)
python
wandb/apis/reports/_blocks.py
611
613
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,905
spec
def spec(self) -> dict: return { "type": "markdown-block", "children": [{"text": ""}], "content": self.text, }
python
wandb/apis/reports/_blocks.py
616
621
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,906
__init__
def __init__(self, text="", *args, **kwargs): super().__init__(*args, **kwargs) self.text = text if isinstance(self.text, list): self.text = "\n".join(self.text)
python
wandb/apis/reports/_blocks.py
627
631
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,907
from_json
def from_json(cls, spec: dict) -> "LaTeXBlock": text = spec["content"] return cls(text)
python
wandb/apis/reports/_blocks.py
634
636
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,908
spec
def spec(self) -> dict: return { "type": "latex", "children": [{"text": ""}], "content": self.text, "block": True, }
python
wandb/apis/reports/_blocks.py
639
645
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,909
__init__
def __init__(self, ids, *args, **kwargs): super().__init__(*args, **kwargs) self.ids = ids
python
wandb/apis/reports/_blocks.py
651
653
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,910
from_json
def from_json(cls, spec: dict) -> "Gallery": ids = spec["ids"] return cls(ids)
python
wandb/apis/reports/_blocks.py
656
658
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,911
from_report_urls
def from_report_urls(cls, urls: LList[str]) -> "Gallery": from .report import Report ids = [Report._url_to_report_id(url) for url in urls] return cls(ids)
python
wandb/apis/reports/_blocks.py
661
665
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,912
spec
def spec(self) -> dict: return {"type": "gallery", "children": [{"text": ""}], "ids": self.ids}
python
wandb/apis/reports/_blocks.py
668
669
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,913
__init__
def __init__(self, url, caption=None, *args, **kwargs): super().__init__(*args, **kwargs) self.url = url self.caption = caption
python
wandb/apis/reports/_blocks.py
676
679
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,914
from_json
def from_json(cls, spec: dict) -> "Image": url = spec["url"] caption = spec["children"][0]["text"] if spec.get("hasCaption") else None return cls(url, caption)
python
wandb/apis/reports/_blocks.py
682
685
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,915
spec
def spec(self) -> dict: if self.caption: return { "type": "image", "children": [{"text": self.caption}], "url": self.url, "hasCaption": True, } else: return {"type": "image", "children": [{"text": ""}], "url": self.url}
python
wandb/apis/reports/_blocks.py
688
697
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,916
__init__
def __init__(self, entity, project, table_name, *args, **kwargs): super().__init__(*args, **kwargs) self.entity = entity self.project = project self.table_name = table_name
python
wandb/apis/reports/_blocks.py
707
711
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,917
from_json
def from_json(cls, spec: dict) -> "WeaveBlockSummaryTable": entity = spec["config"]["panelConfig"]["exp"]["fromOp"]["inputs"]["obj"][ "fromOp" ]["inputs"]["run"]["fromOp"]["inputs"]["project"]["fromOp"]["inputs"][ "entityName" ][ "val" ] project = spec["config"]["panelConfig"]["exp"]["fromOp"]["inputs"]["obj"][ "fromOp" ]["inputs"]["run"]["fromOp"]["inputs"]["project"]["fromOp"]["inputs"][ "projectName" ][ "val" ] table_name = spec["config"]["panelConfig"]["exp"]["fromOp"]["inputs"]["key"][ "val" ] return cls(entity, project, table_name)
python
wandb/apis/reports/_blocks.py
714
732
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,918
spec
def spec(self) -> dict: return { "type": "weave-panel", "children": [{"text": ""}], "config": { "panelConfig": { "exp": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": { "type": "typedDict", "propertyTypes": {"project": "project"}, }, }, "value": { "type": "list", "objectType": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": {"run": "run"}, }, "value": { "type": "union", "members": [ { "type": "file", "extension": "json", "wbObjectType": { "type": "table", "columnTypes": {}, }, }, "none", ], }, }, }, }, "fromOp": { "name": "pick", "inputs": { "obj": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": { "type": "typedDict", "propertyTypes": {"project": "project"}, }, }, "value": { "type": "list", "objectType": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": {"run": "run"}, }, "value": { "type": "union", "members": [ { "type": "typedDict", "propertyTypes": { "_wandb": { "type": "typedDict", "propertyTypes": { "runtime": "number" }, } }, }, { "type": "typedDict", "propertyTypes": { "_step": "number", "table": { "type": "file", "extension": "json", "wbObjectType": { "type": "table", "columnTypes": {}, }, }, "_wandb": { "type": "typedDict", "propertyTypes": { "runtime": "number" }, }, "_runtime": "number", "_timestamp": "number", }, }, { "type": "typedDict", "propertyTypes": {}, }, ], }, }, }, }, "fromOp": { "name": "run-summary", "inputs": { "run": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": { "type": "typedDict", "propertyTypes": { "project": "project" }, }, }, "value": { "type": "list", "objectType": "run", }, }, "fromOp": { "name": "project-runs", "inputs": { "project": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": "project", }, "fromOp": { "name": "root-project", "inputs": { "entityName": { "nodeType": "const", "type": "string", "val": self.entity, }, "projectName": { "nodeType": "const", "type": "string", "val": self.project, }, }, }, } }, }, } }, }, }, "key": { "nodeType": "const", "type": "string", "val": self.table_name, }, }, }, "__userInput": True, } } }, }
python
wandb/apis/reports/_blocks.py
735
935
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,919
__init__
def __init__(self, entity, project, artifact, tab="overview", *args, **kwargs): super().__init__(*args, **kwargs) self.entity = entity self.project = project self.artifact = artifact self.tab = tab
python
wandb/apis/reports/_blocks.py
948
953
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,920
from_json
def from_json(cls, spec: dict) -> "WeaveBlockSummaryTable": inputs = weave_inputs(spec) entity = inputs["project"]["fromOp"]["inputs"]["entityName"]["val"] project = inputs["project"]["fromOp"]["inputs"]["projectName"]["val"] artifact = inputs["artifactName"]["val"] tab = spec["config"]["panelConfig"]["panelConfig"]["tabConfigs"]["overview"][ "selectedTab" ] return cls(entity, project, artifact, tab)
python
wandb/apis/reports/_blocks.py
956
964
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,921
spec
def spec(self) -> dict: return { "type": "weave-panel", "children": [{"text": ""}], "config": { "panelConfig": { "exp": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": { "type": "typedDict", "propertyTypes": { "project": "project", "artifactName": "string", }, }, }, "value": "artifact", }, "fromOp": { "name": "project-artifact", "inputs": { "project": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": "project", }, "fromOp": { "name": "root-project", "inputs": { "entityName": { "nodeType": "const", "type": "string", "val": self.entity, }, "projectName": { "nodeType": "const", "type": "string", "val": self.project, }, }, }, }, "artifactName": { "nodeType": "const", "type": "string", "val": self.artifact, }, }, }, "__userInput": True, }, "panelInputType": { "type": "tagged", "tag": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": { "type": "typedDict", "propertyTypes": { "project": "project", "artifactName": "string", }, }, }, "value": "artifact", }, "panelConfig": { "tabConfigs": {"overview": {"selectedTab": self.tab}} }, } }, }
python
wandb/apis/reports/_blocks.py
967
1,063
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,922
__init__
def __init__(self, entity, project, artifact, version, file, *args, **kwargs): super().__init__(*args, **kwargs) self.entity = entity self.project = project self.artifact = artifact self.version = version self.file = file
python
wandb/apis/reports/_blocks.py
1,075
1,081
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,923
from_json
def from_json(cls, spec: dict) -> "WeaveBlockSummaryTable": inputs = weave_inputs(spec) entity = inputs["artifactVersion"]["fromOp"]["inputs"]["project"]["fromOp"][ "inputs" ]["entityName"]["val"] project = inputs["artifactVersion"]["fromOp"]["inputs"]["project"]["fromOp"][ "inputs" ]["projectName"]["val"] artifact = inputs["artifactVersion"]["fromOp"]["inputs"]["artifactName"]["val"] version = inputs["artifactVersion"]["fromOp"]["inputs"]["artifactVersionAlias"][ "val" ] file = inputs["path"]["val"] return cls(entity, project, artifact, version, file)
python
wandb/apis/reports/_blocks.py
1,084
1,097
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,924
spec
def spec(self) -> dict: return { "type": "weave-panel", "children": [{"text": ""}], "config": { "panelConfig": { "exp": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": { "type": "typedDict", "propertyTypes": { "project": "project", "artifactName": "string", "artifactVersionAlias": "string", }, }, }, "value": { "type": "file", "extension": "json", "wbObjectType": {"type": "table", "columnTypes": {}}, }, }, "fromOp": { "name": "artifactVersion-file", "inputs": { "artifactVersion": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": { "type": "typedDict", "propertyTypes": { "project": "project", "artifactName": "string", "artifactVersionAlias": "string", }, }, }, "value": "artifactVersion", }, "fromOp": { "name": "project-artifactVersion", "inputs": { "project": { "nodeType": "output", "type": { "type": "tagged", "tag": { "type": "typedDict", "propertyTypes": { "entityName": "string", "projectName": "string", }, }, "value": "project", }, "fromOp": { "name": "root-project", "inputs": { "entityName": { "nodeType": "const", "type": "string", "val": self.entity, }, "projectName": { "nodeType": "const", "type": "string", "val": self.project, }, }, }, }, "artifactName": { "nodeType": "const", "type": "string", "val": self.artifact, }, "artifactVersionAlias": { "nodeType": "const", "type": "string", "val": self.version, }, }, }, }, "path": { "nodeType": "const", "type": "string", "val": self.file, }, }, }, "__userInput": True, } } }, }
python
wandb/apis/reports/_blocks.py
1,100
1,217
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,925
from_json
def from_json(cls, spec: dict) -> "HorizontalRule": return cls()
python
wandb/apis/reports/_blocks.py
1,222
1,223
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,926
spec
def spec(self): return {"type": "horizontal-rule", "children": [{"text": ""}]}
python
wandb/apis/reports/_blocks.py
1,226
1,227
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,927
from_json
def from_json(cls, spec: dict) -> "TableOfContents": return cls()
python
wandb/apis/reports/_blocks.py
1,232
1,233
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,928
spec
def spec(self) -> dict: return {"type": "table-of-contents", "children": [{"text": ""}]}
python
wandb/apis/reports/_blocks.py
1,236
1,237
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,929
__init__
def __init__(self, url, *args, **kwargs): super().__init__(*args, **kwargs) self.url = url
python
wandb/apis/reports/_blocks.py
1,243
1,245
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,930
from_json
def from_json(cls, spec: dict) -> "SoundCloud": quoted_url = spec["html"].split("url=")[-1].split("&show_artwork")[0] url = urllib.parse.unquote(quoted_url) return cls(url)
python
wandb/apis/reports/_blocks.py
1,248
1,251
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,931
spec
def spec(self) -> dict: quoted_url = urllib.parse.quote(self.url) return { "type": "soundcloud", "html": f'<iframe width="100%" height="400" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?visual=true&url={quoted_url}&show_artwork=true"></iframe>', "children": [{"text": ""}], }
python
wandb/apis/reports/_blocks.py
1,254
1,260
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,932
__init__
def __init__(self, embed_html, *args, **kwargs): super().__init__(*args, **kwargs) self.embed_html = embed_html if self.embed_html: pattern = r" <script[\s\S]+?/script>" self.embed_html = re.sub(pattern, "\n", self.embed_html)
python
wandb/apis/reports/_blocks.py
1,266
1,271
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,933
from_json
def from_json(cls, spec: dict) -> "Twitter": embed_html = spec["html"] return cls(embed_html)
python
wandb/apis/reports/_blocks.py
1,274
1,276
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,934
spec
def spec(self) -> dict: return {"type": "twitter", "html": self.embed_html, "children": [{"text": ""}]}
python
wandb/apis/reports/_blocks.py
1,279
1,280
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,935
__init__
def __init__(self, spotify_id, *args, **kwargs): super().__init__(*args, **kwargs) self.spotify_id = spotify_id
python
wandb/apis/reports/_blocks.py
1,286
1,288
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,936
from_json
def from_json(cls, spec: dict) -> "Spotify": return cls(spec["spotifyID"])
python
wandb/apis/reports/_blocks.py
1,291
1,292
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,937
from_url
def from_url(cls, url: str) -> "Spotify": spotify_id = url.split("/")[-1].split("?")[0] return cls(spotify_id)
python
wandb/apis/reports/_blocks.py
1,295
1,297
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,938
spec
def spec(self) -> dict: return { "type": "spotify", "spotifyType": "track", "spotifyID": self.spotify_id, "children": [{"text": ""}], }
python
wandb/apis/reports/_blocks.py
1,300
1,306
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,939
__init__
def __init__(self, url, *args, **kwargs): super().__init__(*args, **kwargs) self.url = url
python
wandb/apis/reports/_blocks.py
1,312
1,314
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,940
from_json
def from_json(cls, spec: dict) -> "Video": return cls(spec["url"])
python
wandb/apis/reports/_blocks.py
1,317
1,318
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,941
spec
def spec(self) -> dict: return { "type": "video", "url": self.url, "children": [{"text": ""}], }
python
wandb/apis/reports/_blocks.py
1,321
1,326
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,942
__init__
def __init__(self, text="", *args, **kwargs): super().__init__(*args, **kwargs) self.text = text
python
wandb/apis/reports/_blocks.py
1,332
1,334
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,943
from_json
def from_json(cls, spec): if isinstance(spec["children"], str): text = spec["children"] else: text = [] for elem in spec["children"]: if elem.get("type") == "latex": text.append(InlineLaTeX(elem["content"])) elif elem.get("type") == "link": text.append(Link(elem["children"][0]["text"], elem["url"])) elif elem.get("inlineCode"): text.append(InlineCode(elem["text"])) elif elem.get("text"): text.append(elem["text"]) if not isinstance(text, list): text = [text] return cls(text)
python
wandb/apis/reports/_blocks.py
1,337
1,354
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,944
spec
def spec(self) -> dict: if isinstance(self.text, list): content = [ t.spec if not isinstance(t, str) else {"text": t} for t in self.text ] else: content = [{"text": self.text}] return {"type": "paragraph", "children": content}
python
wandb/apis/reports/_blocks.py
1,357
1,365
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,945
__init__
def __init__(self, spec, *args, **kwargs): super().__init__(*args, **kwargs) self._spec = spec
python
wandb/apis/reports/_blocks.py
1,369
1,371
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,946
from_json
def from_json(cls, spec): obj = cls(spec=spec) obj._spec = spec return obj
python
wandb/apis/reports/_blocks.py
1,374
1,377
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,947
spec
def spec(self): return self._spec
python
wandb/apis/reports/_blocks.py
1,380
1,381
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,948
generate_name
def generate_name(length: int = 12) -> str: """Generate a random name. This implementation roughly based the following snippet in core: https://github.com/wandb/core/blob/master/lib/js/cg/src/utils/string.ts#L39-L44. """ # Borrowed from numpy: https://github.com/numpy/numpy/blob/v1.23.0/numpy/core/numeric.py#L2069-L2123 def base_repr(number: int, base: int, padding: int = 0) -> str: digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" if base > len(digits): raise ValueError("Bases greater than 36 not handled in base_repr.") elif base < 2: raise ValueError("Bases less than 2 not handled in base_repr.") num = abs(number) res = [] while num: res.append(digits[num % base]) num //= base if padding: res.append("0" * padding) if number < 0: res.append("-") return "".join(reversed(res or "0")) rand = random.random() rand = int(float(str(rand)[2:])) rand36 = base_repr(rand, 36) return rand36.lower()[:length]
python
wandb/apis/reports/util.py
24
53
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,949
base_repr
def base_repr(number: int, base: int, padding: int = 0) -> str: digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" if base > len(digits): raise ValueError("Bases greater than 36 not handled in base_repr.") elif base < 2: raise ValueError("Bases less than 2 not handled in base_repr.") num = abs(number) res = [] while num: res.append(digits[num % base]) num //= base if padding: res.append("0" * padding) if number < 0: res.append("-") return "".join(reversed(res or "0"))
python
wandb/apis/reports/util.py
32
48
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,950
coalesce
def coalesce(*arg: Any) -> Any: """Return the first non-none value in the list of arguments. Similar to ?? in C#. """ return next((a for a in arg if a is not None), None)
python
wandb/apis/reports/util.py
56
61
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,951
nested_get
def nested_get(json: dict, keys: str) -> Any: """Get the element at the terminal node of a nested JSON dict based on `path`. The first item of the path can be an object. """ keys = keys.split(".") if len(keys) == 1: return vars(json)[keys[0]] else: rv = json for key in keys: if isinstance(rv, Base): if not hasattr(rv, key): setattr(rv, key, {}) rv = getattr(rv, key) else: if key not in rv: rv[key] = None rv = rv[key] return rv
python
wandb/apis/reports/util.py
64
83
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,952
nested_set
def nested_set(json: dict, keys: str, value: Any) -> None: """Set the element at the terminal node of a nested JSON dict based on `path`. The first item of the path can be an object. If nodes do not exist, they are created along the way. """ keys = keys.split(".") if len(keys) == 1: vars(json)[keys[0]] = value else: for key in keys[:-1]: if isinstance(json, Base): if not hasattr(json, key): setattr(json, key, {}) json = getattr(json, key) else: json = json.setdefault(key, {}) json[keys[-1]] = value
python
wandb/apis/reports/util.py
86
104
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,953
__init__
def __init__( self, fget: Optional[Func] = None, fset: Optional[Func] = None ) -> None: self.fget = fget or self.default_fget self.fset = fset or self.default_fset self.name = ""
python
wandb/apis/reports/util.py
110
115
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,954
__set_name__
def __set_name__(self, owner: Any, name: str) -> None: self.name = name
python
wandb/apis/reports/util.py
117
118
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,955
__get__
def __get__(self, obj: Any, objtype: Optional[Any] = None) -> T: if obj is None: return self if self.fget is None: raise AttributeError(f"unreadable attribute {self.name}") return self.fget(obj)
python
wandb/apis/reports/util.py
120
125
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,956
__set__
def __set__(self, obj: Any, value: Any) -> None: if self.fset is None: raise AttributeError(f"can't set attribute {self.name}") self.fset(obj, value)
python
wandb/apis/reports/util.py
127
130
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,957
getter
def getter(self, fget: Func) -> Func: prop = type(self)(fget, self.fset) prop.name = self.name return prop
python
wandb/apis/reports/util.py
132
135
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,958
setter
def setter(self, fset: Func) -> Func: prop = type(self)(self.fget, fset) prop.name = self.name return prop
python
wandb/apis/reports/util.py
137
140
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,959
default_fget
def default_fget(self, obj: Any) -> Any: return obj.__dict__[self.name]
python
wandb/apis/reports/util.py
142
143
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,960
default_fset
def default_fset(self, obj: Any, value: Any) -> None: obj.__dict__[self.name] = value
python
wandb/apis/reports/util.py
145
146
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,961
__init__
def __init__( self, *args: Func, validators: Optional[List[Validator]] = None, **kwargs: Func ) -> None: super().__init__(*args, **kwargs) if validators is None: validators = [] self.validators = validators
python
wandb/apis/reports/util.py
150
156
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,962
__set__
def __set__(self, instance: Any, value: Any) -> None: if not isinstance(value, type(self)): for validator in self.validators: validator(self, value) super().__set__(instance, value)
python
wandb/apis/reports/util.py
158
162
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,963
__set_name__
def __set_name__(self, owner: Any, name: str) -> None: super().__set_name__(owner, name) self.type = get_type_hints(owner).get(name, UNDEFINED_TYPE) if self.type is not UNDEFINED_TYPE: self.validators = [TypeValidator(attr_type=self.type)] + self.validators
python
wandb/apis/reports/util.py
166
171
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,964
__init__
def __init__( self, *args: Func, json_path: Optional[Union[str, List[str]]] = None, **kwargs: Func, ) -> None: super().__init__(*args, **kwargs) self.path_or_name = json_path
python
wandb/apis/reports/util.py
177
184
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,965
__set_name__
def __set_name__(self, owner: Any, name: str) -> None: if self.path_or_name is None: self.path_or_name = name super().__set_name__(owner, name)
python
wandb/apis/reports/util.py
186
189
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,966
getter
def getter(self, fget: Func) -> Func: prop = type(self)(fget, self.fset, json_path=self.path_or_name) prop.name = self.name return prop
python
wandb/apis/reports/util.py
191
194
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,967
setter
def setter(self, fset: Func) -> Func: prop = type(self)(self.fget, fset, json_path=self.path_or_name) prop.name = self.name return prop
python
wandb/apis/reports/util.py
196
199
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,968
default_fget
def default_fget(self, obj: Any) -> Union[Any, List[Any]]: if isinstance(self.path_or_name, str): return nested_get(obj, self.path_or_name) elif isinstance(self.path_or_name, list): return [nested_get(obj, p) for p in self.path_or_name] else: raise TypeError(f"Unexpected type for path {type(self.path_or_name)!r}")
python
wandb/apis/reports/util.py
201
207
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,969
default_fset
def default_fset(self, obj: Any, value: Any) -> None: if isinstance(self.path_or_name, str): nested_set(obj, self.path_or_name, value) elif isinstance(self.path_or_name, list): for p, v in zip(self.path_or_name, value): nested_set(obj, p, v) else: raise TypeError(f"Unexpected type for path {type(self.path_or_name)!r}")
python
wandb/apis/reports/util.py
209
216
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,970
getter
def getter(self, fget: Func) -> Func: prop = type(self)( fget, self.fset, json_path=self.path_or_name, validators=self.validators ) prop.name = self.name return prop
python
wandb/apis/reports/util.py
220
225
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,971
setter
def setter(self, fset: Func) -> Func: prop = type(self)( self.fget, fset, json_path=self.path_or_name, validators=self.validators ) prop.name = self.name return prop
python
wandb/apis/reports/util.py
227
232
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,972
__new__
def __new__(cls, *args: Any, **kwargs: Any) -> T: if SubclassOnlyABC in cls.__bases__: raise TypeError(f"Abstract class {cls.__name__} cannot be instantiated") return super().__new__(cls)
python
wandb/apis/reports/util.py
236
240
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,973
__repr__
def __repr__(self) -> str: clas = self.__class__.__name__ props = { k: getattr(self, k) for k, v in self.__class__.__dict__.items() if isinstance(v, Attr) } settings = [ f"{k}={v!r}" for k, v in props.items() if not self._is_interesting(v) ] return "{}({})".format(clas, ", ".join(settings))
python
wandb/apis/reports/util.py
244
254
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,974
_is_interesting
def _is_interesting(x: Any) -> bool: if isinstance(x, (list, tuple)): return all(v is None for v in x) return x is None or x == {}
python
wandb/apis/reports/util.py
257
260
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,975
__init__
def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self._spec = {}
python
wandb/apis/reports/util.py
264
266
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,976
spec
def spec(self) -> Dict[str, Any]: return self._spec
python
wandb/apis/reports/util.py
269
270
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,977
from_json
def from_json(cls, spec: Dict[str, Any]) -> T: obj = cls() obj._spec = spec return obj
python
wandb/apis/reports/util.py
273
276
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,978
_get_path
def _get_path(self, var: str) -> str: return vars(type(self))[var].path_or_name
python
wandb/apis/reports/util.py
278
279
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,979
__init__
def __init__( self, layout: Optional[Dict[str, int]] = None, *args: Any, **kwargs: Any ) -> None: super().__init__(*args, **kwargs) self._spec["viewType"] = self.view_type self._spec["__id__"] = generate_name() self.layout = coalesce(layout, self._default_panel_layout()) self.panel_metrics_helper = PanelMetricsHelper()
python
wandb/apis/reports/util.py
285
292
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,980
view_type
def view_type(self) -> str: return "UNKNOWN PANEL"
python
wandb/apis/reports/util.py
295
296
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,981
config
def config(self) -> Dict[str, Any]: return self._spec["config"]
python
wandb/apis/reports/util.py
299
300
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,982
_default_panel_layout
def _default_panel_layout() -> Dict[str, int]: return {"x": 0, "y": 0, "w": 8, "h": 6}
python
wandb/apis/reports/util.py
303
304
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,983
layout
def layout(self, d: Dict[str, int]) -> None: d["x"] = coalesce(d.get("x"), self._default_panel_layout()["x"]) d["y"] = coalesce(d.get("y"), self._default_panel_layout()["y"]) d["w"] = coalesce(d.get("w"), self._default_panel_layout()["w"]) d["h"] = coalesce(d.get("h"), self._default_panel_layout()["h"]) # json_path = self._get_path("layout") # can't use _get_path because it's not on the obj... if only we had dataclass... json_path = "spec.layout" nested_set(self, json_path, d)
python
wandb/apis/reports/util.py
307
316
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,984
fix_collisions
def fix_collisions(panels: List[Panel]) -> List[Panel]: x_max = 24 for i, p1 in enumerate(panels): for p2 in panels[i:]: if collides(p1, p2): # try to move right x, y = shift(p1, p2) if p2.layout["x"] + p2.layout["w"] + x <= x_max: p2.layout["x"] += x # if you hit right right bound, move down else: p2.layout["y"] += y # then check if you can move left again to cleanup layout p2.layout["x"] = 0 return panels
python
wandb/apis/reports/util.py
323
340
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,985
collides
def collides(p1: Panel, p2: Panel) -> bool: l1, l2 = p1.layout, p2.layout if ( (p1.spec["__id__"] == p2.spec["__id__"]) or (l1["x"] + l1["w"] <= l2["x"]) or (l1["x"] >= l2["w"] + l2["x"]) or (l1["y"] + l1["h"] <= l2["y"]) or (l1["y"] >= l2["y"] + l2["h"]) ): return False return True
python
wandb/apis/reports/util.py
343
355
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,986
shift
def shift(p1: Panel, p2: Panel) -> Tuple[Panel, Panel]: l1, l2 = p1.layout, p2.layout x = l1["x"] + l1["w"] - l2["x"] y = l1["y"] + l1["h"] - l2["y"] return x, y
python
wandb/apis/reports/util.py
358
364
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,987
__init__
def __init__(self, latex="", *args, **kwargs): super().__init__(*args, **kwargs) self.latex = latex
python
wandb/apis/reports/util.py
370
372
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,988
spec
def spec(self) -> dict: return {"type": "latex", "children": [{"text": ""}], "content": self.latex}
python
wandb/apis/reports/util.py
375
376
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,989
__init__
def __init__(self, code="", *args, **kwargs): super().__init__(*args, **kwargs) self.code = code
python
wandb/apis/reports/util.py
382
384
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,990
spec
def spec(self) -> dict: return {"text": self.code, "inlineCode": True}
python
wandb/apis/reports/util.py
387
388
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,991
__init__
def __init__(self, text, url, *args, **kwargs): super().__init__(*args, **kwargs) self.text = text self.url = url
python
wandb/apis/reports/util.py
395
398
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,992
spec
def spec(self) -> dict: return {"type": "link", "url": self.url, "children": [{"text": self.text}]}
python
wandb/apis/reports/util.py
401
402
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,993
weave_inputs
def weave_inputs(spec): return spec["config"]["panelConfig"]["exp"]["fromOp"]["inputs"]
python
wandb/apis/reports/util.py
405
406
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,994
__init__
def __init__(self, how=None): self.how = how
python
wandb/apis/reports/validators.py
21
22
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,995
call
def call(self, attr_name, value): pass
python
wandb/apis/reports/validators.py
25
26
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,996
__call__
def __call__(self, attr, value): attr_name = attr.name if value is None and self.how in {"keys", "values"}: return if self.how == "keys": attr_name += " keys" for v in value: self.call(attr_name, v) elif self.how == "values": attr_name += " values" for v in value.values(): self.call(attr_name, v) elif self.how is None: attr_name += " object" self.call(attr_name, value) else: raise ValueError( 'Validator setting `how` must be one of ("keys", "values", None)' )
python
wandb/apis/reports/validators.py
28
46
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,997
__init__
def __init__(self, attr_type, *args, **kwargs): super().__init__(*args, **kwargs) self.attr_type = attr_type try: origin = attr_type.__origin__ subtypes = attr_type.__args__ except AttributeError: # normal types self.attr_type = (attr_type,) else: if origin is Union: self.attr_type = subtypes else: raise TypeError(f"{attr_type} is not currently supported.")
python
wandb/apis/reports/validators.py
50
62
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,998
call
def call(self, attr_name, value): if not isinstance(value, self.attr_type): raise TypeError( f"{attr_name} must be of type {self.attr_type!r} (got {type(value)!r})" )
python
wandb/apis/reports/validators.py
64
68
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
1,999
__init__
def __init__(self, options, *args, **kwargs): super().__init__(*args, **kwargs) self.options = options
python
wandb/apis/reports/validators.py
72
74
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }
2,000
call
def call(self, attr_name, value): if value not in self.options: raise ValueError( f"{attr_name} must be one of {self.options!r} (got {value!r})" )
python
wandb/apis/reports/validators.py
76
80
{ "name": "Git-abouvier/wandb", "url": "https://github.com/Git-abouvier/wandb.git", "license": "MIT", "stars": 0, "forks": 0 }