Skip to content

Commit

Permalink
Remove python 3.6 support (#78)
Browse files Browse the repository at this point in the history
* Remove python 3.6 support

* Remove easydict and pin requirements

* Fix typo

* Set python minor version on travis

* Also remove local db in delete script
  • Loading branch information
JarnoRFB committed Jul 17, 2022
1 parent 66365b7 commit c9f81ed
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 93 deletions.
29 changes: 13 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: 'v4.3.16'
hooks:
- id: isort
additional_dependencies: ['future-fstrings==1.0.0', 'isort[pyproject]']
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.6
additional_dependencies: ['future-fstrings==1.0.0']
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.730'
hooks:
- id: mypy
additional_dependencies: ['future-fstrings==1.0.0']
- repo: https://github.com/pre-commit/mirrors-isort
rev: "v5.10.1"
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.7
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v0.960"
hooks:
- id: mypy
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
sudo: required
language: python
python:
# - "3.5"
- "3.6"
- "3.7"
- "3.7.13"
- "3.8"
os: linux
os: linux
dist: xenial
cache: pip
services:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"restructuredtext.confPath": "${workspaceFolder}/.tox/py36/lib/python3.6/site-packages/importlib_resources/docs"
"restructuredtext.confPath": "${workspaceFolder}/.tox/py36/lib/python3.7/site-packages/importlib_resources/docs",
"esbonio.sphinx.confDir": "${workspaceFolder}/.tox/py36/lib/python3.7/site-packages/importlib_resources/docs"
}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ RUN groupadd --gid $USER_GID $USERNAME \
# Install git, process tools, lsb-release (common in install instructions for CLIs)
RUN apt -y install git procps lsb-release ffmpeg vim exuberant-ctags zsh wget

# Install any missing dependencies for enhanced language service
RUN apt install -y libicu[0-9][0-9]
# # Install any missing dependencies for enhanced language service
# RUN apt install -y libicu[0-9][0-9]

# Clean up
RUN apt-get autoremove -y \
Expand All @@ -46,7 +46,7 @@ RUN mkdir -p ${HOME}/.ssh \
WORKDIR ${HOME}/workspace

# Install Python dependencies from requirements.txt if it exists
RUN conda create -n env python=3.6
RUN conda create -n env python=3.7
RUN echo "source activate env" > ~/.bashrc
ENV PATH /opt/conda/envs/env/bin:$PATH
RUN conda install virtualenv
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Alternatively, you can use conda to set up your local development environment.

::

$ conda create -n incense-dev python=3.6
$ conda create -n incense-dev python=3.7
$ conda activate incense-dev
# virtualenv is required for the precommit environments.
$ conda install virtualenv
Expand Down
6 changes: 3 additions & 3 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- anaconda
dependencies:
- python=3.6
- python=3.7
- numpy
- matplotlib
- pandas
Expand All @@ -12,5 +12,5 @@ dependencies:
- mongodb
- seaborn
- pip:
- git+https://github.com/IDSIA/sacred.git
- incense
- git+https://github.com/IDSIA/sacred.git
- incense
8 changes: 6 additions & 2 deletions delete_db.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import os
import shutil
from pathlib import Path

from dotenv import load_dotenv
from pymongo import MongoClient
from pymongo.mongo_client import MongoClient

env_path = Path(".") / "infrastructure" / "sacred_setup" / ".env"
load_dotenv(dotenv_path=env_path)

DB_NAME = os.environ["MONGO_DATABASE"]

client = MongoClient(host="mongo")
client: MongoClient = MongoClient(host="mongo")
client.drop_database(DB_NAME)

shutil.rmtree(Path("~/data/incense_test/").expanduser(), ignore_errors=True)

print(f"Database {DB_NAME} successfully deleted.")
15 changes: 9 additions & 6 deletions demo.ipynb

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion incense/artifact.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
import os
import pickle
import warnings
Expand Down
4 changes: 2 additions & 2 deletions incense/experiment.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: future_fstrings -*-
import json
from pathlib import Path
from typing import *

import jsonpickle
import pandas as pd
from incense.artifact import Artifact, content_type_to_artifact_cls
from pyrsistent import freeze, thaw

from incense.artifact import Artifact, content_type_to_artifact_cls


class Experiment:
def __init__(self, id_, database, grid_filesystem, data, artifact_links, loader):
Expand Down
13 changes: 7 additions & 6 deletions incense/experiment_loader.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: future_fstrings -*-
import importlib
import numbers
from functools import _lru_cache_wrapper, lru_cache
from functools import lru_cache
from pathlib import Path
from typing import *

import gridfs
import pymongo
from pymongo import MongoClient
from pymongo import DESCENDING
from pymongo.mongo_client import MongoClient

from .experiment import Experiment, FileSystemExperiment
from .query_set import QuerySet
Expand All @@ -19,7 +18,7 @@ class ExperimentLoader:
"""Loads artifacts related to experiments."""

def __init__(self, mongo_uri=None, db_name="sacred", unpickle: bool = True):
client = MongoClient(mongo_uri)
client: MongoClient = MongoClient(mongo_uri)
self._database = client[db_name]
self._runs = self._database.runs
self._grid_filesystem = gridfs.GridFS(self._database)
Expand Down Expand Up @@ -140,7 +139,7 @@ def find_latest(self, n: int = 1, attr: str = "start_time") -> Union[Experiment,
Returns:
Either the latest experiment or the set of latest experiments in case more than one were requested.
"""
cursor = self._runs.find().sort(attr, pymongo.DESCENDING).limit(n)
cursor = self._runs.find().sort(attr, DESCENDING).limit(n)
experiments = [self._make_experiment(experiment) for experiment in cursor]
if len(experiments) == 1:
return experiments[0]
Expand Down Expand Up @@ -189,6 +188,8 @@ def _search_collection(self, key, value):
cursor = self._runs.find({key: {"$regex": rf"{value}"}})
elif isinstance(value, numbers.Real):
cursor = self._runs.find({key: value})
else:
raise ValueError(f"Search value should be either string or number, but was {value}")
return cursor


Expand Down
5 changes: 2 additions & 3 deletions incense/query_set.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
from collections import OrderedDict, UserList, defaultdict
from concurrent.futures import ThreadPoolExecutor
from copy import copy
Expand Down Expand Up @@ -31,8 +30,8 @@ def project(
values in the experiment model can be used inplace of a path. This is useful for summarizing metrics.
rename: The renaming strategy used to create the column names. Either "last" to take the last element in each
path as a column name or None to use the complete paths as column names.
on_missing: {"raise", "ignore"} Whether to raise an error when missing value is encountered or replace it with
a missing value.
on_missing: {"raise", "ignore"} Whether to raise an error when missing value is encountered or replace it with
a missing value.
Returns
-------
Expand Down
1 change: 0 additions & 1 deletion incense/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
from functools import reduce
from operator import and_, or_
from typing import *
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.6
python_version = 3.7
ignore_missing_imports = True

[mypy-versioneer.py]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line-length = 120
target-version = ['py36']
target-version = ['py37']
include = '\.pyi?$'
exclude = '''
(
Expand Down
28 changes: 13 additions & 15 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
-r requirements.txt
pytest
pytest-cov
codecov
tensorflow==2.5.3
python-dotenv
scikit-learn
jupyterlab
seaborn
pre-commit
tokenize-rt==2.2.0
pylint
black
doc8
rope
mypy==0.780
pytest==7.1.2
pytest-cov==3.0.0
codecov==2.1.12
tensorflow==2.9.1
python-dotenv==0.20.0
scikit-learn==1.0.2
jupyterlab==3.4.2
seaborn==0.11.2
pre-commit==2.19.0
black==22.3.0
doc8==0.11.2
rope==1.1.1
mypy==0.960
11 changes: 5 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sacred>=0.8
pandas>=0.23
pymongo>=3.7
easydict>=1.9
ipython>=7.2
future-fstrings==1.0.0
sacred==0.8.2
pandas==1.3.5
pymongo==4.1.1
ipython==7.33.0
pyrsistent==0.18.1
attrs==19.3.0
4 changes: 0 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@
"jupyterlab>=1.0",
"pymongo>=3.7",
"pyrsistent>=0.15.2",
"future-fstrings==1.0.0",
"tokenize-rt==2.2.0",
],
include_package_data=True,
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
Expand Down
1 change: 0 additions & 1 deletion tests/example_experiment/conduct.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
import os
from pathlib import Path

Expand Down
4 changes: 2 additions & 2 deletions tests/test_artifact.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: future_fstrings -*-
import imghdr
import os
import pickle

import IPython
import pandas as pd
import pytest
from incense import artifact
from IPython.display import HTML
from pytest import raises

from incense import artifact


def test_repr(loader):
exp = loader.find_by_id(3)
Expand Down
1 change: 0 additions & 1 deletion tests/test_experiment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
import collections.abc
from datetime import datetime
from fractions import Fraction
Expand Down
6 changes: 3 additions & 3 deletions tests/test_experiment_loader.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: future_fstrings -*-
from pathlib import Path

import pytest
from incense.experiment import Experiment, FileSystemExperiment
from incense.experiment_loader import FileSystemExperimentLoader
from pytest import raises
from sacred import Experiment as SacredExperiment

from incense.experiment import Experiment, FileSystemExperiment
from incense.experiment_loader import FileSystemExperimentLoader


def test_find_by_id(loader):
exp = loader.find_by_id(1)
Expand Down
1 change: 0 additions & 1 deletion tests/test_projector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
import numpy as np
import pandas as pd
from pandas.testing import assert_frame_equal
Expand Down
1 change: 0 additions & 1 deletion tests/test_set_save.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: future_fstrings -*-
import os


Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[tox]
envlist = py35, py36, py37, py38, mypy
envlist = py37, py38, mypy

[travis]
python =
3.6: py36
3.7: py37
3.8: py38, mypy

Expand All @@ -20,4 +19,4 @@ basepython = python3.8
commands =
mypy --package incense
deps =
mypy==0.780
mypy==0.960
6 changes: 1 addition & 5 deletions versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,14 @@

from __future__ import print_function

import configparser
import errno
import json
import os
import re
import subprocess
import sys

try:
import configparser
except ImportError:
import ConfigParser as configparser


class VersioneerConfig:
"""Container for Versioneer configuration parameters."""
Expand Down

0 comments on commit c9f81ed

Please sign in to comment.