Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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 aim/cli/storage/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def to_3_11(ctx, hashes, yes):
try:
run = Run(run_hash, repo=repo)
if run.check_metrics_version():
backup_run(run)
backup_run(repo, run.hash)
run.update_metrics()
index_manager.index(run_hash)
else:
Expand Down
13 changes: 12 additions & 1 deletion aim/sdk/query_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ class Unknown(ast.AST):
Unknown = Unknown() # create a single instance of <unknown> value node


def unparse(*args, **kwargs):
import sys

if sys.version_info.minor < 9:
import astunparse

return astunparse.unparse(*args, **kwargs)
else:
return ast.unparse(*args, **kwargs)


class QueryExpressionTransformer(ast.NodeTransformer):
def __init__(self, *, var_names: List[str]):
self._var_names = var_names
Expand All @@ -20,7 +31,7 @@ def transform(self, expr: str) -> Tuple[str, bool]:
if transformed is Unknown:
return expr, False
else:
return ast.unparse(transformed), True
return unparse(transformed), True

def visit_Expression(self, node: ast.Expression) -> Any:
node: ast.Expression = self.generic_visit(node)
Expand Down
2 changes: 1 addition & 1 deletion aim/sdk/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def __init__(
raise RuntimeError
else:
logger.warning(f'Detected sub-optimal format metrics for Run {self.hash}. Upgrading...')
backup_path = backup_run(self)
backup_path = backup_run(self.repo, self.hash)
try:
self.update_metrics()
logger.warning(f'Successfully converted Run {self.hash}')
Expand Down
12 changes: 7 additions & 5 deletions aim/sdk/sequence_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
from abc import abstractmethod
from typing import TYPE_CHECKING, Iterator

from tqdm import tqdm

from aim.sdk.query_analyzer import QueryExpressionTransformer
from aim.sdk.query_utils import RunView, SequenceView
from aim.sdk.sequence import Sequence
from aim.sdk.types import QueryReportMode
from aim.storage.query import RestrictedPythonQuery
from tqdm import tqdm


if TYPE_CHECKING:
from pandas import DataFrame

from aim.sdk.repo import Repo
from aim.sdk.run import Run
from pandas import DataFrame

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -174,7 +172,11 @@ def iter_runs(self) -> Iterator['SequenceCollection']:
progress_bar = tqdm(total=total_runs)

seq_var = self.seq_cls.sequence_name()
t = QueryExpressionTransformer(var_names=[seq_var, ])
t = QueryExpressionTransformer(
var_names=[
seq_var,
]
)
run_expr, is_transformed = t.transform(self.query)
run_query = RestrictedPythonQuery(run_expr)

Expand Down
4 changes: 2 additions & 2 deletions aim/storage/structured/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def __init__(self, path: str, readonly: bool = False):
self.engine = create_engine(
self.db_url, echo=(logging.INFO >= int(os.environ.get(AIM_LOG_LEVEL_KEY, logging.WARNING)))
)
self.session_cls = scoped_session(sessionmaker(autoflush=False, bind=self.engine))
self._upgraded = None

@classmethod
Expand Down Expand Up @@ -91,7 +90,8 @@ def caches(self):
return self._caches

def get_session(self, autocommit=True):
session = self.session_cls()
session_cls = scoped_session(sessionmaker(autoflush=False, bind=self.engine))
session = session_cls()
setattr(session, 'autocommit', autocommit)
return session

Expand Down
8 changes: 4 additions & 4 deletions aim/utils/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def python_version_deprecation_check():
import sys

version_info = sys.version_info
if version_info.major == 3 and version_info.minor == 6:
if version_info.major == 3 and version_info.minor == 7:
deprecation_warning(
remove_version='3.16',
msg='Python 3.6 has reached EOL. Aim support for Python 3.6 is deprecated!',
remove_msg_template='Python 3.6 support will be dropped in',
remove_version='3.17',
msg='Python 3.7 has reached EOL. Aim support for Python 3.7 is deprecated!',
remove_msg_template='Python 3.7 support will be dropped in',
)


Expand Down
7 changes: 4 additions & 3 deletions aim/web/api/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
echo=(logging.INFO >= int(os.environ.get(AIM_LOG_LEVEL_KEY, logging.WARNING))),
connect_args={'check_same_thread': False},
)
SessionLocal = sessionmaker(autoflush=False, bind=engine)
Base = declarative_base()


def get_session():
session = SessionLocal()
session_cls = sessionmaker(autoflush=False, bind=engine)
session = session_cls()
try:
yield session
finally:
Expand All @@ -29,7 +29,8 @@ def get_session():

@contextmanager
def get_contexted_session():
session = SessionLocal()
session_cls = sessionmaker(autoflush=False, bind=engine)
session = session_cls()
try:
yield session
finally:
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def package_files(directory):
'boto3',
]

if sys.version_info.minor < 9:
REQUIRED += ['astunparse']


class UploadCommand(Command):
"""Support setup.py upload."""
Expand Down Expand Up @@ -194,6 +197,7 @@ def cytonize_extensions():
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: PyPy',
],
ext_modules=cytonize_extensions(),
Expand Down
Loading