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

Gateway: implement sets of filter to return function by specific criteria #1456

Closed
IceKhan13 opened this issue Aug 14, 2024 · 7 comments · Fixed by #1466
Closed

Gateway: implement sets of filter to return function by specific criteria #1456

IceKhan13 opened this issue Aug 14, 2024 · 7 comments · Fixed by #1466
Assignees
Labels
enhancement New feature or request project: gateway Label to identify features related with gateway project

Comments

@IceKhan13
Copy link
Member

What is the expected behavior?

We want to have jobs and programs endpoints to have additional filtering parameter (https:///v1/jobs?filter=<filter_name>).

Initially we need only 2 filters (names might change):

  • providers
    • for /programs?filter=providers will return function uploaded by providers only
    • for /jobs?filter=providers will return only user jobs associated with providers only
  • user
    • for /programs?filter=user will return function uploaded by this user only
    • for /jobs?filter=user will return only user jobs associated with only user programs

2 filters above are mutually exclusive.

@IceKhan13 IceKhan13 added the project: gateway Label to identify features related with gateway project label Aug 14, 2024
@Tansito
Copy link
Member

Tansito commented Aug 14, 2024

Do you need help with this, @IceKhan13 ?

@IceKhan13
Copy link
Member Author

Yes, I'm pretty busy in next few days. If somebody can take it during this time, it will be great!

@Tansito Tansito added the enhancement New feature or request label Aug 16, 2024
@akihikokuroda
Copy link
Collaborator

@IceKhan13 Are the values below instead of "user" or "providers" ?

PRE_FILTER_KEYWORD: str = "catalog"
PRE_FILTER_KEYWORD: str = "serverless"

@akihikokuroda
Copy link
Collaborator

This is the snippet of job client. This needs some changes, doesn't it?

    def list(self, **kwargs) -> List["Job"]:
        tracer = trace.get_tracer("client.tracer")
        with tracer.start_as_current_span("job.list"):
            limit = kwargs.get("limit", 10)
            offset = kwargs.get("offset", 0)
            response_data = safe_json_request(
                request=lambda: requests.get(
                    f"{self.host}/api/{self.version}/jobs/?limit={limit}&offset={offset}",
                    headers={"Authorization": f"Bearer {self._token}"},
                    timeout=REQUESTS_TIMEOUT,
                )
            )
        return [
            Job(job.get("id"), job_client=self, raw_data=job)
            for job in response_data.get("results", [])
	]

The /programs looks good.

def get_programs(self, **kwargs):

@Tansito
Copy link
Member

Tansito commented Aug 21, 2024

@IceKhan13 Are the values below instead of "user" or "providers" ?

PRE_FILTER_KEYWORD: str = "catalog"
PRE_FILTER_KEYWORD: str = "serverless"

Open to discuss but I would not attach the client to the end-point. If other client would like to retrieve user or partner would need to use catalog or serverless. I would maintain Iskandar approach here.

@akihikokuroda
Copy link
Collaborator

user
for /programs?filter=user will return function uploaded by this user only

I believe that this is the current behavior without the filter, right? @IceKhan13 @Tansito

@Tansito
Copy link
Member

Tansito commented Aug 21, 2024

I believe that this is the current behavior without the filter, right? @IceKhan13 @Tansito

I would say the logic changes a little bit:

  • user: user == author && provider is None
  • provider: VIEW_PERMISSION && provider is not None

That way user always returns user functions and provider always returns provider functions. And if there is no filter I would do what we are basically doing right now: user == author && VIEW_PERMISSION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request project: gateway Label to identify features related with gateway project
Projects
None yet
3 participants