cistrome / MIRA

Python package for analysis of multiomic single cell RNA-seq and ATAC-seq.
52 stars 7 forks source link

Question about BayesianTuner #30

Closed MoLuLuMo closed 10 months ago

MoLuLuMo commented 10 months ago
atac_tuner = mira.topics.BayesianTuner(
    model = atac_model,
    min_topics = NUM_TOPICS - 5,
    max_topics = NUM_TOPICS + 5,
    save_name = './atac_tuner',
    n_jobs=5
    # n_jobs = 5, # highly suggested - if you have the GPU memory!
    # storage = mira.topics.Redis(), # if you are running a redis server backend
)

AssertionError Traceback (most recent call last) Cell In[40], line 1 ----> 1 atac_tuner = mira.topics.BayesianTuner( 2 model = atac_model, 3 min_topics = NUM_TOPICS - 5, 4 max_topics = NUM_TOPICS + 5, 5 save_name = './atac_tuner', 6 n_jobs=5 7 # n_jobs = 5, # highly suggested - if you have the GPU memory! 8 # storage = mira.topics.Redis(), # if you are running a redis server backend 9 )

File ~/.conda/envs/mira/lib/python3.9/site-packages/mira/topic_model/hyperparameter_optim/trainer.py:493, in BayesianTuner.init(self, model, save_name, min_topics, max_topics, storage, n_jobs, max_trials, min_trials, stop_condition, seed, tensorboard_logdir, model_dir, pruner, sampler, log_steps, log_every, train_size) 491 self.model_dir = model_dir 492 self.train_size = train_size --> 493 self.study = self.create_study()

File ~/.conda/envs/mira/lib/python3.9/site-packages/mira/topic_model/hyperparameter_optim/trainer.py:500, in BayesianTuner.create_study(self) 498 def create_study(self): --> 500 return optuna.create_study( 501 directions = self.objective, 502 pruner = self.get_pruner(), 503 study_name = self.study_name, 504 storage = self.storage, 505 load_if_exists= True, 506 )

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/study/study.py:1136, in create_study(storage, sampler, pruner, study_name, direction, load_if_exists, directions) 1127 raise ValueError( 1128 "Please set either 'minimize' or 'maximize' to direction. You can also set the " 1129 "corresponding StudyDirection member." 1130 ) 1132 direction_objects = [ 1133 d if isinstance(d, StudyDirection) else StudyDirection[d.upper()] for d in directions 1134 ] -> 1136 storage = storages.get_storage(storage) 1137 try: 1138 study_id = storage.create_new_study(study_name)

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/storages/init.py:31, in get_storage(storage) 29 return RedisStorage(storage) 30 else: ---> 31 return _CachedStorage(RDBStorage(storage)) 32 elif isinstance(storage, RDBStorage): 33 return _CachedStorage(storage)

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/storages/_rdb/storage.py:187, in RDBStorage.init(self, url, engine_kwargs, skip_compatibility_check, heartbeat_interval, grace_period, failed_trial_callback) 185 self._version_manager = _VersionManager(self.url, self.engine, self.scoped_session) 186 if not skip_compatibility_check: --> 187 self._version_manager.check_table_schema_compatibility()

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/storages/_rdb/storage.py:1310, in _VersionManager.check_table_schema_compatibility(self) 1306 version_info = models.VersionInfoModel.find(session) 1308 assert version_info is not None -> 1310 current_version = self.get_current_version() 1311 head_version = self.get_head_version() 1312 if current_version == head_version:

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/storages/_rdb/storage.py:1337, in _VersionManager.get_current_version(self) 1335 context = alembic.migration.MigrationContext.configure(self.engine.connect()) 1336 version = context.get_current_revision() -> 1337 assert version is not None 1339 return version

AssertionError:

AllenWLynch commented 10 months ago

Can you provide the version of Optuna and your operating system?

On Aug 30, 2023, at 1:40 PM, Minxue Jia @.***> wrote:



atac_tuner = mira.topics.BayesianTuner( model = atac_model, min_topics = NUM_TOPICS - 5, max_topics = NUM_TOPICS + 5, save_name = './atac_tuner', n_jobs=5

n_jobs = 5, # highly suggested - if you have the GPU memory!

# storage = mira.topics.Redis(), # if you are running a redis server backend

)


AssertionError Traceback (most recent call last) Cell In[40], line 1 ----> 1 atac_tuner = mira.topics.BayesianTuner( 2 model = atac_model, 3 min_topics = NUM_TOPICS - 5, 4 max_topics = NUM_TOPICS + 5, 5 save_name = './atac_tuner', 6 n_jobs=5 7 # n_jobs = 5, # highly suggested - if you have the GPU memory! 8 # storage = mira.topics.Redis(), # if you are running a redis server backend 9 )

File ~/.conda/envs/mira/lib/python3.9/site-packages/mira/topic_model/hyperparameter_optim/trainer.py:493, in BayesianTuner.init(self, model, save_name, min_topics, max_topics, storage, n_jobs, max_trials, min_trials, stop_condition, seed, tensorboard_logdir, model_dir, pruner, sampler, log_steps, log_every, train_size) 491 self.model_dir = model_dir 492 self.train_size = train_size --> 493 self.study = self.create_study()

File ~/.conda/envs/mira/lib/python3.9/site-packages/mira/topic_model/hyperparameter_optim/trainer.py:500, in BayesianTuner.create_study(self) 498 def create_study(self): --> 500 return optuna.create_study( 501 directions = self.objective, 502 pruner = self.get_pruner(), 503 study_name = self.study_name, 504 storage = self.storage, 505 load_if_exists= True, 506 )

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/study/study.py:1136, in create_study(storage, sampler, pruner, study_name, direction, load_if_exists, directions) 1127 raise ValueError( 1128 "Please set either 'minimize' or 'maximize' to direction. You can also set the " 1129 "corresponding StudyDirection member." 1130 ) 1132 direction_objects = [ 1133 d if isinstance(d, StudyDirection) else StudyDirection[d.upper()] for d in directions 1134 ] -> 1136 storage = storages.get_storage(storage) 1137 try: 1138 study_id = storage.create_new_study(study_name)

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/storages/init.py:31, in get_storage(storage) 29 return RedisStorage(storage) 30 else: ---> 31 return _CachedStorage(RDBStorage(storage)) 32 elif isinstance(storage, RDBStorage): 33 return _CachedStorage(storage)

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/storages/_rdb/storage.py:187, in RDBStorage.init(self, url, engine_kwargs, skip_compatibility_check, heartbeat_interval, grace_period, failed_trial_callback) 185 self._version_manager = _VersionManager(self.url, self.engine, self.scoped_session) 186 if not skip_compatibility_check: --> 187 self._version_manager.check_table_schema_compatibility()

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/storages/_rdb/storage.py:1310, in _VersionManager.check_table_schema_compatibility(self) 1306 version_info = models.VersionInfoModel.find(session) 1308 assert version_info is not None -> 1310 current_version = self.get_current_version() 1311 head_version = self.get_head_version() 1312 if current_version == head_version:

File ~/.conda/envs/mira/lib/python3.9/site-packages/optuna/storages/_rdb/storage.py:1337, in _VersionManager.get_current_version(self) 1335 context = alembic.migration.MigrationContext.configure(self.engine.connect()) 1336 version = context.get_current_revision() -> 1337 assert version is not None 1339 return version

AssertionError:

— Reply to this email directly, view it on GitHubhttps://github.com/cistrome/MIRA/issues/30, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AE43JPFKU677U65FXCVOOTDXX53KBANCNFSM6AAAAAA4E33MEU. You are receiving this because you are subscribed to this thread.Message ID: @.***>

MoLuLuMo commented 10 months ago

The version of optuna is 2.10.1 . My operating system is linux

AllenWLynch commented 10 months ago

Last thing, your python version? I was able to repeat this failure, and it seems to be a new bug with Optuna

On Aug 30, 2023, at 3:38 PM, Minxue Jia @.***> wrote:



The version of optuna is 2.10.1 . My operating system is linux

— Reply to this email directly, view it on GitHubhttps://github.com/cistrome/MIRA/issues/30#issuecomment-1699730809, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AE43JPEXWBKR54CGYNE42PDXX6JBNANCNFSM6AAAAAA4E33MEU. You are receiving this because you commented.Message ID: @.***>

MoLuLuMo commented 10 months ago

Thanks for fast response. Python version is 3.9.17.

AllenWLynch commented 10 months ago

Figured it out,

Try backdating your sqlalchemy installation to <2, for example:

conda install -c conda-forge -y sqlalchemy<2

This appears to be a bug with optuna version 3 installation. Will include conditions on installation in a coming update. Let me know if this works, AL


From: Minxue Jia @.> Sent: Wednesday, August 30, 2023 5:11 PM To: cistrome/MIRA @.> Cc: AllenWLynch @.>; Comment @.> Subject: Re: [cistrome/MIRA] Question about BayesianTuner (Issue #30)

Thanks for fast response. Python version is 3.9.17.

— Reply to this email directly, view it on GitHubhttps://github.com/cistrome/MIRA/issues/30#issuecomment-1699919984, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AE43JPA7UTQ4RWOCOZFVU2DXX63BZANCNFSM6AAAAAA4E33MEU. You are receiving this because you commented.Message ID: @.***>