Repository: sernst/cauldron

Issue:
Library Directories without Reload
Right now when not auto-reloading libraries, the library directories do not always get reliably added during notebook initialization.

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=h1) Report
> Merging [#60](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=desc) into [master](https://codecov.io/gh/sernst/cauldron/commit/8b847dfc49a20186db0d3a506eda55370deb92e3?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/sernst/cauldron/pull/60/graphs/tree.svg?width=650&token=VXJ1BzmoVE&height=150&src=pr)](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master      #60   +/-   ##
=======================================
  Coverage   98.33%   98.33%           
=======================================
  Files         226      226           
  Lines        9869     9869           
=======================================
  Hits         9705     9705           
  Misses        164      164
```


| [Impacted Files](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [cauldron/cli/commands/open/\_\_init\_\_.py](https://codecov.io/gh/sernst/cauldron/pull/60/diff?src=pr&el=tree#diff-Y2F1bGRyb24vY2xpL2NvbW1hbmRzL29wZW4vX19pbml0X18ucHk=) | `86.56% <ø> (-0.2%)` | :arrow_down: |
| [cauldron/cli/commands/open/opener.py](https://codecov.io/gh/sernst/cauldron/pull/60/diff?src=pr&el=tree#diff-Y2F1bGRyb24vY2xpL2NvbW1hbmRzL29wZW4vb3BlbmVyLnB5) | `100% <100%> (ø)` | :arrow_up: |
| [.../test/cli/server/routes/synchronize/test\_status.py](https://codecov.io/gh/sernst/cauldron/pull/60/diff?src=pr&el=tree#diff-Y2F1bGRyb24vdGVzdC9jbGkvc2VydmVyL3JvdXRlcy9zeW5jaHJvbml6ZS90ZXN0X3N0YXR1cy5weQ==) | `100% <100%> (ø)` | :arrow_up: |
| [cauldron/session/projects/project.py](https://codecov.io/gh/sernst/cauldron/pull/60/diff?src=pr&el=tree#diff-Y2F1bGRyb24vc2Vzc2lvbi9wcm9qZWN0cy9wcm9qZWN0LnB5) | `96.65% <100%> (+0.01%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=footer). Last update [8b847df...f8262a8](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

codecov[bot]: # [Codecov](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=h1) Report
> Merging [#60](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=desc) into [master](https://codecov.io/gh/sernst/cauldron/commit/8b847dfc49a20186db0d3a506eda55370deb92e3?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/sernst/cauldron/pull/60/graphs/tree.svg?width=650&token=VXJ1BzmoVE&height=150&src=pr)](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master      #60   +/-   ##
=======================================
  Coverage   98.33%   98.33%           
=======================================
  Files         226      226           
  Lines        9869     9869           
=======================================
  Hits         9705     9705           
  Misses        164      164
```


| [Impacted Files](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [cauldron/cli/commands/open/\_\_init\_\_.py](https://codecov.io/gh/sernst/cauldron/pull/60/diff?src=pr&el=tree#diff-Y2F1bGRyb24vY2xpL2NvbW1hbmRzL29wZW4vX19pbml0X18ucHk=) | `86.56% <ø> (-0.2%)` | :arrow_down: |
| [cauldron/cli/commands/open/opener.py](https://codecov.io/gh/sernst/cauldron/pull/60/diff?src=pr&el=tree#diff-Y2F1bGRyb24vY2xpL2NvbW1hbmRzL29wZW4vb3BlbmVyLnB5) | `100% <100%> (ø)` | :arrow_up: |
| [.../test/cli/server/routes/synchronize/test\_status.py](https://codecov.io/gh/sernst/cauldron/pull/60/diff?src=pr&el=tree#diff-Y2F1bGRyb24vdGVzdC9jbGkvc2VydmVyL3JvdXRlcy9zeW5jaHJvbml6ZS90ZXN0X3N0YXR1cy5weQ==) | `100% <100%> (ø)` | :arrow_up: |
| [cauldron/session/projects/project.py](https://codecov.io/gh/sernst/cauldron/pull/60/diff?src=pr&el=tree#diff-Y2F1bGRyb24vc2Vzc2lvbi9wcm9qZWN0cy9wcm9qZWN0LnB5) | `96.65% <100%> (+0.01%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=footer). Last update [8b847df...f8262a8](https://codecov.io/gh/sernst/cauldron/pull/60?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

coveralls: 
[![Coverage Status](https://coveralls.io/builds/22361673/badge)](https://coveralls.io/builds/22361673)

Coverage remained the same at 98.338% when pulling **f8262a812166a4fe91a395607c9835bab6855ac7 on 59-libs-loading** into **8b847dfc49a20186db0d3a506eda55370deb92e3 on master**.


Patch:
diff --git a/cauldron/cli/commands/open/__init__.py b/cauldron/cli/commands/open/__init__.py
index 8112986..138814e 100644
--- a/cauldron/cli/commands/open/__init__.py
+++ b/cauldron/cli/commands/open/__init__.py
@@ -1,7 +1,6 @@
 import os
 import typing
 from argparse import ArgumentParser
-import requests
 
 import cauldron
 from cauldron import cli
diff --git a/cauldron/cli/commands/open/opener.py b/cauldron/cli/commands/open/opener.py
index 35ade2f..2300c43 100644
--- a/cauldron/cli/commands/open/opener.py
+++ b/cauldron/cli/commands/open/opener.py
@@ -171,7 +171,10 @@ def open_project(
             message='Unable to write project notebook data'
         ).console(whitespace=1).response
 
-    runner.add_library_path(project.source_directory)
+    # Should no longer be needed because the source directory is included
+    # in the library directories as of v0.4.7
+    # runner.add_library_path(project.source_directory)
+    runner.reload_libraries(project.library_directories)
 
     return response.update(
         project=project.kernel_serialize()
diff --git a/cauldron/cli/sync/files.py b/cauldron/cli/sync/files.py
index 9a0e5ba..3255e1d 100644
--- a/cauldron/cli/sync/files.py
+++ b/cauldron/cli/sync/files.py
@@ -159,7 +159,13 @@ def send_all_in(
         directory
     ).rstrip(os.path.sep)
 
-    for file_path in glob.iglob(glob_path, recursive=True):
+    # Only send files that have non-zero size
+    file_paths = (
+        p
+        for p in glob.iglob(glob_path, recursive=True)
+        if os.path.isfile(p) and os.path.getsize(p) > 0
+    )
+    for file_path in file_paths:
         relative_path = file_path[len(root_path):].lstrip(os.path.sep)
 
         response = send(
diff --git a/cauldron/session/projects/project.py b/cauldron/session/projects/project.py
index 3698457..428a967 100644
--- a/cauldron/session/projects/project.py
+++ b/cauldron/session/projects/project.py
@@ -51,11 +51,9 @@ class Project:
         self.remote_source_directory = None  # type: str
 
         def as_shared_cache(source):
-            if source is None:
-                return SharedCache()
-            if not hasattr(source, 'fetch'):
+            if source and not hasattr(source, 'fetch'):
                 return SharedCache().put(**source)
-            return source
+            return source or SharedCache()
 
         self.stop_condition = StopCondition(False, False)  # type: StopCondition
         self.shared = as_shared_cache(shared)
@@ -100,6 +98,9 @@ class Project:
         # Include the remote shared library folder as well
         folders.append('../__cauldron_shared_libs')
 
+        # Include the project directory as well
+        folders.append(self.source_directory)
+
         return [
             environ.paths.clean(os.path.join(self.source_directory, folder))
             for folder in folders
diff --git a/cauldron/settings.json b/cauldron/settings.json
index ce8a660..828015e 100644
--- a/cauldron/settings.json
+++ b/cauldron/settings.json
@@ -1,4 +1,4 @@
 {
-  "version": "0.4.6",
+  "version": "0.4.7",
   "notebookVersion": "v1"
 }


Test patch:
diff --git a/cauldron/test/cli/server/routes/synchronize/test_status.py b/cauldron/test/cli/server/routes/synchronize/test_status.py
index d079684..f13c041 100644
--- a/cauldron/test/cli/server/routes/synchronize/test_status.py
+++ b/cauldron/test/cli/server/routes/synchronize/test_status.py
@@ -44,5 +44,5 @@ class TestStatus(scaffolds.ResultsTest):
         project = cauldron.project.get_internal_project()
         results = status.of_project(project)
 
-        self.assertEqual(len(results['libraries']), 2)
+        self.assertEqual(len(results['libraries']), 3)
         self.assertEqual(len(results['project'].keys()), 1)