CharlieFRuan commented on code in PR #16525:
URL: https://github.com/apache/tvm/pull/16525#discussion_r1493816633


##########
web/src/runtime.ts:
##########
@@ -2432,3 +2444,28 @@ export async function hasNDArrayInCache(
   list = list["records"] as Array<NDArrayShardEntry>;
   return await artifactCache.hasAllKeys(list.map(key => new URL(key.dataPath, 
ndarrayCacheUrl).href));
 }
+
+/**
+ * Given cacheUrl, search up items to delete based on 
cacheUrl/ndarray-cache.json
+ *
+ * @param ndarrayCacheUrl
+ * @param cacheScope
+ */
+export async function deleteNDArrayCache(
+  ndarrayCacheUrl: string,
+  cacheScope = "tvmjs"
+) {
+  const artifactCache = new ArtifactCache(cacheScope);
+  const jsonUrl = new URL("ndarray-cache.json", ndarrayCacheUrl).href;
+  const result = await artifactCache.fetchWithCache(jsonUrl);
+  let list;
+  if (result instanceof Response){
+    list = await result.json();
+  }
+  const arrayentry = list["records"] as Array<NDArrayShardEntry>;
+  const processShard = async (i: number) => {
+    const dataUrl = new URL(arrayentry[i].dataPath, ndarrayCacheUrl).href;
+    await(await artifactCache.deleteInCache(dataUrl));

Review Comment:
   Only one `await` is needed



##########
web/tvm_home:
##########
@@ -0,0 +1 @@
+/ssd1/hangruic/tvm/

Review Comment:
   Please remove this change



##########
web/src/runtime.ts:
##########
@@ -2432,3 +2444,28 @@ export async function hasNDArrayInCache(
   list = list["records"] as Array<NDArrayShardEntry>;
   return await artifactCache.hasAllKeys(list.map(key => new URL(key.dataPath, 
ndarrayCacheUrl).href));
 }
+
+/**
+ * Given cacheUrl, search up items to delete based on 
cacheUrl/ndarray-cache.json
+ *
+ * @param ndarrayCacheUrl
+ * @param cacheScope
+ */
+export async function deleteNDArrayCache(
+  ndarrayCacheUrl: string,

Review Comment:
   We should replace `ndarrayCacheUrl` to `cacheUrl` to match the docstring and 
the semantics.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to