diff --git a/dotscience/__init__.py b/dotscience/__init__.py
index e12da54..c2c3ac3 100644
--- a/dotscience/__init__.py
+++ b/dotscience/__init__.py
@@ -253,6 +253,9 @@ class Dotscience:
     currentRun = None
 
     def __init__(self):
+        self._reset()
+
+    def _reset(self):
         self._mode = None
         self._workload_file = None
         self._root = os.getenv('DOTSCIENCE_PROJECT_DOT_ROOT', default=os.getcwd())
@@ -269,6 +272,7 @@ class Dotscience:
         # TODO: make publish etc fail if we're not connected in remote mode.
         if not project:
             raise Exception("Please specify a project name as the third argument to ds.connect()")
+        self._reset()
         self._dotmesh_client = DotmeshClient(
             cluster_url=hostname + "/v2/dotmesh/rpc",
             username=username,

ds.connect() only connects to single project and runs overwritten [fusemachines]
Fuse machines run ds.connect() from a local machine but it only connects to a single project.

Also runs are getting overwritten when running on the same machine.

This text is just a placeholder: it was decided on the Fuse machines call Oct 21st 4-5pm BST that they may need to do a call with the support engineer to fully explain. And/or send a video/screenshots.

Link to description from Fuse Machines: https://docs.google.com/document/d/1ZLhKlW6AG3khlPVyrINXD3LaS1fSTilyEorrj66w9ow
diff --git a/dotscience/test_dotscience.py b/dotscience/test_dotscience.py
index 92790c7..89ab7e9 100644
--- a/dotscience/test_dotscience.py
+++ b/dotscience/test_dotscience.py
@@ -857,3 +857,39 @@ def test_multi_publish_2():
     assert m1["__ID"] != m2["__ID"]
     assert m1["start"] != m2["start"]
     assert m1["end"] != m2["end"]
+
+
+def test_reconnect_resets_internal_state(monkeypatch):
+    class FakeDotmeshClient:
+        def __init__(self, cluster_url, username, api_key):
+            self.cluster_url = cluster_url
+            self.username = username
+            self.api_key = api_key
+
+        def ping(self):
+            pass
+
+    monkeypatch.setattr(dotscience, "DotmeshClient", FakeDotmeshClient)
+
+    ds = dotscience.Dotscience()
+    ds.connect("me", "pass", "myproj", "https://example.com")
+    assert ds._dotmesh_client.__dict__ == {
+        "cluster_url": "https://example.com/v2/dotmesh/rpc",
+        "username": "me",
+        "api_key": "pass",
+    }
+    assert ds._project_name == "myproj"
+
+    # Pretend we have a cached project:
+    ds._cached_project = "not empty"
+    assert ds._get_project_or_create("myproj") == "not empty"
+
+    # Now, reconnect:
+    ds.connect("me2", "pass2", "myproj2", "https://2.example.com")
+    assert ds._dotmesh_client.__dict__ == {
+        "cluster_url": "https://2.example.com/v2/dotmesh/rpc",
+        "username": "me2",
+        "api_key": "pass2",
+    }
+    assert ds._project_name == "myproj2"
+    assert ds._cached_project == None

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest hypothesis
apt-get update apt-get install -y gcc
3.7
examples/requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
absl-py==2.1.0
apply-defaults==0.1.6
astor==0.8.1
attrs==24.2.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
click==6.7
datadots-api==0.2.4
-e git+https://github.com/dotmesh-io/dotscience-python.git@7e2ec1fceacd0bd8ec2517a2dd6cc9fd74a0f82a#egg=dotscience
exceptiongroup==1.2.2
gast==0.6.0
google-pasta==0.2.0
grpcio==1.62.3
h5py==3.8.0
hypothesis==6.79.4
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
jsonrpcclient==3.3.4
jsonschema==3.2.0
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
Markdown==3.4.4
MarkupSafe==2.1.5
numpy==1.21.6
packaging==24.0
pluggy==1.2.0
protobuf==4.24.4
pyrsistent==0.19.3
pytest==7.4.4
requests==2.31.0
six==1.17.0
sortedcontainers==2.4.0
tensorboard==1.14.0
tensorflow==1.14.0
tensorflow-estimator==1.14.0
termcolor==2.3.0
tomli==2.0.1
typing_extensions==4.7.1
urllib3==2.0.7
Werkzeug==2.2.3
wrapt==1.16.0
zipp==3.15.0

name: dotscience-python
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - absl-py==2.1.0
      - apply-defaults==0.1.6
      - astor==0.8.1
      - attrs==24.2.0
      - charset-normalizer==3.4.1
      - click==6.7
      - datadots-api==0.2.4
      - exceptiongroup==1.2.2
      - gast==0.6.0
      - google-pasta==0.2.0
      - grpcio==1.62.3
      - h5py==3.8.0
      - hypothesis==6.79.4
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - jsonrpcclient==3.3.4
      - jsonschema==3.2.0
      - keras-applications==1.0.8
      - keras-preprocessing==1.1.2
      - markdown==3.4.4
      - markupsafe==2.1.5
      - numpy==1.21.6
      - packaging==24.0
      - pluggy==1.2.0
      - protobuf==4.24.4
      - pyrsistent==0.19.3
      - pytest==7.4.4
      - requests==2.31.0
      - six==1.17.0
      - sortedcontainers==2.4.0
      - tensorboard==1.14.0
      - tensorflow==1.14.0
      - tensorflow-estimator==1.14.0
      - termcolor==2.3.0
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - werkzeug==2.2.3
      - wrapt==1.16.0
      - zipp==3.15.0
prefix: /opt/conda/envs/dotscience-python

dotscience/test_dotscience.py::test_reconnect_resets_internal_state
dotscience/test_dotscience.py::test_default_script_name
dotscience/test_dotscience.py::test_run_null dotscience/test_dotscience.py::test_run_basics dotscience/test_dotscience.py::test_run_input_1 dotscience/test_dotscience.py::test_run_input_relative dotscience/test_dotscience.py::test_run_input_2 dotscience/test_dotscience.py::test_run_input_n dotscience/test_dotscience.py::test_run_input_recursive dotscience/test_dotscience.py::test_run_output_1 dotscience/test_dotscience.py::test_run_output_relative dotscience/test_dotscience.py::test_run_output_2 dotscience/test_dotscience.py::test_run_output_n dotscience/test_dotscience.py::test_run_output_recursive dotscience/test_dotscience.py::test_run_tensorflow_model dotscience/test_dotscience.py::test_run_tensorflow_model_with_classes dotscience/test_dotscience.py::test_run_labels_1 dotscience/test_dotscience.py::test_run_labels_multi dotscience/test_dotscience.py::test_run_summary_1 dotscience/test_dotscience.py::test_run_summary_multi dotscience/test_dotscience.py::test_run_parameter_1 dotscience/test_dotscience.py::test_run_parameter_multi dotscience/test_dotscience.py::test_run_start_1 dotscience/test_dotscience.py::test_run_start_2 dotscience/test_dotscience.py::test_run_end_1 dotscience/test_dotscience.py::test_run_end_2 dotscience/test_dotscience.py::test_no_mode dotscience/test_dotscience.py::test_notice_jupyter_mode dotscience/test_dotscience.py::test_notice_command_mode dotscience/test_dotscience.py::test_conflicting_mode_1 dotscience/test_dotscience.py::test_conflicting_mode_2 dotscience/test_dotscience.py::test_non_conflicting_mode_1 dotscience/test_dotscience.py::test_non_conflicting_mode_2 dotscience/test_dotscience.py::test_no_script_name_when_interactive dotscience/test_dotscience.py::test_explicit_script_name dotscience/test_dotscience.py::test_null dotscience/test_dotscience.py::test_start_end dotscience/test_dotscience.py::test_description_a dotscience/test_dotscience.py::test_description_b dotscience/test_dotscience.py::test_description_c dotscience/test_dotscience.py::test_error_a dotscience/test_dotscience.py::test_error_b dotscience/test_dotscience.py::test_input_1a dotscience/test_dotscience.py::test_input_1b dotscience/test_dotscience.py::test_input_n dotscience/test_dotscience.py::test_output_1a dotscience/test_dotscience.py::test_output_1b dotscience/test_dotscience.py::test_output_n dotscience/test_dotscience.py::test_label_1a dotscience/test_dotscience.py::test_label_1b dotscience/test_dotscience.py::test_label_n dotscience/test_dotscience.py::test_summary_1a dotscience/test_dotscience.py::test_summary_1b dotscience/test_dotscience.py::test_summary_n dotscience/test_dotscience.py::test_parameter_1a dotscience/test_dotscience.py::test_parameter_1b dotscience/test_dotscience.py::test_parameter_n dotscience/test_dotscience.py::test_multi_publish_1 dotscience/test_dotscience.py::test_multi_publish_2
dotscience/__init__.py
dotscience/__init__.py