Skip to content

Commit

Permalink
Some cleanup and fixes of warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AryazE committed Nov 6, 2024
1 parent 989dcfa commit 3c0742b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9
FROM python:3.11-slim

ARG repo

Expand Down
6 changes: 2 additions & 4 deletions src/dynapyt/instrument/CodeInstrumenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ def __create_iid(self, node):
)
return iid

def __create_import(self, names):
def __create_import(self):
module_name = cst.Attribute(
value=cst.Name(value="dynapyt"), attr=cst.Name(value="runtime")
)
# imp_aliases = [cst.ImportAlias(name=cst.Name(value=name)) for name in names]
# imp = cst.ImportFrom(module=module_name, names=imp_aliases)
imp = cst.ImportFrom(
module=module_name,
names=[cst.ImportAlias(name=cst.Name(value="RuntimeEngine"))],
Expand Down Expand Up @@ -266,7 +264,7 @@ def leave_Module(self, original_node: cst.Module, updated_node: cst.Module):
imports_index = i

if len(import_names) > 0:
dynapyt_imports.append(self.__create_import(import_names))
dynapyt_imports.append(self.__create_import())
dynapyt_imports.append(
cst.SimpleStatementLine(
body=[
Expand Down
4 changes: 0 additions & 4 deletions src/dynapyt/instrument/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ def canonical_ifs(node, child_dict):

def instrument_code(src, file_path, iids, selected_hooks):
try:
print("Before:")
print(src)
ast = cst.matchers.replace(
cst.parse_module(src),
cst.matchers.If(
Expand All @@ -53,8 +51,6 @@ def instrument_code(src, file_path, iids, selected_hooks):
),
canonical_ifs,
)
print("After:")
print(ast.code)
ast_wrapper = cst.metadata.MetadataWrapper(ast)

instrumented_code = CodeInstrumenter(src, file_path, iids, selected_hooks)
Expand Down
2 changes: 0 additions & 2 deletions src/dynapyt/run_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from tempfile import gettempdir
import sys
import uuid
import json
from pathlib import Path
from .utils.runtimeUtils import gather_coverage, gather_output
from .runtime import RuntimeEngine


Expand Down
5 changes: 0 additions & 5 deletions src/dynapyt/run_instrumentation.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from typing import List, Set
import argparse
from os import walk
from os import path
from pathlib import Path
import shutil
from subprocess import run
import time
from multiprocessing import Pool
from dynapyt.utils.hooks import get_hooks_from_analysis
from dynapyt.instrument.instrument import instrument_files


Expand All @@ -19,7 +15,6 @@ def instrument_dir(
):
start_time = time.time()
start = directory
all_cmds = []

if isinstance(analysis, str) and Path(analysis).exists():
with open(analysis, "r") as f:
Expand Down
8 changes: 2 additions & 6 deletions src/dynapyt/utils/hooks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from typing import Dict, List

try:
import importlib.resources as pkg_resources
except ImportError:
# Try backported to PY<37 `importlib_resources`.
import importlib_resources as pkg_resources
import importlib.resources as pkg_resources
import json
import builtins
import keyword
Expand Down Expand Up @@ -81,6 +77,6 @@ def get_hooks_from_analysis(classes: List[str]) -> Dict[str, Dict[str, List[str]
raise e
except ImportError as e:
raise e
with pkg_resources.open_text("dynapyt.utils", "hierarchy.json") as f:
with pkg_resources.files("dynapyt.utils").joinpath("hierarchy.json").open("r") as f:
hierarchy = json.load(f)
return get_used_leaves(hierarchy, methods)
6 changes: 1 addition & 5 deletions tutorial/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
FROM ubuntu:latest

RUN apt update
RUN apt install python3 python3-pip -y
RUN apt install python-is-python3 -y
FROM python:3.12-slim

WORKDIR /dynapyt

Expand Down
4 changes: 2 additions & 2 deletions tutorial/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tutorial
This is the tutorial page for ASE 2023.
Slides: [Google slides](https://docs.google.com/presentation/d/14eeGZm4gIznsqtAEYI5o5Ayyp2vRepdKzUTjFTksJaI/edit?usp=sharing)
This is the tutorial page originally designed for ASE 2023. It might not be updated on every release, so please open an issue if something does not work.
Original slides of the ASE 2023 tutorial: [Google slides](https://docs.google.com/presentation/d/14eeGZm4gIznsqtAEYI5o5Ayyp2vRepdKzUTjFTksJaI/edit?usp=sharing)

Table of contents:
- Task 0: [Setup](#setup)
Expand Down

0 comments on commit 3c0742b

Please sign in to comment.