Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sdk): implement hack to make nexus work #121

Merged
merged 7 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.17
current_version = 0.9.18
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="yea-wandb",
version="0.9.17",
version="0.9.18",
description="Test harness wandb plugin",
packages=["yea_wandb"],
install_requires=[
Expand Down
2 changes: 1 addition & 1 deletion src/yea_wandb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .setup import setup

__all__ = ["setup"]
__version__ = "0.9.17"
__version__ = "0.9.18"
2 changes: 1 addition & 1 deletion src/yea_wandb/artifact_emu.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def create_files(self, variables):
"edges": [
{
"node": {
"id": idx,
"id": str(idx),
"name": af["name"],
"displayName": af["name"],
"uploadUrl": f"{base_url}/storage?file={af['name']}&id={af['artifactID']}",
Expand Down
41 changes: 33 additions & 8 deletions src/yea_wandb/mock_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,34 @@
body = request.get_json()
app.logger.info("graphql post body: %s", body)

# fixup body query to be more compatible with other graphql implementations
# lets start by changing any mutation or query that has a space after the
# graphql request name
if re.match(r"^\s*(mutation|query)\s(\w+)\s\(", body["query"]):
body["query"] = body["query"].replace(" (", "(")

Check warning on line 623 in src/yea_wandb/mock_server.py

View check run for this annotation

Codecov / codecov/patch

src/yea_wandb/mock_server.py#L622-L623

Added lines #L622 - L623 were not covered by tests

if body["variables"].get("run"):
ctx["current_run"] = body["variables"]["run"]

if "mutation CreateRunFiles" in body["query"]:
requested_file = body["variables"]["files"][0]
upload_url = base_url + "/storage?file=%s" % requested_file
data = {

Check warning on line 631 in src/yea_wandb/mock_server.py

View check run for this annotation

Codecov / codecov/patch

src/yea_wandb/mock_server.py#L628-L631

Added lines #L628 - L631 were not covered by tests
"data": {
"createRunFiles": {
"runID": "UnVuOnYxOmtoMXFsdmIwOnVuY2F0ZWdvcml6ZWQ6amVmZnI=",
"uploadHeaders": [],
"files": [
{
"name": requested_file,
"uploadUrl": upload_url,
}
],
}
}
}
r = json.dumps(data)
return r

Check warning on line 646 in src/yea_wandb/mock_server.py

View check run for this annotation

Codecov / codecov/patch

src/yea_wandb/mock_server.py#L645-L646

Added lines #L645 - L646 were not covered by tests
if body["variables"].get("files"):
requested_file = body["variables"]["files"][0]
ctx["requested_file"] = requested_file
Expand Down Expand Up @@ -845,7 +870,7 @@
"name": "foo",
"uploadUrl": "",
"storagePath": "x/y/z",
"uploadheaders": [],
"uploadHeaders": [],
"artifact": {"id": "1"},
}
if "storagePath" not in body["query"]:
Expand Down Expand Up @@ -1146,7 +1171,7 @@
"displayName": file_spec["name"],
"digest": "null",
"uploadUrl": url,
"uploadHeaders": "",
"uploadHeaders": [],
}
}
)
Expand Down Expand Up @@ -1280,18 +1305,18 @@
}
if "mutation CreateArtifactManifest(" in body["query"]:
manifest = {
"id": 1,
"id": "1",
"type": "INCREMENTAL"
if "incremental" in body.get("variables", {}).get("name", "")
else "FULL",
"file": {
"id": 1,
"id": "1",
"directUrl": base_url
+ "/storage?file=wandb_manifest.json&name={}".format(
body.get("variables", {}).get("name", "")
),
"uploadUrl": base_url + "/storage?file=wandb_manifest.json",
"uploadHeaders": "",
"uploadHeaders": [],
},
}
run_name = body.get("variables", {}).get("runName", "unknown")
Expand All @@ -1318,7 +1343,7 @@
body.get("variables", {}).get("name", "")
),
"uploadUrl": base_url + "/storage?file=wandb_manifest.json",
"uploadHeaders": "",
"uploadHeaders": [],
},
}
return {
Expand Down Expand Up @@ -1357,7 +1382,7 @@
"id": idx,
"name": file["name"],
"uploadUrl": "",
"uploadheaders": [],
"uploadHeaders": [],
"artifact": {"id": file["artifactID"]},
}
for idx, file in enumerate(
Expand All @@ -1371,7 +1396,7 @@
return {
"data": {
"commitArtifact": {
"artifact": {"id": 1, "digest": "0000===================="}
"artifact": {"id": "1", "digest": "0000===================="}
}
}
}
Expand Down