Skip to content

Commit

Permalink
use importlib to get json absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Nov 4, 2024
1 parent cdf45a9 commit 5d2ec68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion hvcc/core/hv2ir/types/IR.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class HeavyIRType(RootModel):

if __name__ == "__main__":
import json
with open('../../json/heavy.ir.json') as f:
import importlib_resources

heavy_ir_json = importlib_resources.files('hvcc') / 'core/json/heavy.ir.json'
with open(heavy_ir_json, "r") as f:
data = json.load(f)
heavy_ir = HeavyIRType(root=data)
print(heavy_ir.root.keys())
5 changes: 4 additions & 1 deletion hvcc/core/hv2ir/types/Lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class HeavyLangType(RootModel):

if __name__ == "__main__":
import json
with open('../../json/heavy.lang.json') as f:
import importlib_resources

heavy_lang_json = importlib_resources.files('hvcc') / 'core/json/heavy.lang.json'
with open(heavy_lang_json, "r") as f:
data = json.load(f)
heavy_lang = HeavyLangType(root=data)
print(heavy_lang.root.keys())

0 comments on commit 5d2ec68

Please sign in to comment.