turn off sqlalchemy warnings in nosetests

  • Last Update :
  • Techknowledgy :

It seems that nose overwrites whatever you set with:

warnings.filterwarnings("ignore")

However you can filter warnings during nose test with a command line option to nose. e.g.:

$ nosetests--logging - filter = SAWarning

I found that this still may not work under all circumstances. If this is the case you can try:

$ python - W ignore `which nosetests`

Suggestion : 2

Put the same arguments as warnings.filterwarnings in setup.cfg at the root of your project. Separated each argument by pipes |, one filter per line. Whitespace are stripped.,Each line of warning filter is separated in maximum 4 sections, that match the first 4 sections of filterwarnings:,If you prefer another name for the configuration file, you can tell nose to load the configuration using the -c flag: run the tests with nosetests -c nose.cfg.,the value of each fields is treated the same as for filterwarnigns except: - whitespace are trimmed. - if the category has dots, the corresponding class try to be imported. If it does not have dots, the name is looked up in builtins or __builtins__

for example:

[nosetests]
warningfilters =
   default | .* | DeprecationWarning | notebook.*
   ignore | .*metadata.* | DeprecationWarning | notebook.*
   once | .*schema.* | UserWarning | nbfor.*
   error | .*warn.* | DeprecationWarning | notebook.services.contents.manager *

Each line of warning filter is separated in maximum 4 sections, that match the first 4 sections of filterwarnings:

filterwarnings(action, message = "", category = Warning, module = "", lineno = 0, append = False)

fields 2 to 4 can be omitted, ie to say 1 line can be of the following form:

action
action | message
action | message | category
action | message | category | module

Each line of warning filter is separated in maximum 4 sections, that match the first 4 sections of filterwarnings:

filterwarnings(action, message = "", category = Warning, module = "", lineno = 0, append = False)

fields 2 to 4 can be omitted, ie to say 1 line can be of the following form:

action
action | message
action | message | category
action | message | category | module

Suggestion : 3

Stop crashing when empty logs are received from kubernetes client (#22566),Add compat shim for SQLAlchemy to avoid warnings (#21959),The scheduler.min_file_parsing_loop_time config option has been temporarily removed due to some bugs.,According to AIP-21 _operator suffix has been removed from operators. A deprecation warning has also been raised for paths importing with the suffix.

@dag.task(params = {
   "a": {
      1,
      2,
      3
   },
   "b": pendulum.now()
})
def datetime_param(value):
   print(value)

datetime_param("{{ params.a }} | {{ params.b }}")
> raise exc.NoSuchModuleError(
   "Can't load plugin: %s:%s" % (self.group, name)
)
E sqlalchemy.exc.NoSuchModuleError: Can 't load plugin: sqlalchemy.dialects:postgres
INSERT INTO log_template(id, filename, elasticsearch_id, created_at) VALUES(0, '{{ ti.dag_id }}/{{ ti.task_id }}/{{ ts }}/{{ try_number }}.log', '{dag_id}-{task_id}-{execution_date}-{try_number}', NOW());
airflow connections
export -2 > & 1 > /dev/null | grep 'non-JSON'
Param(None, type = ["null", "string"])
Param().resolve() # raises TypeError

Suggestion : 4

PickleType and ARRAY mutability turned off by default,If merging data into a versioned state, the version id attribute can be left undefined, and no version check will take place.,The Index() construct can be created inline with a Table definition, using strings as column names, as an alternative to the creation of the index outside of the Table. That is:,The mutable=True flag is being phased out, in favor of the new Mutation Tracking extension. This extension provides a mechanism by which user-defined datatypes can provide change events back to the owning parent or parents.

query.join(SomeClass, SomeClass.id == ParentClass.some_id)
query.join(MyClass.somerelation)
query.join("somerelation")
query.join(MyTarget)
#...etc
Table('mytable', metadata,
   Column('id', Integer, primary_key = True),
   Column('name', String(50), nullable = False),
   Index('idx_name', 'name')
)
class HasNameMixin(object):
   name = Column('name', String(50), nullable = False)
@declared_attr
def __table_args__(cls):
   return (Index('name'), {})

class User(HasNameMixin, Base):
   __tablename__ = 'user'
id = Column('id', Integer, primary_key = True)
from sqlalchemy.sql
import table, column, select, func

empsalary = table('empsalary',
   column('depname'),
   column('empno'),
   column('salary'))

s = select([
   empsalary,
   func.avg(empsalary.c.salary).
   over(partition_by = empsalary.c.depname).
   label('avg')
])

print(s)
SELECT empsalary.depname, empsalary.empno, empsalary.salary,
   avg(empsalary.salary) OVER(PARTITION BY empsalary.depname) AS avg
FROM empsalary