Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError while running a notebook through ipython #893

Closed
SiddhantSadangi opened this issue Dec 20, 2022 · 1 comment · Fixed by #899
Closed

AssertionError while running a notebook through ipython #893

SiddhantSadangi opened this issue Dec 20, 2022 · 1 comment · Fixed by #899

Comments

@SiddhantSadangi
Copy link

SiddhantSadangi commented Dec 20, 2022

Setting interactive=True doesn't work when the notebook is run as a script through ipython.

$ ipython notebook.ipynb

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 ex = Experiment("image_classification", interactive=True)
      2 ex.observers.append(NeptuneObserver(run=neptune_run))

File ~\miniconda3\envs\py38\lib\site-packages\sacred\experiment.py:119, in Experiment.__init__(self, name, ingredients, interactive, base_dir, additional_host_info, additional_cli_options, save_git_info)
    117     elif name.endswith(".pyc"):
    118         name = name[:-4]
--> 119 super().__init__(
    120     path=name,
    121     ingredients=ingredients,
    122     interactive=interactive,
    123     base_dir=base_dir,
    124     _caller_globals=caller_globals,
    125     save_git_info=save_git_info,
    126 )
    127 self.default_command = None
    128 self.command(print_config, unobserved=True)

File ~\miniconda3\envs\py38\lib\site-packages\sacred\ingredient.py:75, in Ingredient.__init__(self, path, ingredients, interactive, _caller_globals, base_dir, save_git_info)
     69 self.save_git_info = save_git_info
     70 self.doc = _caller_globals.get("__doc__", "")
     71 (
     72     self.mainfile,
     73     self.sources,
     74     self.dependencies,
---> 75 ) = gather_sources_and_dependencies(
     76     _caller_globals, save_git_info, self.base_dir
     77 )
     78 if self.mainfile is None and not interactive:
     79     raise RuntimeError(
     80         "Defining an experiment in interactive mode! "
     81         "The sourcecode cannot be stored and the "
     82         "experiment won't be reproducible. If you still"
     83         " want to run it pass interactive=True"
     84     )

File ~\miniconda3\envs\py38\lib\site-packages\sacred\dependencies.py:725, in gather_sources_and_dependencies(globs, save_git_info, base_dir)
    723 def gather_sources_and_dependencies(globs, save_git_info, base_dir=None):
    724     """Scan the given globals for modules and return them as dependencies."""
--> 725     experiment_path, main = get_main_file(globs, save_git_info)
    727     base_dir = base_dir or experiment_path
    729     gather_sources = source_discovery_strategies[SETTINGS["DISCOVER_SOURCES"]]

File ~\miniconda3\envs\py38\lib\site-packages\sacred\dependencies.py:596, in get_main_file(globs, save_git_info)
    594     main = None
    595 else:
--> 596     main = Source.create(globs.get("__file__"), save_git_info)
    461 return Source(main_file, get_digest(main_file), repo, commit, is_dirty)

File ~\miniconda3\envs\py38\lib\site-packages\sacred\dependencies.py:382, in get_py_file_if_possible(pyc_name)
    380 if pyc_name.endswith((".py", ".so", ".pyd")):
    381     return pyc_name
--> 382 assert pyc_name.endswith(".pyc")
    383 non_compiled_file = pyc_name[:-1]
    384 if os.path.exists(non_compiled_file):

Environment details:

  • Windows11
  • python3.8.15
  • sacred==0.8.2
@thequilo
Copy link
Collaborator

Hmm, interesting, thanks for reporting! I'll have a look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants