internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: edgedb/edgedb

Issue:
Overloading a link with a more specific type fails
When this schema is described, the overload on the `parent` link to link it to a different type appears to have been ignored.

`describe schema as sdl;` produces this for `Human`:
```esdl
type Human extending default::Animal {
    overloaded link parent;
};
```

`describe schema;` produces this:
```edgeql
create module default if not exists;
create abstract type default::Animal {
    create link parent: default::Animal;
    create property name: std::str;
};
create type default::Human extending default::Animal {
    alter link parent {
        SET OWNED;
    };
};
```

- EdgeDB Version: 4.4+aa576e1
- EdgeDB CLI Version: 4.0.2+500be79
- OS Version: macOS 14.0

Steps to Reproduce:

1. Migrate the schema
2. Describe the schema

<!-- If the issue is about a query error, please also provide your schema -->

Schema:

```esdl
abstract type Animal {
  name: str;
  parent: Animal;
}
type Human extending Animal {
  overloaded parent: Human;
}
```



Discussion:
related #6701 
I feel pretty silly about this one: seems like it is a bug in the code for omitting `link`/`property` specifiers. If you write `overloaded link parent: Human`, it works.

Resolving patch:
diff --git a/edb/schema/unknown_pointers.py b/edb/schema/unknown_pointers.py
--- a/edb/schema/unknown_pointers.py
+++ b/edb/schema/unknown_pointers.py
@@ -166,6 +166,10 @@ def _cmd_tree_from_ast(
             qlast.AlterConcreteProperty
             if isinstance(obj, s_props.Property)
             else qlast.AlterConcreteLink
+        ) if isinstance(astnode, qlast.AlterObject) else (
+            qlast.CreateConcreteProperty
+            if isinstance(obj, s_props.Property)
+            else qlast.CreateConcreteLink
         )
         astnode = astnode.replace(__class__=astcls)
         qlparser.append_module_aliases(astnode, context.modaliases)


Test patch:
diff --git a/tests/test_schema.py b/tests/test_schema.py
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -10200,6 +10200,27 @@ def test_schema_describe_name_override_03(self):
             """
         )
 
+    def test_schema_describe_overload_01(self):
+        self._assert_describe(
+            """
+            abstract type Animal {
+                name: str;
+                parent: Animal;
+            }
+            type Human extending Animal {
+                overloaded parent: Human;
+            }
+            """,
+
+            'describe type test::Human as sdl',
+
+            """
+            type test::Human extending test::Animal {
+                overloaded link parent: test::Human;
+            };
+            """,
+        )
+
 
 class TestCreateMigration(tb.BaseSchemaTest):
Repository: edgedb/edgedb

Issue:
ISE: cannot create root rvar for non-object path
- EdgeDB Version: 5.0-beta.1+15775e6
- EdgeDB CLI Version: 4.1.0+127aeb9
- OS Version: Win 11

Steps to Reproduce:

1. Try to make a migration `edgedb migrate` with attached initial migration: 
[00001_edgeql.txt](https://github.com/edgedb/edgedb/files/14491317/00001_edgeql.txt)





Discussion:
Here's a reduced version:
```
  CREATE GLOBAL val := ('asdf');
  CREATE FUNCTION test() -> OPTIONAL str {
      USING (GLOBAL val)
  };
```

There is a dumb bug in how we handle `single` computed globals, where we try to cache them but get our wires crossed.

For you, this is happening with the global variable `default::dayClosure`. A workaround would be to declare it as `multi`.

Fix forthcoming.

Resolving patch:
diff --git a/edb/pgsql/compiler/relctx.py b/edb/pgsql/compiler/relctx.py
--- a/edb/pgsql/compiler/relctx.py
+++ b/edb/pgsql/compiler/relctx.py
@@ -501,9 +501,6 @@ def new_primitive_rvar(
     lateral: bool,
     ctx: context.CompilerContextLevel,
 ) -> pgast.PathRangeVar:
-    if not ir_set.path_id.is_objtype_path():
-        raise ValueError('cannot create root rvar for non-object path')
-
     if isinstance(ir_set.expr, irast.TypeRoot):
         skip_subtypes = ir_set.expr.skip_subtypes
     else:
@@ -1431,6 +1428,9 @@ def range_for_material_objtype(
         typeref = typeref.material_type
     is_global = typeref.material_type is not None
 
+    if not is_global and not path_id.is_objtype_path():
+        raise ValueError('cannot create root rvar for non-object path')
+
     relation: Union[pgast.Relation, pgast.CommonTableExpr]
 
     assert isinstance(typeref.name_hint, sn.QualName)


Test patch:
diff --git a/tests/test_edgeql_globals.py b/tests/test_edgeql_globals.py
--- a/tests/test_edgeql_globals.py
+++ b/tests/test_edgeql_globals.py
@@ -40,6 +40,9 @@ class TestEdgeQLGlobals(tb.QueryTestCase):
             create required global def_cur_user -> str {
                 set default := 'Alice'
             };
+            create global def_cur_user_excited := (
+                global def_cur_user ++ '!'
+            );
             create global cur_card -> str {
                 set default := 'Dragon'
             };
@@ -119,9 +122,10 @@ async def test_edgeql_globals_02(self):
 
         await self.assert_query_result(
             r'''
-                select (global cur_user, global def_cur_user)
+                select (global cur_user, global def_cur_user,
+                        global def_cur_user_excited)
             ''',
-            [['Bob', 'Dave']],
+            [['Bob', 'Dave', 'Dave!']],
         )
 
     async def test_edgeql_globals_03(self):
Repository: edgedb/edgedb

Issue:
ALTER MODULE foo RENAME TO bar gives ISE
We should produce a parse error or an unimplemented message.

We could actually support it, but it might actually be kind of hairy to do, since in the data model modules really don't *do* anything, they *just* lay claim to a name. (And DDL isn't *that* important anyway; renaming a module might actually work in SDL...)


Discussion:

Resolving patch:
diff --git a/edb/schema/modules.py b/edb/schema/modules.py
--- a/edb/schema/modules.py
+++ b/edb/schema/modules.py
@@ -96,6 +96,19 @@ class AlterModule(ModuleCommand, sd.AlterObject[Module]):
     astnode = qlast.AlterModule
 
 
+class RenameModule(ModuleCommand, sd.RenameObject[Module]):
+
+    def apply(
+        self,
+        schema: s_schema.Schema,
+        context: sd.CommandContext,
+    ) -> s_schema.Schema:
+        raise errors.SchemaError(
+            f'renaming modules is not supported',
+            span=self.span,
+        )
+
+
 class DeleteModule(ModuleCommand, sd.DeleteObject[Module]):
     astnode = qlast.DropModule
 


Test patch:
diff --git a/tests/test_edgeql_ddl.py b/tests/test_edgeql_ddl.py
--- a/tests/test_edgeql_ddl.py
+++ b/tests/test_edgeql_ddl.py
@@ -8750,6 +8750,19 @@ async def test_edgeql_ddl_modules_04(self):
                 DROP MODULE test_other;
             """)
 
+    async def test_edgeql_ddl_modules_05(self):
+        await self.con.execute(r"""
+            CREATE MODULE foo;
+        """)
+
+        async with self.assertRaisesRegexTx(
+            edgedb.SchemaError,
+            "renaming modules is not supported",
+        ):
+            await self.con.execute(r"""
+                ALTER MODULE foo RENAME TO bar;
+            """)
+
     async def test_edgeql_ddl_extension_package_01(self):
         await self.con.execute(r"""
             CREATE EXTENSION PACKAGE foo_01 VERSION '1.0' {
Repository: voxel51/fiftyone

Issue:
fiftyone fails to import if not installed in a virtual environment
Due to at least https://github.com/voxel51/fiftyone/blob/v0.1.3/fiftyone/constants.py#L32


Discussion:
Why is that constant even there? It doesn't seem to be used

Resolving patch:
diff --git a/fiftyone/constants.py b/fiftyone/constants.py
--- a/fiftyone/constants.py
+++ b/fiftyone/constants.py
@@ -29,7 +29,6 @@
 
 # Directories
 FIFTYONE_DIR = os.path.abspath(os.path.dirname(__file__))
-FIFTYONE_ENV = os.environ["VIRTUAL_ENV"]
 FIFTYONE_CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".fiftyone")
 FIFTYONE_CONFIG_PATH = os.path.join(FIFTYONE_CONFIG_DIR, "config.json")
 BASE_DIR = os.path.dirname(FIFTYONE_DIR)
@@ -58,7 +57,6 @@
 DB_BIN_PATH = os.path.join(FIFTYONE_DB_BIN_DIR, "mongod")
 DB_CLIENT_BIN_PATH = os.path.join(FIFTYONE_DB_BIN_DIR, "mongo")
 DB_LOG_PATH = os.path.join(FIFTYONE_CONFIG_DIR, "var/log/mongodb/mongo.log")
-os.environ["PATH"] = os.pathsep.join([FIFTYONE_CONFIG_DIR, os.environ["PATH"]])
 START_DB = [
     DB_BIN_PATH,
     "--dbpath",


Test patch:
Repository: voxel51/fiftyone

Issue:
Can't load dataset on latest develop
On latest `develop`, after rerunning the install script, I see:
```py
import fiftyone as fo                                                                                                                                                        
import fiftyone.zoo as foz                                                                                                                                                   

dataset = foz.load_zoo_dataset("cifar10", split="test")                                                                                                                      
Split 'test' already downloaded
Loading existing dataset 'cifar10-test'. To reload from disk, first delete the existing dataset

fo.launch_dashboard(dataset) 
```

<img width="1662" alt="Screen Shot 2020-06-10 at 5 50 09 PM" src="https://user-images.githubusercontent.com/25985824/84322368-dd775d00-ab42-11ea-8d96-31dcdb3ea85b.png">



Discussion:

Resolving patch:
diff --git a/fiftyone/server/main.py b/fiftyone/server/main.py
--- a/fiftyone/server/main.py
+++ b/fiftyone/server/main.py
@@ -18,9 +18,11 @@
 # pragma pylint: enable=unused-wildcard-import
 # pragma pylint: enable=wildcard-import
 
+import json
 import logging
 import os
 
+from bson import json_util
 from flask import Flask, request, send_file
 from flask_socketio import emit, Namespace, SocketIO
 
@@ -152,7 +154,9 @@ def on_page(self, page, page_length=20):
             return []
 
         view = view.skip((page - 1) * page_length).limit(page_length + 1)
-        samples = [s.to_dict(extended=True) for s in view]
+        samples = [
+            json.loads(json_util.dumps(s.to_mongo_dict())) for s in view
+        ]
         more = False
         if len(samples) > page_length:
             samples = samples[:page_length]


Test patch:
Repository: voxel51/fiftyone

Issue:
Pretty-print view stages when showing dataset summaries (and in general)
I recently ran this:

```py
# Sort by likelihood of mistake (most likely first) 
mistake_view = (dataset.view() 
    .match_tag("processed") 
.sort_by("mistakenness", reverse=True) 
) 
print(mistake_view)                                                                                                                                                          
```

and saw this:

```
Dataset:        cifar10-test
Num samples:    1000
Tags:           ['test', 'processed', 'mistake']
Sample fields:
    filepath:     fiftyone.core.fields.StringField
    tags:         fiftyone.core.fields.ListField(fiftyone.core.fields.StringField)
    metadata:     fiftyone.core.fields.EmbeddedDocumentField(fiftyone.core.metadata.Metadata)
    ground_truth: fiftyone.core.fields.EmbeddedDocumentField(fiftyone.core.labels.Classification)
    resnet50:     fiftyone.core.fields.EmbeddedDocumentField(fiftyone.core.labels.Classification)
    mistakenness: fiftyone.core.fields.FloatField
Pipeline stages:
    1. <fiftyone.core.stages.MatchTag object at 0x13afdaf60>
    2. <fiftyone.core.stages.SortBy object at 0x13b10e128>
```

We should pretty-print the view stages so their content is human-readable.

Following existing patterns in the codebase, we should implement `ViewStage.__repr__` and `ViewStage.__str__` so that view stages are always pretty-printed


Discussion:

Resolving patch:
diff --git a/fiftyone/core/stages.py b/fiftyone/core/stages.py
--- a/fiftyone/core/stages.py
+++ b/fiftyone/core/stages.py
@@ -18,12 +18,18 @@
 # pragma pylint: enable=unused-wildcard-import
 # pragma pylint: enable=wildcard-import
 
+import reprlib
+
 from bson import ObjectId
 from pymongo import ASCENDING, DESCENDING
 
 import eta.core.utils as etau
 
 
+# max number of list elements to print
+reprlib.aRepr.maxlist = 3
+
+
 class ViewStage(object):
     """Abstract base class for all :class:`fiftyone.core.view.DatasetView`
     stages.
@@ -33,6 +39,16 @@ class ViewStage(object):
             arguments
     """
 
+    def __str__(self):
+        kwarg_str = ", ".join(
+            ["%s=%s" % (k, reprlib.repr(v)) for k, v in self._kwargs().items()]
+        )
+
+        return "%s(%s)" % (self.__class__.__name__, kwarg_str)
+
+    def __repr__(self):
+        return str(self)
+
     def to_mongo(self):
         """Returns the MongoDB version of the
         :class:`fiftyone.core.stages.ViewStage` instance


Test patch:
Repository: voxel51/fiftyone

Issue:
Docs table of contents spacing issue on small screens
On small screens, the table of contents has too much space below it; it should be tight with the bottom of the contents so that the main content is visible:

<img width="717" alt="Screen Shot 2020-07-15 at 3 45 52 PM" src="https://user-images.githubusercontent.com/25985824/87589202-e2d04600-c6b2-11ea-8f24-d3e14ec4cc7e.png">



Discussion:

Resolving patch:
diff --git a/docs/source/conf.py b/docs/source/conf.py
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -100,6 +100,10 @@
 html_css_files = ["css/voxel51-website.css", "css/custom.css"]
 html_js_files = ["js/voxel51-website.js", "js/custom.js"]
 
+# Prevent RST source files from being included in output
+html_copy_source = False
+
+# Links - copied from website config
 html_context = {
     "address_main_line1": "410 N 4th Ave, 3rd Floor",
     "address_main_line2": "Ann Arbor, MI 48104",


Test patch:
Repository: voxel51/fiftyone

Issue:
Incosistent behavior when deleting datasets
Why does the code below seemingly work when I copy + paste the whole thing into ipython, when, conversely, I get an error if I run the same commands one-by-one manually with, say, 1 second of spacing between each?

```py
import fiftyone as fo

dataset1 = fo.Dataset("test")
dataset1.persistent = True
dataset1.delete()

# works only if run immediately after delete() ??????
dataset1 = fo.Dataset("test")
```


Discussion:
Strange. So I did a little testing. The issue is not in creating the dataset via: `fo.Dataset("test")`, it's in assigning `dataset1`. And it doesn't have to do with time, but instead it seems to be whether you're in an interpreter or not. For example, this works when ran in a script:

```python
import time
import fiftyone as fo

dataset1 = fo.Dataset("test")
dataset1.persistent = True
dataset1.delete()

time.sleep(5)

# works only if run immediately after delete() ??????
dataset1 = 51
print(dataset1)
```

But doing this in an interpreter doesn't:
```
In [1]: import fiftyone as fo 
   ...:  
   ...: dataset1 = fo.Dataset("test") 
   ...: dataset1.persistent = True 
   ...: dataset1.delete()              

In [2]: dataset1 = 51                  
---------------------------------------------------------------------------
DoesNotExistError                         Traceback (most recent call last)
~/source/fiftyone/fiftyone/core/dataset.py in __getattribute__(self, name)
    200 
    201         if getattr(self, "_deleted", False):
--> 202             raise DoesNotExistError("Dataset '%s' is deleted" % self.name)
    203 
    204         return super().__getattribute__(name)

DoesNotExistError: Dataset 'test' is deleted
```



The interpreter is trying to access `dataset1.__class__`. I'll have a fix in a sec

Resolving patch:
diff --git a/fiftyone/core/dataset.py b/fiftyone/core/dataset.py
--- a/fiftyone/core/dataset.py
+++ b/fiftyone/core/dataset.py
@@ -195,7 +195,12 @@ def __delitem__(self, sample_id):
         self.remove_sample(sample_id)
 
     def __getattribute__(self, name):
-        if name in ["name", "deleted", "_name", "_deleted"]:
+        if name.startswith("__") or name in [
+            "name",
+            "deleted",
+            "_name",
+            "_deleted",
+        ]:
             return super().__getattribute__(name)
 
         if getattr(self, "_deleted", False):


Test patch:
Repository: voxel51/fiftyone

Issue:
Include sample fields in `dir(sample)`
We should include sample fields in `dir(sample)`, so that users working from an interactive shell that are inspecting their data correctly see that they can access `sample.ground_truth`, for example (see below):

```py
import fiftyone as fo 
import fiftyone.zoo as foz 

dataset = foz.load_zoo_dataset("cifar10", split="test") 
sample = dataset.first()

print(sample)

"ground_truth" in dir(sample)  # False                                                                                                        
```

```
<Sample: {
    'dataset_name': 'cifar10-test',
    'id': '5f31b3d434154128b3a13b6e',
    'filepath': '/Users/Brian/fiftyone/cifar10/test/data/000001.jpg',
    'tags': BaseList(['test']),
    'metadata': None,
    'ground_truth': <Classification: {
        'id': '5f31b3d434154128b3a13aee',
        'label': 'cat',
        'confidence': None,
        'logits': None,
    }>,
}>
```


Discussion:

Resolving patch:
diff --git a/fiftyone/core/sample.py b/fiftyone/core/sample.py
--- a/fiftyone/core/sample.py
+++ b/fiftyone/core/sample.py
@@ -23,6 +23,9 @@ class _Sample(object):
     def __init__(self):
         self._dataset = self._get_dataset()
 
+    def __dir__(self):
+        return super().__dir__() + list(self.field_names)
+
     def __getattr__(self, name):
         try:
             return super().__getattribute__(name)


Test patch:
Repository: voxel51/fiftyone

Issue:
Show currently selected samples in the App, and allow selection/exclusion
We should replace `Dataset: coco-2017-validation` in the App screenshot below with `Selected # samples`, to indicate how many samples are currently selected:

Also, we should add an icon next to `Selected # samples` that the user can click on. This icon would open a small window that lets the user pick between two actions to take:
- show only these samples: this would add a `Select([list, of, selected, samples])` stage to the current view
- exclude these samples: this would add an `Exclude([list, of, selected, samples])` stage to the current view

<img width="1323" alt="Screen Shot 2020-08-13 at 3 25 08 PM" src="https://user-images.githubusercontent.com/25985824/90178699-45803480-dd7a-11ea-9b21-3e1adc413e23.png">



Discussion:

Resolving patch:
diff --git a/fiftyone/server/main.py b/fiftyone/server/main.py
--- a/fiftyone/server/main.py
+++ b/fiftyone/server/main.py
@@ -88,15 +88,23 @@ def get_stages():
     }
 
 
-def _load_state(func):
-    def wrapper(self, *args, **kwargs):
-        state = fos.StateDescriptionWithDerivables.from_dict(self.state)
-        state = func(self, state, *args, **kwargs)
-        self.state = state.serialize()
-        emit("update", self.state, broadcast=True, include_self=False)
-        return self.state
+def _load_state(trigger_update=False):
+    def decorator(func):
+        def wrapper(self, *args, **kwargs):
+            state = fos.StateDescriptionWithDerivables.from_dict(self.state)
+            state = func(self, state, *args, **kwargs)
+            self.state = state.serialize()
+            emit(
+                "update",
+                self.state,
+                broadcast=True,
+                include_self=trigger_update,
+            )
+            return self.state
+
+        return wrapper
 
-    return wrapper
+    return decorator
 
 
 class StateController(Namespace):
@@ -155,7 +163,7 @@ def on_get_current_state(self, _):
         """
         return self.state
 
-    @_load_state
+    @_load_state()
     def on_add_selection(self, state, _id):
         """Adds a sample to the selected samples list.
 
@@ -173,7 +181,7 @@ def on_add_selection(self, state, _id):
         state.selected = list(selected)
         return state
 
-    @_load_state
+    @_load_state()
     def on_remove_selection(self, state, _id):
         """Remove a sample from the selected samples list
 
@@ -191,6 +199,21 @@ def on_remove_selection(self, state, _id):
         state.selected = list(selected)
         return state
 
+    @_load_state()
+    def on_clear_selection(self, state):
+        """Remove all samples from the selected samples list
+
+        Args:
+            state: the current
+                :class:`fiftyone.core.state.StateDescriptionWithDerivables`
+
+        Returns:
+            the updated
+                :class:`fiftyone.core.state.StateDescriptionWithDerivables`
+        """
+        state.selected = []
+        return state
+
     def on_page(self, page, page_length=20):
         """Gets the requested page of samples.
 


Test patch:
Repository: voxel51/fiftyone

Issue:
Tweak code literal formatting in docs tables
There are a couple small issues with how code literals are rendered in tables in the docs:

For example, this code from the user guide https://github.com/voxel51/fiftyone/blob/develop/docs/source/user_guide/using_datasets.rst#default-fields
yields the following:

<img width="778" alt="Screen Shot 2020-07-20 at 9 00 10 AM" src="https://user-images.githubusercontent.com/25985824/87992321-041ba280-cab6-11ea-8c93-2869dc878a45.png">

The two issues are:
- the code literals seem to have an extra `div` around them that always uses the darker background color. So, in the odd-numbered rows with white background, the code has a small dark background surrounding it, which clutters things a bit
- it would be nice if `Metadata` were styled as a blue hyperlink (like the blue links above the table) since they are all links to the API docs. The other red links in the table would ideally be styled as gray links like `None` in the text above, since they are just standard code literals



Discussion:

Resolving patch:
diff --git a/fiftyone/core/odm/mixins.py b/fiftyone/core/odm/mixins.py
--- a/fiftyone/core/odm/mixins.py
+++ b/fiftyone/core/odm/mixins.py
@@ -84,8 +84,8 @@ def wrapper(cls_or_self, field_name, *args, **kwargs):
 
 
 class DatasetMixin(object):
-    """Mixin for required for concrete :class:`fiftyone.core.odm.document.SampleDocument`s
-    that are backed by a dataset
+    """Mixin for concrete :class:`fiftyone.core.odm.document.SampleDocument`
+    subtypes that are backed by a dataset
     """
 
     def __setattr__(self, name, value):
@@ -509,8 +509,8 @@ def _get_fields_ordered(cls, include_private=False):
 
 
 class NoDatasetMixin(object):
-    """Mixin for required for concrete :class:`fiftyone.core.odm.document.SampleDocument`s
-    that are not backed by a dataset
+    """Mixin for concrete :class:`fiftyone.core.odm.document.SampleDocument`
+    subtypes that are not backed by a dataset
     """
 
     def __getattr__(self, name):


Test patch:
Repository: voxel51/fiftyone

Issue:
[BUG] Label stats don't update when views are created on remote sessions
Environment: prod v0.6.4

I load the quickstart in a remote session and open a view with one random sample:

```py
import fiftyone as fo

dataset, session = fo.quickstart(remote=True)
session.view = dataset.take(1)
```

However, the App incorrectly shows label stats and sample counts for the entire dataset, not the view:

<img width="1136" alt="Screen Shot 2020-11-04 at 10 34 38 PM" src="https://user-images.githubusercontent.com/25985824/98194872-5d390600-1eee-11eb-92c9-ab50c89d97ee.png">



Discussion:

Resolving patch:
diff --git a/fiftyone/server/main.py b/fiftyone/server/main.py
--- a/fiftyone/server/main.py
+++ b/fiftyone/server/main.py
@@ -272,7 +272,7 @@ def on_get_statistics(self, stages):
         view = fov.DatasetView(state.dataset)
         for stage_dict in stages:
             stage = fosg.ViewStage._from_dict(stage_dict)
-            view.add_stage(stage)
+            view = view.add_stage(stage)
 
         return fos.DatasetStatistics(view).serialize()["stats"]
 


Test patch: